Thursday, March 25, 2010

How to set up linux as a ROUTER

Setting up Linux machine as a ROUTER
STEP 1:

Consider 2 interfaces: eth0 and eth1
eth0 //connecting to internet //Static IP assigned by ISP
eth1 //connexcting to LAN //Assigned Private ip 192.168.XXX.XXX
STEP 2:
Turn on ip forwarding
Edit /etc/sysctl.conf
Add the following
net.ipv4.ip_forward = 1
STEP 3:
Restart Network services by the following
#service network restart
STEP 4:
Set up IP forwarding and Masqerading by the following:
#iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
#iptables --append FORWARD --in-interface eth1 -j ACCEPT

STEP 4:
Assign the ipaddress of eth1 as the default gateway for the clients

No comments: