May 4, 2010

Simple NAT for Internet sharing

You need a Linux machine (or virtual machine running Linux, or Colinux) to do this:


#enable routing
echo 1 > /proc/sys/net/ipv4/ip_forward

#flush iptable
iptables -t nat -F

#enable DNAT (also known as IP masquerading)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

#enable port forwarding
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 2401 -j DNAT --to 192.168.16.66:2401
iptables -t nat -A PREROUTING -i eth1 -p ALL --dport 82:88 -j DNAT --to 192.168.16.66:5000:5006

No comments:

Post a Comment