Fixes

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

  1. No default route (default via <router> missing from ip route).
  2. A prefix too short, such as /16 on a /24 network: the machine thinks far addresses are on its own wire and asks for them with ARP.
  3. 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.

laptop:~# ip route
Only the local network, 10.0.1.0/24. No default line: nothing says where other networks are.
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.10 
alice:~# ping -c2 10.0.2.10
With a /16 address, Destination Host Unreachable comes from the machine's own address: it looked for 10.0.2.10 on its own wire.
PING 10.0.2.10 (10.0.2.10) 56(84) bytes of data.
From 10.0.1.10 icmp_seq=1 Destination Host Unreachable
From 10.0.1.10 icmp_seq=2 Destination Host Unreachable

--- 10.0.2.10 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1028ms
pipe 2
alice:~# ip route get 10.0.2.10
On a healthy machine, ip route get names the router: via 10.0.1.2.
10.0.2.10 via 10.0.1.2 dev eth0 src 10.0.1.10 uid 0 
    cache 

Fix

laptop:~# ip route add default via 10.0.1.2
Add the default route through the router.
laptop:~# ip route
default via 10.0.1.2 is now in the table.
default via 10.0.1.2 dev eth0 
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.10 
laptop:~# ping -c1 -W1 10.0.2.10
The far network answers.
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.154 ms

--- 10.0.2.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.154/0.154/0.154/0.000 ms
alice:~# ip addr del 10.0.1.10/16 dev eth0
For a wrong prefix: delete the address with the wrong prefix (the right one stays).
alice:~# ping -c1 -W2 10.0.2.10
The server answers again, through the 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.091 ms

--- 10.0.2.10 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.091/0.091/0.091/0.000 ms

Break it and fix it yourself

Each lab is a small network of real Linux machines in your browser, where this fault happens.

Open A bare machine: networking by hand

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Start this lab, free