Instalasi Openvpn di Ubuntu dan Debian

ubuntu adalah keluarga dari distro debian maka saya gabung saja untuk instalasinya. kita cari cara yang paling mudah saja berlanjut anti ke  advance.

Kebutuhan system:
Vps/Dedicated server dengan dev tun/tap sudah enable, iptables ready, internet access ready and root access.
kita cek dev tun  nya
$ ls -al /dev/net/tun
crw-rw—- 1 root root 10, 200 2010-02-28 01:54 /dev/net/tun
selanjutnya install paket yang di perlukan karena di debian dan ubuntu ada apt-get maka cara paling mudah menggunakan apt-get
$ apt-get install gcc pam-devel openssl-devel make openvpn liblzo2-dev
untuk keluarga redhat seperti centos,rhell,fedora bisa gunakan
$ yum install gcc pam-devel openssl-devel make openvpn liblzo2-dev
di sini kita memakai cara paling gampang saja. ikuti panduan di atas dan ketik Y untuk instalasinya. setelah selesai maka kita bisa mendapati openvpn sudah masuk system. bisa di cek di /usr/sbin/
langkah selanjutnya adalah
membuat configurasi dan generate certificate.
$ cd /etc/openvpn/
# kita cari dimana easy-rsa berada dan lalu kita pake versi 2.0
$ find / -name "easy-rsa"
/usr/share/doc/openvpn/examples/easy-rsa
$ cp –r /usr/share/doc/openvpn/examples/easy-rsa/ /etc/openvpn/
$ cd /etc/openvpn/easy-rsa/2.0
$ source ./vars
$ ./vars
$ ./clean-all
$ ./build-ca
Generating a 1024 bit RSA private key
…..++++++
………………………………………………………………………………………………++++++
writing new private key to ‘ca.key
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [ID]:
State or Province Name (full name) [WJ]:
Locality Name (eg, city) [BANDUNG]:
Organization Name (eg, company) [ardantus.NET]:
Organizational Unit Name (eg, section) []:VPN
Common Name (eg, your name or your server’s hostname) []:ardantus.com
Email Address [ardantus@vpnindo.com]:
$ ./build-key-server server
Generating a 1024 bit RSA private key
……….++++++
……….++++++
writing new private key to ‘server.key
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [ID]:
State or Province Name (full name) [WJ]:
Locality Name (eg, city) [BANDUNG]:
Organization Name (eg, company) [ardantus.NET]:
Organizational Unit Name (eg, section) []:VPN
Common Name (eg, your name or your server’s hostname) []:ardantus.com
Email Address [ardantus@vpnindo.com]:
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:piyungan83
An optional company name []:ardantus.NET
Using configuration from /etc/openvpn/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName           : PRINTABLE:’ID’
stateOrProvinceName   : PRINTABLE:’WJ’
localityName          : PRINTABLE:’BANDUNG’
organizationName      : PRINTABLE:’ardantus.NET
organizationalUnitName: PRINTABLE:’VPN’
commonName            : PRINTABLE:’ardantus.com
emailAddress          :IA5STRING:’ardantus@vpnindo.com
Certificate is to be certified until Apr 12 01:36:33 2020 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
$ ./build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
……………………+…………………………………..+.
……………………+…………………………………..+.
$ cp /etc/openvpn/easy-rsa/2.0/keys /etc/openvpn/keys –R
# salin ke directory /etc/openvpn/keys
Selanjutnya kita buat .conf nya
buat file server.conf
isi dengan “dev tun” tanpa tanda petik
selanjutnya buat conf lain nya seperti contoh berikut:
—————————
port 1194
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem
plugin /usr/lib/openvpn/openvpn-auth-pam.so /etc/pam.d/login
client-cert-not-required
username-as-common-name
server 10.1.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1"
push "dhcp-option DNS 4.2.2.1"
push "dhcp-option DNS 4.2.2.2"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3
————————-
dimanakah menemukan openvpn-auth-pam.so ? itu bisa di cari dengan perintah
$ find / – name “openvpn-auth-pam.so
dan akan ketemu
/usr/lib/openvpn/openvpn-auth-pam.so
untuk centos ada di /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so
Setelah semua sudah di save. sekarang kita coba jalankan
$ /etc/init.d/openvpn start
* Starting virtual private network daemon.                                      * 1194 (OK)
* server (OK)
                                                                        [ OK ]
$ ifconfig
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.1.0.1  P-t-P:10.1.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

sudah jalan :
untuk centos
$ /etc/init.d/openvpn start
/etc/init.d/openvpn restart
Starting openvpn:                                          [  OK  ]
selanjutnya bisa di cek dengan ifconfig
sampai disini openvpn sudah berhasil terinstal, tetapi belum bisa di gunakan, di client. selanjutnya adalah menyalin file keys dan menseting iptables.
$ echo 1 > /proc/sys/net/ipv4/ip_forward
$ /sbin/iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT –to 117.103.58.45
$ /sbin/iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o venet0 -j SNAT –to 117.103.58.45
117.103.58.45 adalah ip vpn saya, bisa di kondisikan dengan ip vpn anda sendiri. itu adalah real ip yang kita gunakan sebagai host tujuan ssh kita.
bisa di masukin script tersebut di /etc/rc.local
kemudian tinggal di jalankan dengan
$ sh /etc/rc.local
untuk centos tidak beda jauh dan bisa juga di masukan ke file /etc/rc.local
contoh di centos sebagai berikut
/sbin/iptables -F
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT –to 173.236.63.177
/sbin/iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o venet0 -j SNAT –to 173.236.63.177
/sbin/iptables -t nat -A POSTROUTING -s 10.10.0.0/24 -o venet0 -j SNAT –to 173.236.63.177
/sbin/iptables-save

ketik di /etc/rc.local simpan kemudian jalankan
$ sh /etc/rc.local
atau bisa di ketik langsung, hanya saja jika suatu waktu nanti vps di restart maka tidak usakh ketik ulang sehingga praktis di masukan ke rc.local
# lankah selanjutnya membuat user yang bisa login di vpn
$ useradd –m -s /bin/false ardan
$ passwd ardan
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
# bisa di kondisikan dengan vpn anda. untuk centos caranya add user sama, kita set nologin supaya user tidak punya akses login ssh ke server vpn.
# lankah selanjutnya salin file ca.crt yang ada di directory /etc/openvpn/keys/
memakai winscp
selanjutnya kita buat file semisal client194.ovpn
client openvpn dan kita taruh di
c:\program files\openvpn\config\
isinya sebagai berikut
—————————————-
client
dev tun
proto udp
remote 173.236.63.177 1194
resolv-retry infinite
route-method exe
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
————————————————

selanjutnya bisa di jalankan openvpn client nya
login dan jika sudah hijau dan complete maka vpn sudah bisa di gunakan bisa di cek di http://www.whatismyip.com apakah ip ita sudah berubah.

pastikan lihat status untuk mengetahui statusnya benar2 sudah komplit, dikarenakan openvpn sudah hijau tetapi gagal, di os win7,winvista. hal tersebut dikarenakanasalah permision, bisa di jalankan as administrator untuk mengatasinya.

untuk openvpn client bisa memakai openvpn yang sudah siap pakai
download di:
http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe
Referensi:
http://www.google.com/
http://openvpn.net/index.php/open-source/documentation.html
http://www.kaskus.us

0 comments:

Post a Comment

Please Enable JavaScript!
Mohon Aktifkan Javascript![ Enable JavaScript ]
close
iklan 120 x 600 kanan
close