How can I set my linux box as a router to forward ip packets?

Posted by UniMouS on Ask Ubuntu See other posts from Ask Ubuntu or by UniMouS
Published on 2012-12-10T02:36:14Z Indexed on 2012/12/10 5:19 UTC
Read the original article Hit count: 276

Filed under:
|

I am doing a network experiment about ip packet forwarding, but I don't know why it does work.

I have a linux machine with two network interfaces, eth0 and eth1 both with static IP address (eth0: 192.168.100.1, eth1: 192.168.101.2).

My goal is simple, I just want to forward ip packets from eth1 with destination in subnet 192.168.100.0/24 to eth0, and forward ip packets from eth0 with destination in subnet 192.168.101.0/24 to eth1.

I turned on ip forwarding with:

sysctl -w net.ipv4.ip_forward=1

my routing table is like this:

# route -n
Kernel IP routing table
Destination     Gateway     Genmask        Flags Metric Ref   Use  Iface
192.168.100.0   0.0.0.0     255.255.255.0  U     0      0       0  eth0
192.168.101.0   0.0.0.0     255.255.255.0  U     0      0       0  eth1

But, when I try to ping from 192.168.100.25 to 192.168.101.47, it does not work.

© Ask Ubuntu or respective owner

Related posts about route

Related posts about ip-forward