Setup OpenVPN for CentOS

Did your ISP Blocked sites? Got a VPS? Well OpenVPN unblocks all sites for you!

OpenVPNI would be teaching you how to install OpenVPN the faster way than going through the hard ways. Basically its a simple script that is packed with all the codes and you would just have to execute it from terminal and put some default options and your done! – Interesting? Well Let’s get started!

Requirements :

  1. Any CentOS 5 32bit VPS with minimum 128MB RAM.
  2. TUN/TAP device enabled on your VPS.
  3. iptables NAT support (For NAT – Contact your VPS Provider).

Procedure :

Are you the server Owner? Then you must setup iptables on your VPS by entering the following command on SSH :

vzctl set YOUR_VEID –iptables ipt_REJECT –iptables ipt_tos –iptables ipt_TOS –iptables ipt_LOG –iptables ip_conntrack –iptables ipt_limit –iptables ipt_multiport –iptables iptable_filter –iptables iptable_mangle –iptables ipt_TCPMSS –iptables ipt_tcpmss –iptables ipt_ttl –iptables ipt_length –iptables ipt_state –iptables iptable_nat –iptables ip_nat_ftp –save

vzctl start YOUR_VEID

Make sure you replace “YOUR_VEID” with your VPS’s VEID.

All right, We would now proceed with the execution of the installer which would install OpenVPN the easy way!

Login to SSH and execute the following commands which is given below :

wget http://www.tharunpkarun.com/data/uploads/openvpninstall.sh

chmod +x openvpninstall.shh

./openvpninstall.sh

You would be  prompted to enter values for your server and client certificate, Just hit the enter key for the default values. Its not recommended to setup a password for your server certificate as you will have to type in the password each time you wish to start/restart the openvpn daemon as it would be surely a headache 😉

After the script finished installing openvpn (should be very quick) the client keys and the openvpn client configuration file will be archived in /root/keys.tgz

You may use a sftp/scp client such as winscp or filezilla to download the archive on your computer.

If you already haven’t installed openvpn for windows you may do so now.
You may use winrar or 7zip to extract the content of keys.tgz in C:Program FilesOpenVPNconfigVPN (create a folder named VPN there)

After you have extracted the files from keys.tgz in the above folder, you may start openvpn-gui from the start menu, right click the tray icon, go to VPN and click connect. After the icon turns green all your traffic will be forwarded through your VPS, no extra configuration on your browser or programs!

Sometimes, you might get some issues with connection – Make sure you got your VPS clock as well as your computer’s clock updated correctly! If your VPS’s clock isn’t correct, Make sure you contact your host so that they could update it for you!

Well, That’s All. Feel free to leave your suggestions/issues via comment! – I would surely help you out!

[Update 18/02/2013] : Links re-uploaded.




May 27, 2012
/
Previous Post Next Post

Tharun recommends you to read these fantastic articles