Saturday, November 15, 2008

Enable NAT through tun0 (VPN) by iptables

Assuming the interface WAN is used to connect to internet and interface VPN is created by VPN client
WAN=eth1
VPN=tun0
LAN=eth0
#Enable packet forwarding to function as a router
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables --append FORWARD --in-interface $LAN -j ACCEPT
#Enable MASQUERADE to function as a NAT router
iptables --table nat --append POSTROUTING --out-interface $WAN -j MASQUERADE
iptables --table nat --append POSTROUTING --out-interface $VPN -j MASQUERADE

2 comments:

alex smith said...

I would not trust free vpn services, sounds enticing, surely.
But I believe any free service disguises some sort of undercurrent.
No matter if it is provided by an unknown entity or by such a trusted
corporation

mikelo said...

are u saying ff disguises some sort of undercurrent for example? just because it's free it does not mean there's no quality involved. Look at windows ME, it was not free but I don't see ant quality there?