1
At first, my network config was like this:
$ ip a
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 3c:97:0e:bd:b1:68 brd ff:ff:ff:ff:ff:ff
inet 10.66.65.2/24 brd 10.66.65.255 scope global em1
valid_lft forever preferred_lft forever
inet6 fe80::3e97:eff:febd:b168/64 scope link
valid_lft forever preferred_lft forever
$ ip r
default via 10.66.65.254 dev em1 proto static
10.66.65.0/24 dev em1 proto kernel scope link src 10.66.65.2 metric 1
in this way, the network subnet mask is incorrect. I don't have the access to internet but I can ping gateway 10.66.65.254.
Then I flush the route table and ip address of em1 and restart nic. And I have a new route table and ip:
$ ip a s dev em1
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 3c:97:0e:bd:b1:68 brd ff:ff:ff:ff:ff:ff
inet 10.66.65.2/23 brd 10.66.65.255 scope global em1
valid_lft forever preferred_lft forever
inet6 fe80::3e97:eff:febd:b168/64 scope link
valid_lft forever preferred_lft forever
$ ip r
default via 10.66.65.254 dev em1 proto static
10.66.64.0/23 dev em1 proto kernel scope link src 10.66.65.2 metric 1
and I can access the internet now.
What I think have happened before I change restart the nics is like: the packet to the internet have a destination of say 172.1.1.1 and 10.66.65.2 as source, so it look up the route table and go out thought em1, then the gateway received the packet, but when the packet is going back to em1, the gateway cannot find an appropriate route entry for 10.66.65.2/24, so it dropped the packet, so I can't access the internet.
But I am wondering why I can ping the gateway, why is it able to send packet to me this time?
Thanks
It seems the question is incorrect, because it's quite normal that it is going to receive packet from the gateway since we are in the same subnet in it's option. – dspjm – 2014-01-07T07:11:21.123