Centos/Redhat/Debain Internet Connection Sharing

Network Setup :
eth0 = 192.168.2.1 [ Isp router]
eth1 = 10.0.0.2 [ Internal network]

Check if IPv4 forwarding is ON or OFF :
cat /proc/sys/net/ipv4/ip_forward
if result = 0 then will have to On it by this command :

echo “1” > /proc/sys/net/ipv4/ip_forward

Now have to Enable IP masquerading by adding rules in iptables

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
[ Now all internet request will go via eth0]

If internal computers are unable to ping by domain name, then have to add bellow rule to allow all UDP [53] request to go to router(For Centos and Redhat)
-A RH-Firewall-1-INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp –dport 53 -j ACCEPT

Or
-A RH-Firewall-1-INPUT -p udp -m state –state NEW -m udp –dport 53 -j ACCEPT

Leave a Reply

*