VPS has been around for quiet sometime, and, If only I knew it earlier, I wouldn’t gave justhost.com people my money this year for their crappy server
.
Anyways, I got myself a VPS a week ago. before I decided to get one, I was actually seeking for a VPN provider. and when I googled, the term VPS keeps coming on to my screen….so I decided to give it a click…then I got a VPS from rockmyweb.net, nice speed, nice configuration, and cheap.
There are a lot of people talks about setup a VPN in VPS, but those threads are soooo long…after 2 days, I found this http://vpsnoc.com/blog/how-to-install-openvpn-on-a-debianubuntu-vps-instantly/.
This is quick and dirty. and there are a few things I need to modify here for rockmyweb.net hosted VPS, and I use ubuntu for my OS.
Requirement:
A VPS
NAT is enable on your server
Able to create tun nod
This script gives you one cert for you to connect to VPN, for multiple user, see openvpn docs. it’s just a matter of running ./build-key
make sure you have /dev/net/tun
normally you don’t, so you need to create one with root privilege.
mknod /dev/net/tun c 10 200
and you can make sure you have nat support
root@znxf:~# iptables -t nat -L
This usually gives you an empty list, but we know that nat is working(support staff says otherwise, but well, it’s working).
If you see a error message instead, you’ll need to contact support.
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
After you ran this script, you should have keys.tgz in your root folder. Move it to your ftp and download it to your computer, or scp it or whatever.
#!/bin/bash
#
# CrUmp crumpz.info
# Modified for rockmyweb.net hosted VPS
# 04/30/2011
#
# Quick and dirty OpenVPN install script
# Tested on debian 5.0 32bit, openvz minimal debian OS template
# and Ubuntu 9.04 32 bit minimal, should work on 64bit images as well
# Please submit feedback and questions at support@vpsnoc.com
# John Malkowski vpsnoc.com 01/18/2010
#
#
ip=`grep address /etc/network/interfaces | grep -v 127.0.0.1 | awk '{print $2}'`
dnss=`cat /etc/resolv.conf |grep [0-9] | awk '{print $2}'`
dns1=`echo $dnss | awk '{print $1}'`
dns2=`echo $dnss | awk '{print $2}'`
apt-get update
apt-get install openvpn libssl-dev openssl
cd /etc/openvpn/
cp -R /usr/share/doc/openvpn/examples/easy-rsa/ /etc/openvpn/
cd /etc/openvpn/easy-rsa/2.0/
chmod +rwx *
. ./vars
./clean-all
source ./vars
echo -e "\n\n\n\n\n\n\n" | ./build-ca
clear
echo "####################################"
echo "Feel free to accept default values"
echo "Wouldn't recommend setting a password here"
echo "Then you'd have to type in the password each time openVPN starts/restarts"
echo "####################################"
./build-key-server server
./build-dh
cp keys/{ca.crt,ca.key,server.crt,server.key,dh1024.pem} /etc/openvpn/
clear
echo "####################################"
echo "Feel free to accept default values"
echo "This is your client key, you may set a password here but it's not required"
echo "####################################"
./build-key client1
cd keys/
client="
client
remote $ip 1194
dev tun
comp-lzo
ca ca.crt
cert client1.crt
key client1.key
route-delay 2
route-method exe
redirect-gateway def1
verb 3"
echo "$client" > $HOSTNAME.ovpn
tar czf keys.tgz ca.crt ca.key client1.crt client1.csr client1.key $HOSTNAME.ovpn
mv keys.tgz /root
opvpn="
dev tun
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
ca ca.crt
cert server.crt
key server.key
dh dh1024.pem
push "route 10.8.0.0 255.255.255.0"
push "redirect-gateway"
push "dhcp-option DNS $dns1"
push "dhcp-option DNS $dns2"
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
group daemon
daemon"
echo "$opvpn" > /etc/openvpn/openvpn.conf
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to $ip
echo "#!/bin/sh" > /etc/network/if-up.d/iptables
echo "iptables-restore < /etc/iptables.conf" >> /etc/network/if-up.d/iptables
chmod +x /etc/network/if-up.d/iptables
sysctl -w net.ipv4.ip_forward=1
/etc/init.d/openvpn start
clear
echo "OpenVPN has been installed
Download /root/keys.tgz using winscp or other sftp/scp client such as filezilla
Create a directory named vpn at C:Program FilesOpenVPNconfig and untar the content of keys.tgz there
Start openvpn-gui, right click the tray icon go to vpn and click connect
For support/bug reports email us at support@vpsnoc.com"
Now you can download the keys and unpack it to use with Tunnelblick(Mac), or other VPN clients.