Skip to content

Same subnet or gateway

Module
Subnetting Foundations
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, tcpdump 4.99.4
Prerequisites
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.

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.

  1. Apply the machine’s own prefix to its own address to find its network.
  2. Apply that same prefix to the destination. Do not borrow the destination’s prefix.
  3. Matching network parts mean local: try directly on the connected network. Different parts mean use router through the default route in this lab.
  4. 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.

Compare local and gateway routes on laptop
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Compare laptop's selected route for phone with its route for web.
Steps (9)
  1. Type netlab shell laptop -- ip route get 10.77.10.11
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: 10.77.10.11 dev eth0 src 10.77.10.10 uid 1001 cache
  7. Type netlab shell laptop -- ip route get 10.77.20.80
  8. Press Enter
  9. 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.

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.

Different local views under the fault Laptop treats web as local under /16. Web treats laptop as remote under /24 and uses router. laptop: 10.77.10.10/16 local: 10.77.0.0 to 10.77.255.255 web 10.77.20.80: local: ask at home web: 10.77.20.80/24 local: 10.77.20.0 to 10.77.20.255 laptop 10.77.10.10: not local: use router
Different local views under the fault Laptop treats web as local under /16. Web treats laptop as remote under /24 and uses router. laptop: 10.77.10.10/16 local: 10.77.0.0 to 10.77.255.255 web 10.77.20.80: local: ask at home web: 10.77.20.80/24 local: 10.77.20.0 to 10.77.20.255 laptop 10.77.10.10: not local: use router
Different prefixes give laptop and web different views of the local range and the next step.

Predict: with the fault applied, can laptop and web still reach each other? In both directions? Write each machine’s decision before testing.

Apply the prefix fault and inspect the lab
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Apply the named fault and identify the changed setting in status.
Steps (9)
  1. Type netlab break mask-mismatch
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: Fault mask-mismatch applied.
  7. Type netlab status
  8. Press Enter
  9. 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
Compare each machine route under the fault
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Read both machines' chosen routes while the fault is active.
Steps (9)
  1. Type netlab shell laptop -- ip route get 10.77.20.80
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: 10.77.20.80 dev eth0 src 10.77.10.10 uid 1001 cache
  7. Type netlab shell web -- ip route get 10.77.10.10
  8. Press Enter
  9. 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.

Test local and remote reachability under the fault
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Test phone and both directions of the laptop and web exchange.
Steps (12)
  1. Type netlab shell laptop -- ping -c 2 10.77.10.11
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. 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
  7. Type netlab shell laptop -- ping -c 2 10.77.20.80
  8. Press Enter
  9. 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
  10. Type netlab shell web -- ping -c 2 10.77.10.10
  11. Press Enter
  12. 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.

Listen on laptop in terminal 1 under the fault
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Keep the listener running on laptop while terminal 2 sends its request.
Steps (18)
  1. Type netlab shell laptop
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Type sudo tcpdump -i eth0 -n 'arp or icmp'
  7. Press Enter
  8. Output: [sudo] password for learner:
  9. Type the password (the terminal shows nothing)
  10. Press Enter
  11. Output: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
  12. Terminal 2 on web finished its ping to laptop. Return to terminal 1 and press Ctrl+C to stop listening.
  13. 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
  14. Press Ctrl + C
  15. Output: 6 packets captured 6 packets received by filter 0 packets dropped by kernel
  16. Type exit
  17. Press Enter
  18. Output: logout
Ping laptop from terminal 2 on web
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Send one request from web while laptop listens.
Steps (3)
  1. Type ping -c 1 10.77.10.10
  2. Press Enter
  3. 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.

“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.

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.

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.

Remove the fault and check the restored route
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:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Restore the starting settings and verify the route through router returns.
Steps (12)
  1. Type netlab fix
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: Fault mask-mismatch removed.
  7. Type netlab status
  8. Press Enter
  9. 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
  10. Type netlab shell laptop -- ip route get 10.77.20.80
  11. Press Enter
  12. 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.