![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIhHscMjBcUlIWKEYmN_-MYfZE01lpgxvgZIoy9ouVFM2r1HHoRFFSLuo3Vf-ZRlu3_oZtD9M26uS_cPN-xDU6SreHWy51iv7nAubr12L-oXV8S4Jf8eJbtmsWx3hPKQSA1pF9yrJcRdDr/s400/NAT.jpg)
Network Diagram:
IP address of NIC :
Eth1: [WAN] IP: 120.50.31.188 SM: 255.255.255.192 GW: 120.50.31.129 | Eth0: [LAN] IP: 192.168.100.1 SM: 255.255.255.0 |
Setup IP address:
#vi /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none ONBOOT=yes NETMASK=255.255.255.192 IPADDR=120.50.31.188 GATEWAY=120.50.31.129 TYPE=Ethernet
|
#vi /etc/sysconfig/network-scripts/ifcfg-eth1 DEVICE=eth0 BOOTPROTO=none ONBOOT=yes NETMASK=255.255.255.0 IPADDR=192.168.100.1 TYPE=Ethernet
|
And /etc/sysconfig/network will show:
NETWORKING=yes
HOSTNAME=Rubel
Setup DNS address:
nameserver 116.212.104.81
nameserver 116.212.104.82
Enable IP Forwarding:
#vi /etc/sysctl.conf
net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1
Flush rules:
#iptables –F
#iptables –t nat –F
NAT enable:
#iptables –t nat –A POSTROUTING –o eth1 –j MASQUERADE
#iptables –A FORWARD –i eth0 –j ACCEPT
edit the file etc/sysconfig/iptables-config
IPTABLES_MODULES_UNLOAD, IPTABLES_SAVE_ON_STOP, and IPTABLES_SAVE_ON_RESTART all set to “yes”
Save the Rules to /etc/sysconfig/iptables
#iptables-save
Restart iptables:
#service iptables restart
Restart Network:
#service network restart
Now Setup ip configuration on Client PC and ping the gateway 192.168.100.1 and ping www.google.com.