Configure Nat Routing Between Two Network Interfaces

By | August 24, 2009

Configure Nat Routing Between Two Network Interfaces

Network Address Translation (Nat) help to route the request through the gateway. It will help the system administrator to control the traffic over the network and monitor the users usage.

Nat is done using two Ethernet interfaces and basically the public address is accessible by the internal users, but the public people wont able to access the internal network with out the help of system administrator.

This help to prevent the access to internal network with our administrator permission and increase the security.

This is done with the help of iptables and ip forwarding on kernel parameter.

1. Edit,

#vi /etc/sysctl.conf

change the parameter,

net.ipv4.ip_forward = 1

and restart the network. The value can see on runing the command

#sysctl -p

2. The iptable command used to make it done is,

#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

where eth0 is the external network.It may vary depend on the interface naming.

command will configure nat between public and internal interfaces.

Save the iptables rule using the command,

#iptables save

Configure Apf with Nat

Apf can able to configure to make the nat working. We need to edit the post routing rule on apf configuration file.

# vi /etc/apf/postroute.rules

and add the same line

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

save and exit and reload apf

#apf -r 

Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More
Category: Linux

About Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More