Work in progress.
There are a couple of good tutorials on how to set up your own OpenVPN server (e.g. here, here, or here). To route all traffic through VPN, you need to set up some iptables on the server, which is also well documented. This post is about a problem i encountered that was not described anywhere: on every reboot of your machine the iptables are reset.
To solve this, you want to save your iptables to a file and load them on the startup of the network interfaces.
Setup iptables as usual:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
Save your currently active rules to a file with
iptables-save > /etc/iptables-up.rules
We can load now our file with
iptables-restore when the network interfaces are started. This is done on
Notice, that you have to put it right after the interface you want to tunnel the traffic through (not just at the end of the file)
iface eth0 inet dhcp post-up /sbin/iptables-restore < /etc/iptables-up.rules