Forwarding traffic to Internet GW
by sniper8752 from LinuxQuestions.org on (#51Q9E)
I have a server at 192.168.2.1, and my main server (GW to internet) internal IP at 192.168.1.1. In between is my laptop where I interact with both networks.
I did the following on 2.1:
Code:route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.1.2
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.2 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0Where my laptop is 192.168.1.2.
Here is what my laptop's routing table looks like:
Code:0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1I would like to be able to get out to the internet from the 2.1 network.


I did the following on 2.1:
Code:route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.1.2
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.2 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0Where my laptop is 192.168.1.2.
Here is what my laptop's routing table looks like:
Code:0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1I would like to be able to get out to the internet from the 2.1 network.