Fix
Can reach the local network but not other subnets
The machine has no default route, or the wrong prefix on its address, so packets for other networks never go to the router. Check ip route and the prefix.
Likely causes
- No default route (
default via <router>missing fromip route). - A prefix too short, such as
/16on a/24network: the machine thinks far addresses are on its own wire and asks for them with ARP. - A default route via an address nobody answers for.
Diagnose
Run these in order. The output is what each printed on a lab's real Linux machines.
-
leo:~# ip route - Only the local network,
10.0.1.0/24. Nodefaultline: nothing says where other networks are.10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.10
-
till:~# ping -c 1 -W 2 10.0.1.70 -
Network unreachablewith no packet sent: the address is outside the machine's own block, and no route covers it.ping: connect: Network unreachable
-
till:~# ifconfig eth0 - Read the mask.
255.255.255.192is/26: only.0to.63count as neighbors, and everything else goes through a router.eth0 Link encap:Ethernet HWaddr 1A:74:03:72:3B:A9 inet addr:10.0.1.10 Bcast:10.0.1.63 Mask:255.255.255.192 …
Fix
-
leo:~# ip route add default via 10.0.1.2 - Add the default route through the router.
leo:~# ip route default via 10.0.1.2 dev eth0 10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.10
-
leo:~# ping -c 1 10.0.2.10 - The far network answers, and
ttl=63shows the ping crossing one router.PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data. 64 bytes from 10.0.2.10: icmp_seq=1 ttl=63 time=0.103 ms --- 10.0.2.10 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.103/0.103/0.103/0.000 ms
-
ip addr add 10.0.1.10/24 dev eth0 - For a wrong prefix: add the address with the right prefix first.
-
ip addr del 10.0.1.10/16 dev eth0 - Then delete the one with the wrong prefix. In this order the machine keeps its default route.
-
till:~# curl -s http://10.0.2.80/ - The page on the other network opens, through the router.
Flour supplier: 25 kg bags in stock
Break it and fix it yourself
Each lab is a small network of real Linux machines in your browser, where this fault happens.
- Linux networking: bring a blank machine online by hand : its challenge "Noah answers, Zoe doesn't" set the fault for you to find and fix.
- Subnet masks: why a machine on the same switch is out of reach : its challenge "The supplier's page will not open" set the fault for you to find and fix.