Same subnet or gateway
On this page
Before sending anything, laptop chooses whether to reach a neighbor directly or hand the message to router. It makes that choice using its own settings. The destination does not vote on the first decision.
Before you start
Section titled “Before you start”Finish Practice: Understanding IPv4 Addresses and Subnet ranges. Start with the lab up, modes off, no fault, at the VM prompt. This lesson changes one setting, then restores it.
Make the local decision
Section titled “Make the local decision”- Apply the machine’s own prefix to its own address to find its network.
- Apply that same prefix to the destination. Do not borrow the destination’s prefix.
- Matching network parts mean local: try directly on the connected network. Different parts mean use router through the default route in this lab.
- Repeat from the other machine’s view for a reply. It uses its own setting.
Laptop’s /24 puts phone in 10.77.10.0/24, while web falls outside it. ip route get asks the machine which route it would use for a destination, without sending anything. Repeat these reads.
learner@rootvolt:~$ netlab shell laptop -- ip route get 10.77.10.11[sudo] password for learner: 10.77.10.11 dev eth0 src 10.77.10.10 uid 1001
cache learner@rootvolt:~$ netlab shell laptop -- ip route get 10.77.20.8010.77.20.80 via 10.77.10.1 dev eth0 src 10.77.10.10 uid 1001
cache learner@rootvolt:~$ Steps (9)
- Type
netlab shell laptop -- ip route get 10.77.10.11 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
10.77.10.11 dev eth0 src 10.77.10.10 uid 1001 cache - Type
netlab shell laptop -- ip route get 10.77.20.80 - Press Enter
- Output:
10.77.20.80 via 10.77.10.1 dev eth0 src 10.77.10.10 uid 1001 cache
Phone’s line has dev eth0 without via; web’s has via 10.77.10.1. You can ignore uid … and cache here. Web uses its own /24: laptop is outside 10.77.20.0/24, so web sends toward its gateway, 10.77.20.1.
Give the machines different views
Section titled “Give the machines different views”netlab break <fault> applies one named fault from the VM terminal. netlab fix removes it, as netlab reset would. The named fault mask-mismatch gives laptop 10.77.10.10/16; nothing else changes.
The figure shows the local ranges each machine will use under that fault. Laptop includes both home and site addresses; web still includes only its site subnet.
Predict: with the fault applied, can laptop and web still reach each other? In both directions? Write each machine’s decision before testing.
learner@rootvolt:~$ netlab break mask-mismatch[sudo] password for learner: Fault mask-mismatch applied.learner@rootvolt:~$ netlab statusLab is up. Modes on: none. Fault: mask-mismatch.
MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START
laptop home 10.77.10.10/16 10.77.10.1 changed
phone home 10.77.10.11/24 10.77.10.1 same
router home, site 10.77.10.1/24 10.77.20.1/24 - same
web site 10.77.20.80/24 10.77.20.1 same
Changed since the start:
laptop: eth0 address 10.77.10.10/16 (start: 10.77.10.10/24)
Switch sw-home (home): laptop, phone, router
Switch sw-site (site): router, web
Services: web http 80, web https 443, web http 8080, web ssh 22learner@rootvolt:~$ Steps (9)
- Type
netlab break mask-mismatch - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Fault mask-mismatch applied. - Type
netlab status - Press Enter
- Output:
Lab is up. Modes on: none. Fault: mask-mismatch. MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START laptop home 10.77.10.10/16 10.77.10.1 changed phone home 10.77.10.11/24 10.77.10.1 same router home, site 10.77.10.1/24 10.77.20.1/24 - same web site 10.77.20.80/24 10.77.20.1 same Changed since the start: laptop: eth0 address 10.77.10.10/16 (start: 10.77.10.10/24) Switch sw-home (home): laptop, phone, router Switch sw-site (site): router, web Services: web http 80, web https 443, web http 8080, web ssh 22
learner@rootvolt:~$ netlab shell laptop -- ip route get 10.77.20.80[sudo] password for learner: 10.77.20.80 dev eth0 src 10.77.10.10 uid 1001
cache learner@rootvolt:~$ netlab shell web -- ip route get 10.77.10.1010.77.10.10 via 10.77.20.1 dev eth0 src 10.77.20.80 uid 1001
cache learner@rootvolt:~$ Steps (9)
- Type
netlab shell laptop -- ip route get 10.77.20.80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
10.77.20.80 dev eth0 src 10.77.10.10 uid 1001 cache - Type
netlab shell web -- ip route get 10.77.10.10 - Press Enter
- Output:
10.77.10.10 via 10.77.20.1 dev eth0 src 10.77.20.80 uid 1001 cache
Run the three ping commands next. As before, -c 2 limits each attempt to two requests.
learner@rootvolt:~$ netlab shell laptop -- ping -c 2 10.77.10.11[sudo] password for learner: PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data.
64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.202 ms
64 bytes from 10.77.10.11: icmp_seq=2 ttl=64 time=0.100 ms
--- 10.77.10.11 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.100/0.151/0.202/0.051 mslearner@rootvolt:~$ netlab shell laptop -- ping -c 2 10.77.20.80PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data.
From 10.77.10.10 icmp_seq=1 Destination Host Unreachable
From 10.77.10.10 icmp_seq=2 Destination Host Unreachable
--- 10.77.20.80 ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1002ms
pipe 2learner@rootvolt:~$ netlab shell web -- ping -c 2 10.77.10.10PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data.
--- 10.77.10.10 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1025mslearner@rootvolt:~$ Steps (12)
- Type
netlab shell laptop -- ping -c 2 10.77.10.11 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
PING 10.77.10.11 (10.77.10.11) 56(84) bytes of data. 64 bytes from 10.77.10.11: icmp_seq=1 ttl=64 time=0.202 ms 64 bytes from 10.77.10.11: icmp_seq=2 ttl=64 time=0.100 ms --- 10.77.10.11 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 0.100/0.151/0.202/0.051 ms - Type
netlab shell laptop -- ping -c 2 10.77.20.80 - Press Enter
- Output:
PING 10.77.20.80 (10.77.20.80) 56(84) bytes of data. From 10.77.10.10 icmp_seq=1 Destination Host Unreachable From 10.77.10.10 icmp_seq=2 Destination Host Unreachable --- 10.77.20.80 ping statistics --- 2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1002ms pipe 2 - Type
netlab shell web -- ping -c 2 10.77.10.10 - Press Enter
- Output:
PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data. --- 10.77.10.10 ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 1025ms
For your own view of the incoming request, repeat the next two replays together. In terminal 1, enter laptop and start the listener. The filter 'arp or icmp' includes address questions as well as ping traffic. Wait for listening on eth0. In terminal 2, enter web with netlab shell web, then run its replay. Return to terminal 1, press Ctrl+C, and exit both machine shells.
learner@rootvolt:~$ netlab shell laptop[sudo] password for learner: learner@laptop:~$ sudo tcpdump -i eth0 -n 'arp or icmp'[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes19:56:44.973819 ARP, Request who-has 10.77.10.10 tell 10.77.10.1, length 28
19:56:44.973823 ARP, Reply 10.77.10.10 is-at 02:77:10:00:00:10, length 28
19:56:44.973826 IP 10.77.20.80 > 10.77.10.10: ICMP echo request, id 180, seq 1, length 64
19:56:44.973847 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28
19:56:46.003011 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28
19:56:47.026964 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28^C6 packets captured
6 packets received by filter
0 packets dropped by kernellearner@laptop:~$ exitlogoutlearner@rootvolt:~$ Steps (18)
- Type
netlab shell laptop - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Type
sudo tcpdump -i eth0 -n 'arp or icmp' - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 on web finished its ping to laptop. Return to terminal 1 and press Ctrl+C to stop listening.
- Output:
19:56:44.973819 ARP, Request who-has 10.77.10.10 tell 10.77.10.1, length 28 19:56:44.973823 ARP, Reply 10.77.10.10 is-at 02:77:10:00:00:10, length 28 19:56:44.973826 IP 10.77.20.80 > 10.77.10.10: ICMP echo request, id 180, seq 1, length 64 19:56:44.973847 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28 19:56:46.003011 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28 19:56:47.026964 ARP, Request who-has 10.77.20.80 tell 10.77.10.10, length 28 - Press Ctrl + C
- Output:
6 packets captured 6 packets received by filter 0 packets dropped by kernel - Type
exit - Press Enter
- Output:
logout
learner@web:~$ ping -c 1 10.77.10.10PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data.
--- 10.77.10.10 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0mslearner@web:~$ Steps (3)
- Type
ping -c 1 10.77.10.10 - Press Enter
- Output:
PING 10.77.10.10 (10.77.10.10) 56(84) bytes of data. --- 10.77.10.10 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms
Check your answer
Laptop reaches phone: 2 received. Laptop to web reports Destination Host Unreachable, with 0 received, +2 errors. Web to laptop has 0 received, 100% packet loss.
Laptop treats web as local and asks the home network who has 10.77.20.80; nobody answers. Web treats laptop as remote and sends through router. The listener shows router first asking the home network for laptop’s hardware address, then laptop answering. That question is for laptop’s own address, so the fault does not stop it.
Web’s echo request then arrives at laptop. Laptop asks who has web’s address on the home network three times, with no echo reply. Its reply cannot complete the return path because its own prefix again says web is local. The listener shows the request arrived, even though ping on web received no answer. Reaching Another Device explains these address requests.
Mistakes to recognize
Section titled “Mistakes to recognize”“Both ends always agree.” The fault’s route reads show different decisions. Each machine uses its own prefix for its own sending.
“The router decides what is local.” The Destination Host Unreachable lines come From 10.77.10.10, laptop itself. Laptop gave up while asking for web on the home network, so nothing for web was handed to router.
Good to know
Section titled “Good to know”A selected route is evidence of intent, not successful delivery. Compare settings, the chosen route and actual traffic. Times, identifiers, sequence numbers and interface indexes may differ from the replay.
Try it yourself
Section titled “Try it yourself”For each pair, write both machines’ local-or-router decisions: A 192.0.2.10/24 and 192.0.2.130/25; B 198.51.100.70/26 and 198.51.100.90/27; C 172.16.1.10/16 and 172.16.2.20/24; D 10.1.1.10/24 and 10.1.2.20/16. Then run the fix replay, confirm laptop is same, and compare its restored route to web with the starting read.
learner@rootvolt:~$ netlab fix[sudo] password for learner: Fault mask-mismatch removed.learner@rootvolt:~$ netlab statusLab is up. Modes on: none. Fault: none.
MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START
laptop home 10.77.10.10/24 10.77.10.1 same
phone home 10.77.10.11/24 10.77.10.1 same
router home, site 10.77.10.1/24 10.77.20.1/24 - same
web site 10.77.20.80/24 10.77.20.1 same
Switch sw-home (home): laptop, phone, router
Switch sw-site (site): router, web
Services: web http 80, web https 443, web http 8080, web ssh 22learner@rootvolt:~$ netlab shell laptop -- ip route get 10.77.20.8010.77.20.80 via 10.77.10.1 dev eth0 src 10.77.10.10 uid 1001
cache learner@rootvolt:~$ Steps (12)
- Type
netlab fix - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Fault mask-mismatch removed. - Type
netlab status - Press Enter
- Output:
Lab is up. Modes on: none. Fault: none. MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START laptop home 10.77.10.10/24 10.77.10.1 same phone home 10.77.10.11/24 10.77.10.1 same router home, site 10.77.10.1/24 10.77.20.1/24 - same web site 10.77.20.80/24 10.77.20.1 same Switch sw-home (home): laptop, phone, router Switch sw-site (site): router, web Services: web http 80, web https 443, web http 8080, web ssh 22 - Type
netlab shell laptop -- ip route get 10.77.20.80 - Press Enter
- Output:
10.77.20.80 via 10.77.10.1 dev eth0 src 10.77.10.10 uid 1001 cache
Solution
In A and C the first machine says local, the second router. In B both say local: both addresses fall in 64?95 under /27 and 64?127 under /26. In D the first says router, the second local. Apply each side’s prefix to both addresses. After repair every machine is same; laptop again selects via 10.77.10.1 for web.
- Each machine decides with its own prefix.
- A working request path does not guarantee a working reply path.
- Remove the fault before continuing.
Next, Practice: Subnetting Foundations checks the method on new cases.