A simple keep-alive script for OpenVPN

echo 1 > /proc/sys/net/ipv4/ip_forward #Enable NAT
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE #Set up DNAT 
iptables -A FORWARD -i eth1 -o tap0 -m state --state RELATED,ESTABLISHED,NEW -j ACCEPT #Enable connections from the private subnet S1 out
iptables -A FORWARD -i tap0 -o eth1 -j ACCEPT #Enable connections from the tunnel to the the private subnet, i.e. from S2 to S1
#Bring up the tunnel: 
ifconfig tap0 up 

#Configure the tunnel as you like: 
ifconfig tap0 netmask #Adjust to taste; the scanner uses 172.16.0.x internally so I chose this on a whim