Ip route
I keep running into situations where I'm having some sort of home network trouble so I will bring down my network interface and then bring it up again and afterward my routing table seems screwed up.
# ping www.noah.org connect: Network is unreachable # ping 4.2.2.2 connect: Network is unreachable
Things look OK from the LAN side:
# cat /etc/resolv.conf nameserver 4.2.2.2 nameserver 192.168.1.1 # ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:16:cb:aa:37:2a inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::216:cbff:feaa:352a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:218524 errors:0 dropped:0 overruns:0 frame:0 TX packets:162058 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:186251217 (186.2 MB) TX bytes:26169040 (26.1 MB) Interrupt:16 # ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.801 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.760 ms ^C # ping 192.168.1.105 PING 192.168.1.105 (192.168.1.105) 56(84) bytes of data. 64 bytes from 192.168.1.105: icmp_seq=1 ttl=64 time=7.02 ms 64 bytes from 192.168.1.105: icmp_seq=2 ttl=64 time=0.234 ms ^C # ping 192.168.1.200 PING 192.168.1.200 (192.168.1.200) 56(84) bytes of data. 64 bytes from 192.168.1.200: icmp_seq=1 ttl=64 time=0.048 ms 64 bytes from 192.168.1.200: icmp_seq=2 ttl=64 time=0.049 ms ^C
I look at the routing... This doesn't look good:
# ip route 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.200
So I run `dhclient eth0` to force my machine to talk to the gateway again.
# dhclient eth0 Internet Systems Consortium DHCP Client V3.1.1 Copyright 2004-2008 Internet Systems Consortium. All rights reserved. For info, please visit http://www.isc.org/sw/dhcp/ Listening on LPF/eth0/00:16:cb:aa:37:2a Sending on LPF/eth0/00:16:cb:aa:37:2a Sending on Socket/fallback DHCPREQUEST of 192.168.1.200 on eth0 to 255.255.255.255 port 67 DHCPACK of 192.168.1.200 from 192.168.1.1 * Reloading /etc/samba/smb.conf smbd only ...done. bound to 192.168.1.200 -- renewal in 880348675 seconds.
OK, good. It gets a response and the DHCP acknowledges use of the same IP. Check ip route again and it's fixed:
# ip route show 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.200 default via 192.168.1.1 dev eth0
It can see the world again:
# ping 4.2.2.2 PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data. 64 bytes from 4.2.2.2: icmp_seq=1 ttl=54 time=18.5 ms 64 bytes from 4.2.2.2: icmp_seq=2 ttl=54 time=17.0 ms ^C # ping www.kernel.org PING pub.us.kernel.org (204.152.191.37) 56(84) bytes of data. 64 bytes from pub2.kernel.org (204.152.191.37): icmp_seq=1 ttl=56 time=18.4 ms 64 bytes from pub2.kernel.org (204.152.191.37): icmp_seq=2 ttl=56 time=37.2 ms ^C
I can sort of see how it can get into this situation, but it's always bugged me that it doesn't just fix itself or fix itself faster.
Did the non-local route get put in the unreachable table? Unfortunately I didn't check this last time before I ran dhcp... I can manually add a single addresses to the unreachable route:
# ip route add unreachable 192.168.1.13 # ip route list type unreachable 192.168.1.13 # ping 192.168.1.13 connect: Network is unreachable # ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.877 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.765 ms ^C