Configuration Firewall IPTables Linux Servers SysAdmin Tips & Tricks

IPTables – Route traffic from vpn tunnel

Written by bkarankar

Tun0 = VPN Tunnel

eth1 = local network

all the request coming from local network @eth1 will forward to tun0. so you do not need to have a site2site vpn, this 4 commands will make your linux as route/vpn gateway.

sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i eth1 -o tun0 -m state –state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i tun0 -o eth1 -j ACCEPT

About the author


Leave a Comment