Install openVPN di VPS CentOS 5

Sebelum melakukan installasi openVPN di vps anda pastikan akses tun/tap anda enable. untuk mengecek akses tun/tap masukan perintah ini pada console/ssh

# ls -al /dev/net/tun

Apabila tun/tap enable akan ada balasan seperti ini:

[root@arielfx ~]# ls -al /dev/net/tun
 crw------- 1 root root 10, 200 Jul 18 12:03 /dev/net/tun
 [root@arielfx ~]#

agar mempersingkat waktu dalam penginstalan, kita buat saja file .sh, berikut source nya:

#!/bin/sh

echo
echo "============================================="
echo "OpenVPN Setup for CentOS 32bit Linux"
echo "============================================="
echo

mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 600 /dev/net/

rm openvpn-2.0.9.tar.gz
rm lzo-1.08-4.rf.src.rpm
wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm

yum install nano iptables gcc rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel make -y

rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
rpm -Uvh /usr/src/redhat/RPMS/i386/lzo-*.rpm
rpmbuild -tb openvpn-2.0.9.tar.gz
rpm -Uvh /usr/src/redhat/RPMS/i386/openvpn-2.0.9-1.i386.rpm

cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn

cd /etc/openvpn/easy-rsa/2.0
source ./vars
./vars
./clean-all
./build-ca
./build-key-server server
./build-dh
cp /etc/openvpn/easy-rsa/2.0/keys /etc/openvpn/keys -R
cd /etc/openvpn

rm server.conf
wget https://www.dropbox.com/s/8ky0knybi4epjon/server.conf

cd /etc/openvpn

service openvpn restart

echo 1 > /proc/sys/net/ipv4/ip_forward

echo
echo "================================================================================"
echo "Installation Completed"
echo "================================================================================"
echo

Simpan file .sh diatas menjadi openvpn.sh, dan sekarang mulai lakukan instalasi openVPN pada server anda

# sh install-openvpn.sh

tunggu proses instalasi selesai dan selanjutnya system akan meminta anda untuk mengisi informasi data:

Country Name (2 letter code) [KG]:
State or Province Name (full name) [NA]:
Locality Name (eg, city) [BISHKEK]:
Organization Name (eg, company) [OpenVPN-TEST]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server.s hostname) []:
OpenVPN-CAEmail Address [[email protected]]:

supaya tidak repot silakan lakukan enter saja, apabila ada pertanyaan [y/n]
ketik huruf y kemudian enter. tunggu sampai proses instalasi selesai dan di akhiri dengan tulisan

Shuting down openVPN [OK]
Starting openVPN [OK]

Enabling packet forwarding dengan command:

# echo 1 > /proc/sys/net/ipv4/ip_forward

Edit NAT table untuk MASQUERADING

Baca juga:  Tips CentOS Yum Tidak Dapat Menginstall Aplikasi

Command berikut khusus untuk server Dedicated saja:

# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

Sedangkan untuk VPS, command nya adalah sebagai berikut:

# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o venet0 -j SNAT --to xx.xx.x.x

NB: xx.xx.x.x disesuaikan dengan IP venet0 di VPS anda.

Download openVPN berbasis GUI

http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe

Download sertifikat ke komputer anda, file yang di butuhkan adalah ca.crt yang berada dalam folder /etc/openvpn/keys lalu

simpan di folder config di instalasi openvpn pada komputer.

buatlah file konfigurasi client dan beri nama misalkan user1.ovpn dengan isi

client
dev tun
proto udp
remote 234.234.234.234 2342 #Ip ini harus sesuai dengan server vpn nya
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
mute 20
keepalive 10 100
tun-mtu 5000
redirect-gateway def1
route-method exe
route-delay 2

kemudian simpan di dalam folder c://Program File/openVPN/config/user1.ovpn

Membuat user vpn

# useradd namauser -s /bin/false
# passwd namauser

Jalankan dan connect ke vpn anda

Write a Comment

Your email address will not be published.

16 + three =

%d bloggers like this: