Page 1 of 1

Setting Up NAT Network Address Translation Rate Topic: -----

#1 Nova Dragoon  Icon User is offline

  • The Innocent Shall Suffer, Big Time
  • member icon

Reputation: 36
  • View blog
  • Posts: 6,169
  • Joined: 16-August 01

Posted 09 August 2006 - 09:27 AM

For this tutorial, we are using a modern linux os with IPTables, on a computer with two ethernet cards.
All commands run should be done with root privs

[The Phyical Setup]
Connect to the first ethernet card (eth0) the line that gets this computer connected to the internet.
Connect to the second ethernet card (eth1) to a hub/switch
Connect all clients to be NAT'ed to the hub/switch.

Logical Setup
The NAT'ed network will be
And the NAT'ing computer will be on eth1

On the NAT'ing computer:
ifconfig eth1 netmask

Enabling IP Forwarding in the Kernel
Check and see if your computer is already doing forwarding with:
sysctl net.ipv4.ip_forward
If what it returns is 0, its off
if what it return is 1 then its already enabled.

Turn it on now by running:
sysctl -w net.ipv4.ip_forward=1

and to enable it at boot, add this line to your /etc/sysctl.conf:
net.ipv4.ip_forward = 1

Now restart your networking:
/etc/init.d/networking restart

Forwarding Rules in IPTables
iptables -A FORWARD -i eth1 -o eth0 -s -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

Finally setup you clients to have a address, with the gateway as

Is This A Good Question/Topic? 0
  • +

Page 1 of 1