This setup is CentOS-specific but your install will probably be similar. The config is also for the 2.0 version, the 2.1 series appears to use a different format of config file. It also assumes you're using two linux boxes to do this, and not just join a Windows XP endpoint - so you'll need to make adaptations for the Windows XP install you're using. In this example, the addresses have been chosen at random, so here's how they are assigned:
- 1.1.1.1 is the public address of your server at work facing towards the internet
- 2.2.2.2 is the public address of your server at home facing towards the internet
- 192.168.1.0/24 is the network at your work
- 192.168.1.1 is the internal address of your machine that has 1.1.1.1
- 192.168.1.254 will be the VPN end-point of the machine that has 1.1.1.1
- 192.168.2.0/24 is the network at your home
- 192.168.2.1 is the internal address of your machine that has 2.2.2.2
- 192.168.2.254 will be the VPN end-point of the machine that has 2.2.2.2
and
- both 1.1.1.1 and 2.2.2.2 accept traffic through your firewall on port 1194 from each other only. No sense in accepting traffic from anywhere else and it will cut down on potential attacks.
Secret Static Key
It will be easiest for you to use a static key. Read instructions here on how to make one. Here's the short version done from 1.1.1.1 as root:
openvpn --genkey --secret > /etc/openvpn/secret.key
chmod 600 /etc/openvpn/secret.key
scp /etc/openvpn/static.key root@2.2.2.2:/etc/openvpn/secret.key
ssh root@2.2.2.2
chmod 600 /etc/openvpn/secret.key
exit
Sample Local (Work LAN) Config:
You would place this text in /etc/openvpn/home-vpn
on your work machine (1.1.1.1), assuming that OpenVPN reads the contents of /etc/openvpn
at startup.
#daemon home-vpn
local 1.1.1.1
remote 2.2.2.2
proto tcp-server
port 1194
dev tun0
ifconfig 192.168.1.254 192.168.2.254
route 192.168.2.0 255.255.255.0 192.168.1.254 6
route-delay 5
verb 3
nice 1
secret /etc/openvpn/secret.key
comp-lzo
passtos
Sample Remote (Home LAN) Config:
You would place this text in /etc/openvpn/work-vpn
on your home machine (2.2.2.2), assuming that OpenVPN reads the contents of /etc/openvpn
at startup.
#daemon work-vpn
local 2.2.2.2
remote 1.1.1.1
proto tcp-server
port 1194
dev tun0
ifconfig 192.168.2.254 192.168.1.254
route 192.168.1.0 255.255.255.0 192.168.2.254 6
route-delay 5
verb 3
nice 1
secret /etc/openvpn/secret.key
comp-lzo
passtos
Commentary
The examples here have the openvpn service running with a nice priority of 1; if you do not desire this, remove the entire line that reads nice 1
to have it run like any other program. Compression is enabled via comp-lzo
on both ends, and passtos
allows for TOS packet bits to survive across the VPN. Both of these can also be disabled if you like. Some will notice that the route cost of 6 seems a bit high, which is true, it can be much lower (4-5 depending on the setup) but 6 provides enough "reach" for subnets and additional routing.
And lastly, as I'm posting this at 1:31am, I'm sure that I forgot something or marked something incorrectly, so please feel free to go over the settings and double-check them.