Anyway what is openvpn?
http://en.wikipedia.org/wiki/OpenVPNOkay, let's begin.
First off all install CentOS on your vps, here i'm using SolusVM for OS install and choose CentOS 5.5

I'm using CentOS 5.5 because TUN/TAP is not available in CentOS 32bit and x86. Okay, the installation will be finish in approximately 30 minutes, after finished now login to root using ssh.
Before we're going to install OPENVPN, check your TUN/TAP whether it is active or not, if it's not you can try to install another CentOS or contact your vps provider to activate TUN/TAP.
#cat /dev/net/tun
if you're TUN/TAP status is like that, then your TUN/TAP is ready, otherwise it's not.
Now we're begin the installation, first of all install gcc and make.
#yum install gcc make
Download package for OPENVPN
#wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpmDownload repository for OPENVPN
if you're using 32bit version
#wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpmif you're using 64bit version
#wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpmyou can check your server architecture with:
#uname -aInstall package needed for OPENVPN
#yum install rpm-build#yum install autoconf.noarch#yum install zlib-devel#yum install pam-devel#yum install openssl-develInstall the downloaded rpm package and add the repository to your CentOS
#rpmbuild --rebuild lzo-1.08-4.rf.src.rpm#rpm -Uvh /usr/src/redhat/RPMS/x86_64/lzo-*.rpm#rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpmnote: check your architecture engine, if you're using 32bit then change "x86_64" to "i386"
Install OPENVPN
#yum install openvpnCopy the folder for creating certificate to directory /etc/openvpn/
#cp -r /usr/share/doc/openvpn-2.0.9/easy-rsa/ /etc/openvpn/Now let's create the certificate
#cd /etc/openvpn/easy-rsa/2.0#chmod 755 *#source ./vars#./vars#./clean-allBuild CA
#./build-cayou'll be asked to fill the field data, you can empty that with click enter repeatedly, but the one you have to fill is the "Common Name" field.
Build Key Server
#./build-key-server serversame as build-ca, but in the "Common Name" fill with: server
Build Diffie Hellman
#./build-dhBuilding certificate done, now we create the configuration file in the directory /etc/openvpn
#cd /etc/openvpn#nano server.confyou can also use vi or pico editor to create the configuration file
Here is the example of configuration file.
local 123.123.123.123 #- change it with your server ip addressport 1234 #- change the port you wantproto udp #- protocol can be tcp or udpdev tuntun-mtu 1500tun-mtu-extra 32mssfix 1450ca /etc/openvpn/easy-rsa/2.0/keys/ca.crtcert /etc/openvpn/easy-rsa/2.0/keys/server.crtkey /etc/openvpn/easy-rsa/2.0/keys/server.keydh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pemplugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/loginclient-cert-not-requiredusername-as-common-nameserver 1.2.4.0 255.255.255.0push "redirect-gateway def1"push "dhcp-option DNS 208.67.222.222"push "dhcp-option DNS 4.2.2.1"keepalive 5 30comp-lzopersist-keypersist-tunstatus server-tcp.logverb 3Now start the OPENVPN
#openvpn /etc/openvpn/server.confif the status is Initialization Sequence Completed then your OPENVPN is ready.

Now we're enabling ip forward and create NAT iptables rules so we can access the internet with OPENVPN server.
#echo 1 > /proc/sys/net/ipv4/ip_forwardIf you're using VPS:
#iptables -t nat -A POSTROUTING -s 1.2.3.0/24 -j SNAT --to 123.123.123.123If you're using Dedicated Server:
#iptables -t nat -A POSTROUTING -s 1.2.3.0/24 -o eth0 -j MASQUERADEInstall process is done, now create user for you OPENVPN.
#useradd username -s /bin/false#passwd usernameto delete existing user, you can use
#userdel usernameNow go to your OPENVPN GUI config folder and create client configuration file. This is the example for client configuration.
clientdev tunproto udpremote 123.123.123.123 4567 #- your OPENVPN server ip and portresolv-retry infinitenobindtun-mtu 1500tun-mtu-extra 32mssfix 1450persist-keypersist-tunca ca.crtauth-user-passcomp-lzoverb 3save the configuration with filename.ovpn.
And the last thing you have to do is download ca.crt file in directory /etc/openvpn/easy-rsa/2.0/keys to your PC and save to the OPENVPN GUI config folder.

Your OPENVPN is ready!
if you want to test OPENVPN, here's the config file:
http://rapidshare.com/files/407751537/vpn4free_cfg_test.rarrar pass: vpn4free.org
Reference:
http://blog.hostgokil.com/tutorial-instalasi-openvpn-di-vps-centos.html
http://paijrut.net/?p=7
http://www.kaskus.us/showthread.php?t=4437825
This worked, Thanks mate.
ReplyDeletewho is your VPS provider?
thanks very helpful
ReplyDeleteThis is awesome!
ReplyDeleteCan you make a script for this?
I shall highly appreciate it.
very informative. thanks for sharing. will probably try this.
ReplyDeletethank you for this its good for business
ReplyDeleteHi this one is great and is actually a high-quality post. uk vpn
ReplyDelete