task 2.2 · chapter 2 of 3: your network · 30 min
One wrong number
objective
Find out why broken-pc can reach the printer but not web, using only ip addr, ip route, ping and ip neigh. Then fix its prefix and give it a default gateway.
| Lessons used | 3.2 CIDR, 2.1 the router and the gateway |
|---|---|
| Log in | click broken-pc on the Topology tab (and laptop to compare) |
| Nothing to write | the checker looks at broken-pc itself, and pings from it |
new to this? step by stepbeginner
- Click broken-pc on the Topology tab. In the broken-pc tab:
ip addr show eth1,ip route,ping -c 3 192.168.2.10andip neigh. - Fix the prefix:
ip addr del 192.168.1.30/16 dev eth1, thenip addr add 192.168.1.30/24 dev eth1. - Challenge: web still doesn’t answer. Find out why, and fix it.
- Check task 2.2, under the guide.
more in meet the lab
When a computer can reach some things and not others
The story
Somebody set up broken-pc by hand, instead of letting DHCP do it. They typed its IP address right:
192.168.1.30. But they typed the prefix as /16 instead of /24, and they forgot the gateway
completely. Now its owner says: “I can print, but I can’t get to the website.”
That’s a real kind of fault, and it’s worth knowing well: a wrong prefix doesn’t break everything, which makes it harder to spot. You’ll find it the way an engineer would: look at what the computer believes, test, and compare with a computer that works.
What the prefix decides
From lesson 3.2: before sending anything, a host compares the destination’s network part with its own.
- Same network? Send it straight there: ARP for the destination’s MAC address (task 2.1).
- Different network? Send it to the default gateway.
The prefix decides where the network part ends, so it decides the answer. With /24, broken-pc’s network is
192.168.1.0/24: 192.168.1.0 to 192.168.1.255. With /16 it’s 192.168.0.0/16: everything from
192.168.0.0 to 192.168.255.255. That includes the printer, which is right, but it also includes web, at
192.168.2.10, which is wrong.
in one sentence The prefix decides which addresses a host thinks are on its own network, and so whether it ARPs for them or uses the gateway.
Two different error messages
ping tells you how it failed, and the two messages mean different things:
| Message | What the computer is telling you |
|---|---|
Destination Host Unreachable | I think that address is on my network, I asked with ARP, and nobody answered. |
Network is unreachable | I have no idea where that network is: no route for it, and no default gateway. |
in one sentence Host unreachable: it ARPed and got no answer. Network unreachable: it has no route at all.
What broken-pc believes
broken-pc:~# ip addr show eth1
...
inet 192.168.1.30/16 scope global eth1
broken-pc:~# ip route
192.168.0.0/16 dev eth1 proto kernel scope link src 192.168.1.30
Compare with the laptop’s ip route from task 1.2:
laptop:~# ip route
default via 192.168.1.1 dev eth1
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.50
| broken-pc | laptop | |
|---|---|---|
| its own network | 192.168.0.0/16: far too big | 192.168.1.0/24 |
default via | missing | 192.168.1.1, r1 |
The 192.168.0.0/16 dev eth1 line says: every address from 192.168.0.0 to 192.168.255.255 is right here
on eth1. So for web, broken-pc ARPs, and nobody on its network has 192.168.2.10:
broken-pc:~# ping -c 3 192.168.2.10
PING 192.168.2.10 (192.168.2.10) 56(84) bytes of data.
From 192.168.1.30 icmp_seq=1 Destination Host Unreachable
From 192.168.1.30 icmp_seq=2 Destination Host Unreachable
From 192.168.1.30 icmp_seq=3 Destination Host Unreachable
broken-pc:~# ip neigh
192.168.2.10 dev eth1 FAILED
FAILED: it asked who has 192.168.2.10? and nobody answered.
Find it, then fix the prefix
Log in to broken-pc: click broken-pc on the Topology tab. In the broken-pc tab, look at what it believes:
run in the broken-pc tabip addr show eth1 ip routeTest both directions of the complaint. The printer first, then web:
run in the broken-pc tabping -c 3 192.168.1.20 ping -c 3 192.168.2.10 ip neighThe printer answers. web gives
Destination Host Unreachable, and the neighbour table has192.168.2.10 ... FAILED. broken-pc thinks web is next door.Fix the prefix. An address and its prefix go together, so you remove the wrong one and add the right one:
run in the broken-pc tabip addr del 192.168.1.30/16 dev eth1 ip addr add 192.168.1.30/24 dev eth1 ip routeip routenow says192.168.1.0/24 dev eth1. Right size.Try web again:
run in the broken-pc tabping -c 3 192.168.2.10A different error now:
ping: connect: Network unreachable. That’s progress. broken-pc knows web isn’t on its network, so it doesn’t ARP for it any more. But it doesn’t know where else to send it either.(Changes you make with
iplast until the lab restarts. A real computer keeps its settings in a file, so they come back after a restart; here, Reset network in the top bar puts broken-pc back how it was.)
in one sentence ip addr del and ip addr add change an address and its prefix; ip route shows the effect straight away.
Get broken-pc to web
Make ping -c 3 192.168.2.10 work from broken-pc. The printer must still work too. Then click
Check task 2.2, under the guide.
hint
Network is unreachable means no route. Which line does the laptop’s ip route have that broken-pc’s
doesn’t? (Click laptop on the Topology tab to compare, in a tab of its own.)
hint
The command to add a route starts ip route add. A default route is written default via <gateway>.
show the solution
broken-pc:~# ip route add default via 192.168.1.1
broken-pc:~# ip route
default via 192.168.1.1 dev eth1
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.30
broken-pc:~# ping -c 3 192.168.2.10
64 bytes from 192.168.2.10: icmp_seq=1 ttl=62 time=0.749 ms
...
Now broken-pc’s ip route matches the laptop’s, apart from its own address. That’s what DHCP would have given
it in the first place: this is why most hosts use DHCP instead of being typed in by hand.
Look at ttl=62 in the answer. Every router a packet crosses takes 1 off its time to live. web sent its
answer with 64, and two routers later it’s 62. Task 3.1 uses that.
5 check: run it, then prove it
Check task 2.2 under the guide, in the lab app
when it's right, you'll see
╭─ task 2.2 · one wrong number
│ ✓ broken-pc's address is 192.168.1.30/24 (follow along): it's 192.168.1.30/24
│ ✓ broken-pc's default gateway is r1, 192.168.1.1 (challenge): it's 192.168.1.1
│ ✓ broken-pc reaches the printer, on its own network (challenge)
│ ✓ broken-pc reaches web, two routers away (challenge)
╰─ 4/4 checks passed verified