Instal OpenVPN di VPS OpenVZ Centos
Instal OpenVPN di VPS OpenVZ Centos maksudnya adalah menginstal OpenVPN di VPS dengan virtuaisasi OpenVZ dan menggunakan operating system Linux Centos. Pada prinsipnya sama aja baik itu KVM, Xen, ataupun OpenVZ. Perbedaannya pada Routing.Langkah-langkah untuk menginstal OpenVPN di Linux Centos adalah sebagai berikut :
update centos
yum update
Periksa Tun/Tap udah terpasang belumcat /dev/net/tun
Kalau sudah benar muncul seperti berikut :cat: /dev/net/tun: File descriptor in bad state
Instal persyaratanyum
install
gcc
make
rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel -y
Download LZO :wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
Download Repo untuk Centos 5 32 bit:wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
Download Repo untuk Centos 6 32 bit:wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.i686.rpm
Download Repo untuk Centos 5 64 bit::wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
Download Repo untuk Centos 6 64 bit:wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Build RPM paketnya :rpmbuild --rebuild lzo-1.08-4.rf.src.rpm rpm -Uvh lzo-*.rpm rpm -Uvh rpmforge-release* Install OpenVPN: yum install openvpn -ySalin easy-rsa ke /etc/openvpn/:
cp -R /usr/share/doc/openvpn-2.2.2/easy-rsa/ /etc/openvpn/
Untuk Centos 6 ada perubahan silahkan di edit:vi /etc/openvpn/easy-rsa/2.0/vars
Ganti teks dibawah:export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
Dengan:export KEY_CONFIG=/etc/openvpn/easy-rsa/2.0/openssl-1.0.0.cnf
Simpan dan KeluarBuat file Sertifikat:
cd /etc/openvpn/easy-rsa/2.0
chmod 755 *
source ./vars
./vars
./clean-all
Build Certificate Authority:
./build-ca
Country Name: may be filled or press enter
State or Province Name: may be filled or press enter
City: may be filled or press enter
Org Name: may be filled or press enter
Org Unit Name: may be filled or press enter
Common Name: your server hostname
Email Address: may be filled or press enter
Build server key:./build-key-server server
Almost the same with ./build.ca but check the changes and additional
Common Name: server
A challenge password: leave
Optional company name: fill or enter
sign the certificate: y
1 out of 1 certificate requests: y
Build Diffie Hellman./build-dh
Buat file config:touch /etc/openvpn/server.confkopi teks berikut :
local x.x.x.x port 443 proto tcp dev tun tun-mtu 1500 tun-mtu-extra 32 mssfix 1450 ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt cert /etc/openvpn/easy-rsa/2.0/keys/server.crt key /etc/openvpn/easy-rsa/2.0/keys/server.key dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/login client-cert-not-required username-as-common-name server 10.6.8.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "redirect-gateway def1" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" keepalive 5 30 comp-lzo persist-key persist-tun status server-tcp.log verb 3Simpan dan jalankan OpenVPN
service openvpn restart
Atur net.ipv4.ip_forwardvi /etc/sysctl.conf
net.ipv4.ip_forward = 1
Supaya terdapat perubahan pada modifikasi tadi:sysctl -p
Jalankan IPtables untuk Xen dan KVM adalah sebagai berikutiptables -t nat -A POSTROUTING -s 10.6.8.0/24 -o eth0 -j MASQUERADE
Untuk OpenVZ adalah sebagai berikut:iptables -t nat -A POSTROUTING -o venet0 -j SNAT --to-source x.x.x.x
dan:iptables -t nat -A POSTROUTING -s 10.6.8.0/24 -j SNAT --to-source x.x.x.x
Ganti x.x.x.x dengan IP VPS. Simpan dan restart IPtables:service iptables save
Service iptables restart
Supaya openVPN jalan di startup:chkconfig openvpn on
Tambahkan User:useradd contohUser -s /bin/false
Atur Password untuk user:passwd contohUser
0 comments:
Post a Comment