So you got one of these scenarios:
-You want a direct connection to a host of yours that is somewhere around the globe and has a real IP
-You want to by pass your *#%*!+%%!* Firewall/Proxy that has a dumb content filtering, doesn’t allow you to SSH, FTP, Connect to Kazaa, or DCC via IRC
-You want to access a private network of a company/your house etc…
1 solution, open a tunnel/VPN.
The methology i’m gonna use is simple and straight forward, but you might need to follow the diagrams that i drew (ugly i know) to help you understand what’s going on exactly.
So that’s your setup, now!

so lets say 255.268.477.985 is your ISPs external IP address, if you don’t know what it is, kindly go to www.whatismyip.com and note it.
now, before continuing note that this method will require you to 0Wn a box somewhere on the Internet, that box has to have Linux installed (Windows works too), and that has a static real IP (a dynamic IP works too, but will not be covered in this HOWTO, email me for personal scenarios such as having to deal with dynamic ips).
My choice for the middle box is my personal dedicated server that is located in the USA. You can get good deals if you search well (email me if you want some of the cheapest hosting companies around). Another cheap solution is a virtual private server, you can find VERY cheap prices, and you’ll have your own root access to the box (again, mail me for more info)
So that’s how the new diagram looks like now with my dedicated server online:

I’m aware that the ips are pretty impossible, but the hell with it =). What we need to do is the following:

of course the tunnel line is VIRTUAL, the traffic still passes thru the traditional physical points of the network.
Now here’s a small summary of the steps we shall follow:
- Find out which port is opened in the OUTPUT circuit/chain of your ISP.
- Decide on whether to use this port on your box to listen to.
- SSHing to your dedicated server (268.999.457.210 in this case)
- Downloading OpenVPN on both client and Server
- Configuring OpenVPN
- Voila
Choosing a port:
Now that’s hard to do, if you know how to work with “nmap”, do it yourself. I’m going to assume that you don’t use HTTPS on your server, and that port 443 is free to use, so lets use it. You can also try port 23 (Telnet) if you don’t usualy telnet to your server.
Another good choice for a port is port 20 ,which is FTP-DATA, you don’t need it if you can connect as FTP Passive.
So ……. (drum rolls) …… port ** 443 **
Now, connecting to your server (online box, middle server, middle host, all are synonyms of 268.999.457.210). If you can’t SSH to the box, Telnet to it (NOT SECURE), if you still can’t then your ISP’s administrator should be thrown in the firy pits of hell.
Go to your school, work place, to a friend or even open a dial up connection.
now, you are connected to your online box:
[sadus@debianbox:~ 10:10 PM]$ ssh -l root 268.999.457.210
[root@sushi-box:~]$
cool !!!
On Debian (My distro of choice):
[root@debianbox:~ 10:10 PM]$ apt-get update && apt-get install openvpn
[root@sushi-box:~]$ apt-get update && apt-get install openvpn
you can still get the sources and compile them your self, or get the .rpms, i won’t cover this, there are plenty of HOWTOs to do that.
make sure you get the following packages:
lzo, libc6, liblzo1, libssl0.9.7, pam (get the latest versions)
remember this is the most basic way to use OpenVPN, but as much as it is easy and basic, its very productive and secure.
type the following on the server:
[root@sushi-box:~]$ cd /etc/openvpn
[root@sushi-box:~]$ openvpn –genkey –secret secret.key
this will create you a 2048 bit OpenVPN static key
[root@sushi-box:~]$ touch configuration.conf
With your favorite editor open configuration.conf that you’ve just created, i’ll use ‘nano’ here
[root@sushi-box:~]$ nano configuration.conf
and paste the following while changing what’s needed to be changed, remember you’re working on the server now:
========================================
# /etc/openvpn/configuration.conf
dev tun
port 443
verb 3
#(enable this if you want to shape the bandwidth's speed)
#shaper 1000
#(this keeps the connection alive)
keepalive 10 120
#(for security purposes)
user nobody
group nogroup
#to log your tunnel
status /etc/openvpn/openvpn-status.log
#(this is the ip of your ISP, get it from www.whatismyip.com
remote 255.268.477.985
#the local tunX ips, the server will be 10.0.0.1, the client 10.0.0.2
#don't forget the switch the ips on the configuration file of your
#client.
ifconfig 10.0.0.1 10.0.0.2
#Using Pre-Shared Secret Key.
secret /etc/openvpn/secret.key
auth MD5
cipher DES-CBC
========================================
now, logon to your local pc:
[sadus@debianbox:~ 10:10 PM]$
and just get everything you created on the server to your local pc, copy
the files via an encrypted connection such as SSH, SFTP, SCP so that you
decrease the risk of someone sniffing your secret.key.
[sadus@debianbox:~ 10:10 PM]$ scp root@268.999.457.210:/etc/openvpn/* /etc/openvpn/
now that you got the files on your local pc, just open configuarion.conf
[root@debianbox:~ 10:10 PM]$ nano configuration.conf
remember you’re working on the client now:
========================================
# /etc/openvpn/configuration.conf
dev tun
port 443
verb 3
#(enable this if you want to shape the bandwidth's speed)
#shaper 1000
#(this keeps the connection alive)
keepalive 10 120
#(for security purposes)
user nobody
group nogroup
#to log your tunnel
status /etc/openvpn/openvpn-status.log
#(this is the ip of your Server
remote 268.999.457.210
#the local tunX ips, the server will be 10.0.0.1, the client 10.0.0.2
#since this is the client and the server is set to 10.0.0.1, the local #
pc should be 10.0.0.2
ifconfig 10.0.0.2 10.0.0.1
#Using Pre-Shared Secret Key.
secret /etc/openvpn/secret.key
auth MD5
cipher DES-CBC
========================================
et voila mes amis, on a fini, enfin we still have some security issues to take care of. You need to know that now, when you run openvpn on your server, it will LISTEN for an incoming connection from a special ip, which is your ISPs IP. When you run openvpn from your client, to the server’s IP, and since the keys are the same, a handshaking will take place and a connection will be established.
do it, DO IT, DO IT (Starsky and Hutch, 2004, Ben Stiller)
Make sure the iptables on your server don’t block port 443
[root@sushi-box:~]$ iptables -I INPUT -p tcp 443 -j ACCEPT
[root@sushi-box:~]$ iptables -I OUTPUT -p tcp 443 -j ACCEPT
[root@sushi-box:~]$ openvpn –config configuration.conf –float –proto tcp-server &
You’ll see a whole load of crap don’t mind them (unless they’re error messages)
[root@debianbox:~ 10:10 PM]$ openvpn –config configuration.conf –float –proto tcp-client &
(the –float option on the client is essential because you’ll be usualy
behind NAT)
and now ladies and gentlemen, the moment of truth…..(drum roll)
[root@debianbox:~ 10:10 PM] ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=747.2 ms
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=847.1 ms
64 bytes from 10.0.0.1: icmp_seq=0 ttl=64 time=658.9 ms
congrats, you’re officialy on a VPN (Virtual Private Network).
lets take now the scenario where you want your server to be your main gateway (so that you can bypass your ISP’s firewall/content filtering etc.. system)
turn off the openvpn from your client side:
[root@debianbox:~ 10:10 PM]$ killall -9 openvpn #could be the fastest way
and delete your default gateway. What’s cool about iproute2 is that you can assign special ips to go to a certain gateway without setting a default gateway on your computer, so here it goes:
[root@debianbox:~ 10:10 PM]$ route del default
[root@debianbox:~ 10:10 PM]$ ip r a 268.999.457.210 via 192.168.1.1
and run openvpn again, it should work normaly.
now you can set your server to be your default gateway by adding this line:
[root@debianbox:~ 10:10 PM]$ route add default gw 10.0.0.1
i’m gonna write other HOWTOs to benefit more of the tunnel we created, such as DNATing, SNATing, DNS etc…
that’s it basicaly, feel free to email me your questions.