Simple NAT using IPtables

posted in: Networking | 0

It was needed to do NAT (Network Address Translation) in the network of INHERENT Universitas Pattimura (UNPATTI). In this case, it was decided to do NAT of one INHERENT’s IP which is 167.205.164.5. The purpose is to be able to connect several client computers assigned with class C private IP in 192.168.76.xxx through 167.205.164.5.

The machine used to handle this task is an IBM x3650 which also servesĀ  as a multipurpose server as web server and database server. The operating system installed is CentOS 5, and as far as it was tried, centOS is the only Linux distro that can be installed in this machine and nothing else of open source distro works.

The NAT application implemented is very straight forward, network schema is as shown in the picture below.

INHERENT NAT

It is needed to pass inbound and outbound trafics from/to eth0 167.205.164.5 from/to eth1 192.168.76.1 and to achieve this task, IPtables is used.

Here are the IPtables commands that were used to configure the NAT for 192.168.76.0/24 and 167.205.164.5

[inherent@hotumese ~]$/sbin/iptables -t nat -A POSTROUTING -o eth1 -s 192.168.76.0/24 -j SNAT –to-source 167.205.164.5

[inherent@hotumese ~]$/sbin/iptables-save > /etc/sysconfig/iptables