Centos NAT with iptables

To manage NAT properly first thing we need to do is to allow IP FORWARDING
so we will edit following file

nano /etc/sysctl.conf

find the following line

net.ipv4.ip_forward

and change that to

net.ipv4.ip_forward = 1

once done, please issue following iptables commands

# /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# /sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
# /sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
# /sbin/iptables save

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.