Using iptables to route OpenVPN traffic
avatar

To have your vpn traffic be able to reach the internet you just need to add the following iptable rules:

iptables -A FORWARD -i tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o eth0 -m state –state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o tun0 -m state –state RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE

This would take the tunnel adapter of tun0 and route the traffic through eth0 for the vpn subnet of 192.168.0.0.

This entry was posted in Arch, CentOS, Fedora, Guides, Linux, Networking and tagged , . Bookmark the permalink.

Leave a Reply