Pages

Tuesday, June 5, 2012

Linux Network Address Translation (NAT) Service

Variables
    iif: your intranet interface
    iip: your intranet IP
    wif: your internet (WAN) interface
    wip: your wan internet (WAN) IP
    inm: your intranet netmask


Enable Forwarding
    echo 1 > /proc/sys/net/ipv4/ip_forward

Enable IP Forwarding
  1.      iptables -I FORWARD -i $wif -o $iif -j ACCEPT
  2.      iptables -I FORWARD -i $iif -o $wif -j ACCEPT
  3.      iptables -t nat -A POSTROUTING -s $iip/$inm -o $wif -j MASQUERADE
               OR 
     iptables -t nat -I POSTROUTING -s $iip/$inm -j SNAT --to $wip

No comments:

Post a Comment