Why is 192.168.1.0 needed in route table?

2

My home network is configured as follows:

Computer -- Route -- Internet

If I run route on my computer, I see

~ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0

My question is that since all packets matching 192.168.1.0 will be directed to 0.0.0.0, why is the first entry needed? Would removing the entry cause any problem?

Wei Shi

Posted 2011-10-16T23:23:33.117

Reputation: 735

Answers

4

The entry doesn't point to 0.0.0.0; rather, it points to the eth0 interface. Without it, the system wouldn't know which interface to use when sending packets to 192.168.1.1 and other computers in the same subnetwork.

Remember also that computers in 192.168.1.0 are not behind the gateway; they can be reached directly.

user1686

Posted 2011-10-16T23:23:33.117

Reputation: 283 655

But when I remove the first entry, I can still ping google.com. Why is this happening? – Wei Shi – 2011-10-19T01:07:52.167

@Usavich: Because the first entry doesn't match Google's address and wouldn't have been used anyway. It is only for communications with 192.168.1.*. – user1686 – 2011-10-19T09:25:01.430