Monday, June 10, 2013

Configure Linux Machine as Router

Scenario:

          Consider your Linux Machine is having two NICs eth0 and eth1 connected to networks 10.0.0.0/8 and 172.18.61.0/16 respectively. You would like to enable routing between these two networks. For instance IP 10.0.0.3 (subnet mask 255.0.0.0) is assigned to eth0 and IP 172.18.61.15 (subnet mask 255.255.0.0) is assigned to eth1. Then here are the steps to configure your Linux machine as a router.

Steps:

1. #vim /etc/sysconfig/network-scripts/route-eth0

               10.0.0.0/8    via    10.0.0.3

 2. #vim /etc/sysconfig/network-scripts/route-eth1

               172.18.0.0/16    via    172.18.61.15

3. #service network restart

4. #iptables -t nat -I POSTROUTING -j MASQUERADE

5. #service iptables save

6. #service iptables restart

No comments:

Post a Comment