iptables NAT typical Internet

As a general computer NAT is also a local area network gateway, assuming that the machine has two NIC eth0, eth1, eth0 connect to external networks, IP is 202.96.134.134; eth1 connect LAN, IP is 192.168.62.10

1. Turn on the kernel ip forwarding

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

2.? LAN users can access the internet do nat

#iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to?202.96.134.134

If the Internet IP is dynamic IP, use the following rules:

#iptables -t nat -A POSTROUTING -o eth0 -s 192.168.62.0/24 -j MASQUERADE

If it is through ADSL Internet access, and public IP is dynamic IP, use the following rules:

#iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.62.0/24 -j MASQUERADE

3. Make internet users can access the LAN web hosts do nat

#iptables -t nat -A PREROUTING -p tcp -d 202.96.134.134 --dport 80 -j DNAT --to-destination 192.168.62.10

Note: The client within the LAN will need to default gateway, the DNS to firewalls IP

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11130172.html
NAT