Set up a NAT router on a Linux-based computer- Red Hat Enterprise 5 …!!!

0

Set up a NAT router on a Linux-based

Suppose you have 2 computers : Linux1  and Linux2.

Linux1 has two Network Cards- eth0 & eth1.  Linux1 is connected directly to the internet through eth0 & eth1 with Local LAN. we will use 192.168.1.100 for public network & 10.10.0.10 for private network on Linux1.

for eth0:

IPADDR= address:192.168.1.100

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

for eth1:

IPADDR= address:10.10.0.10

NETMASK=255.0.0.0.0

Now on Linux2:

We want to make linux2 have internet access through linux1.

we will set IP for linux2 from same subnet what we configured on eth1 on linux1

for eth0:

IPADDR= address:10.10.0.11

NETMASK=255.0.0.0.0

please check through ping command from linux2 to linux1 and make it sure you can get ping success to 10.10.0.10

ping 10.10.0.10

Now on Linux1 computer and type below commands:

[root@linux1 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@linux1 ~]#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
[root@linux1 ~]#iptables -A FORWARD -i eth1 -j ACCEPT

[root@linux1 ~]#service network restart

Copy the file /etc/resolv.conf from Linux1 to Linux2. We use this file to resolve DNS.

Now ping yahoo.com from linux2, it will be successful.

 

Thanks………………

Share.

About Author

Chakraborty Prijus

Former Asst. Manager (IT) - MGH Group MCA (Masters in Computer Application) From Sikkim Manipal University India. Have 5 years experience In IT field.

Leave A Reply

Powered by themekiller.com