IP routing · Introduction · Module 2
Longest prefix match and the default route: when routes overlap, or none fits
Show topologyHide topology
Interfaces and addresses · Et0/0 = Ethernet0/0. R2, R3 and R4 each also hold one more network: 10.2.1.0/24, 198.51.100.0/24 and 10.2.3.0/24.
- 10.1.1.0/24R1 Et0/0 10.1.1.1H1 eth0 10.1.1.10
- 10.0.12.0/24R1 Et0/1 10.0.12.1R2 Et0/0 10.0.12.2
- 10.0.14.0/24R1 Et0/2 10.0.14.1R4 Et0/0 10.0.14.4
- 203.0.113.0/24R1 Et0/3 203.0.113.2R3 Et0/0 203.0.113.1
Five device icons joined by four plain cables, in a cross with R1, the office router, at the center. Above it, R3, the provider router, holding 198.51.100.1/24, on a cable labeled 203.0.113.0/24. Left of it, R2, the HQ router, holding 10.2.1.2/24, on a cable labeled 10.0.12.0/24. Right of it, R4, the branch router, holding 10.2.3.4/24, on a cable labeled 10.0.14.0/24. Under it, H1, the office host, a laptop, on a cable labeled 10.1.1.0/24. The list under the drawing gives the interface and the address at each end of each cable.
What longest match is
Overlapping routes and the default
When two routes match
R1 now has a route, 10.2.0.0/16, to R2 for every address that starts 10.2, the branch address 10.2.3.4 too. So why does R1 send a packet for 10.2.3.4 to R4?
Because another of its routes, a longer one, covers that address as well: the branch route 10.2.3.0/24 to R4. A third route, 0.0.0.0/0, leads to the provider router R3.
| Route | Sends to | Covers |
|---|---|---|
| 10.2.0.0/16 | R2 (HQ) | every address that starts 10.2 |
| 10.2.3.0/24 | R4 (branch) | every address that starts 10.2.3 |
| 0.0.0.0/0 | R3 (provider) | every address |
You can test both routes against 10.2.3.4 yourself. A route matches when the destination’s first bits, as many as the prefix length, equal the route’s prefix. For 10.2.0.0/16 those are the first two numbers, 10.2, and for 10.2.3.0/24 the first three, 10.2.3, so both match.
Why the longer one? A longer prefix fixes more bits of the address, so it says more exactly where the destination is. Routers therefore follow longest prefix match, the rule that the router uses the matching route with the longest prefix.
So R1 uses 10.2.3.0/24 and sends the packet to R4. Routers on the internet forward on this longest-match basis too.
The /16 is the larger block, but that gives it no advantage. The rule compares prefix lengths, not how many addresses a route covers.
Each route covers a range of addresses, and here the ranges sit one inside the other (Figure 2.1). Each address takes the route of the innermost range that holds it.
Three rows, one per route, each with its prefix at the left and an outlined bar at the right. Top row: 0.0.0.0/0, every address, toward R3, the widest bar. Middle row: 10.2.0.0/16, the HQ block, toward R2, a shorter bar inside the first. Bottom row: 10.2.3.0/24, the branch, toward R4, the shortest bar, inside the second. Three vertical lines cross the bars, one per address. The line for 198.51.100.1 crosses only the top bar, with a dot on it: it uses the /0. The line for 10.2.1.2 crosses the top and middle bars, with a dot on the middle one: it uses the /16. The line for 10.2.3.4 crosses all three, with a highlighted dot on the bottom one: it uses the /24. A note says the drawing is not to scale.
Two routes with the same prefix, one typed in and one learned another way, tie on length; other rules then choose.
The default route
No route in R1’s table names most of the networks on the internet. What does R1 do with a packet for one of them?
R1 sends it by a route that matches any address, the default route 0.0.0.0/0. Its prefix length is 0, so no bit has to be equal and every address matches.
Any other route that matches is longer than 0, so under longest match it beats the default. The default route is used only when nothing longer matches. On R1 it sends those packets to the provider router R3.
A route that matches every address might seem to send all traffic to R3. It carries only what nothing longer matches, so a packet for the branch still goes to R4 by the /24.
R1’s table prints the default route’s next hop on its own line, ahead of the route lines, as the gateway of last resort, 203.0.113.1, R3’s address on their shared link.
What if there is no default route and nothing else matches? Then the router discards the packet. If another device sent the packet, the router must tell it that the address cannot be reached, though it may limit how often.
A host needs a way out of its own network too. Its default gateway is the router address it sends packets for other networks to, and H1’s is R1, 10.1.1.1. The computer you are reading this on most likely has one as well.
H1 sends R1 only the packets that leave its own network. A packet for an address in its own network, 10.1.1.0/24, goes straight to that device.
One packet from H1 to the internet uses both H1’s default gateway and R1’s default route (Figure 2.2).
The network: R1 at the center of a cross, R3 above it, R2 left of it, R4 right of it and H1 under it. A short arrow beside the cable from H1 points up toward R1, with the note “default gateway: R1, 10.1.1.1”. A highlighted short arrow left of the cable from R1 points up toward R3, with the note “default route 0.0.0.0/0” left of it. The cables to R2 and R4 have no arrow.
Key idea
When routes overlap, the longest matching prefix wins. The default route 0.0.0.0/0 matches every address but has the shortest prefix, so it wins only when nothing else matches; with no match at all, the packet is dropped.
How it works
R1 looks up three addresses
R1 sends one test packet to each of three addresses. Which route does each one take?
Two of them match more than one route, and each takes the longest one that matches (Figure 2.3). How can you see which way each packet left? With debug ip packet on, R1 logs each packet that starts or ends at R1, and show logging | include IP: prints those lines.
Step 1 of 6
R1 holds three typed-in routes that overlap: 10.2.0.0/16 to R2, 10.2.3.0/24 to R4 and 0.0.0.0/0 to R3.
Step 2 of 6
10.2.1.2 matches 10.2.0.0/16 and 0.0.0.0/0. The /16 is longer, so R1 sends the packet out of Ethernet0/1 to R2.
Next, 10.2.3.4. It matches all three routes. Which one does R1 use?
S 10.2.0.0/16 [1/0] via 10.0.12.2, Ethernet0/1.: It matches, but its prefix is shorter: 16 bits against 24. Covering more addresses is not what decides; the longest matching prefix is.S* 0.0.0.0/0 [1/0] via 203.0.113.1, Ethernet0/3.: With prefix length 0, the default is the shortest of the three matches and loses to both others.- The first matching line printed in the table.: R1 compares the prefix lengths of all the routes that match; where a line is printed plays no part.
S 10.2.3.0/24 [1/0] via 10.0.14.4, Ethernet0/2. (Correct): The /24 fixes 24 bits, more than the /16 or the /0, so it is the longest match. Its next hop is 10.0.14.4, R4, out of Ethernet0/2.
Step 3 of 6
10.2.3.4 matches all three routes. The /24 is the longest, so R1 sends the packet out of Ethernet0/2 to R4.
Step 4 of 6
198.51.100.1 matches only the default route. R1 sends the packet out of Ethernet0/3 to 203.0.113.1, its gateway of last resort.
Step 5 of 6
Without the default route, 198.51.100.1 matches nothing, so R1 drops the packet. R1’s debug line for it ends with unroutable.
Step 6 of 6
R1 uses the longest match, falls back on the default route only when nothing longer matches, and drops a packet that matches nothing.
A strip at the top holds two chips: the destination, and the routes that match. Under it, the network: R1 at the center, R3 above it, R2 left, R4 right and H1 under it. Step 1: the chips read “R1’s typed-in routes” and “/16 → R2 · /24 → R4 · /0 → R3”. Step 2: “to 10.2.1.2”, “matches /16 and /0, uses /16 → R2”, and a short arrow beside the cable to R2, pointing to R2, noted /16. Step 3: “to 10.2.3.4”, “matches /24, /16, /0, uses /24 → R4”, and a short arrow beside the cable to R4, pointing to R4, noted /24; the /16 arrow stays, in gray. Step 4: “to 198.51.100.1”, “matches /0 only, uses /0 → R3”, and a short arrow left of the cable to R3, pointing up to R3, noted /0; the /16 and /24 arrows stay, in gray. Step 5: “to 198.51.100.1, no /0 route”, “matches nothing, R1 drops it”, and a cross beside the cable to R3, left of it at R1’s end, just above R1, in place of the /0 arrow; the /16 and /24 arrows stay, in gray. In step 6 the three arrows keep their notes, and the chips read “three addresses” and “longest match wins; no match: drop”.
unroutable.R1 uses the longest match, falls back on the default route only when nothing longer matches, and drops a packet that matches nothing.Answer here to see step 3, or tap “Skip, show me”.
On R1, the lines debug ip packet printed for the three test packets:
A sent packet’s first line has the destination after d=, the interface in the parentheses after it and the next hop after nexthop=.
Lines appear as you step through.
R1#show logging | include IP:2IP: tableid=0, s=10.0.12.1 (local), d=10.2.1.2 (Ethernet0/1) nexthop=10.0.12.2, routed via FIB… 6 more lines (see Full output)3IP: tableid=0, s=10.0.14.1 (local), d=10.2.3.4 (Ethernet0/2) nexthop=10.0.14.4, routed via FIB… 6 more lines (see Full output)4IP: tableid=0, s=203.0.113.2 (local), d=198.51.100.1 (Ethernet0/3) nexthop=203.0.113.1, routed via FIB… 6 more lines (see Full output)
Full output · 21 lines
R1#show logging | include IP:IP: tableid=0, s=10.0.12.1 (local), d=10.2.1.2 (Ethernet0/1) nexthop=10.0.12.2, routed via FIBIP: s=10.0.12.1 (local), d=10.2.1.2 (Ethernet0/1), len 100, sendingIP: s=10.0.12.1 (local), d=10.2.1.2 (Ethernet0/1), len 100, sending full packetIP: s=10.2.1.2 (Ethernet0/1), d=10.0.12.1 (nil), len 100, input feature, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.2.1.2 (Ethernet0/1), d=10.0.12.1 (nil), len 100, rcvd 2IP: s=10.2.1.2 (Ethernet0/1), d=10.0.12.1 (nil), len 100, stop process pak for forus packetIP: tableid=0, s=10.2.1.2 (Ethernet0/1), d=10.0.12.1 (Ethernet0/1) nexthop=10.0.12.1, routed via RIBIP: tableid=0, s=10.0.14.1 (local), d=10.2.3.4 (Ethernet0/2) nexthop=10.0.14.4, routed via FIBIP: s=10.0.14.1 (local), d=10.2.3.4 (Ethernet0/2), len 100, sendingIP: s=10.0.14.1 (local), d=10.2.3.4 (Ethernet0/2), len 100, sending full packetIP: s=10.2.3.4 (Ethernet0/2), d=10.0.14.1 (nil), len 100, input feature, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.2.3.4 (Ethernet0/2), d=10.0.14.1 (nil), len 100, rcvd 2IP: s=10.2.3.4 (Ethernet0/2), d=10.0.14.1 (nil), len 100, stop process pak for forus packetIP: tableid=0, s=10.2.3.4 (Ethernet0/2), d=10.0.14.1 (Ethernet0/2) nexthop=10.0.14.1, routed via RIBIP: tableid=0, s=203.0.113.2 (local), d=198.51.100.1 (Ethernet0/3) nexthop=203.0.113.1, routed via FIBIP: s=203.0.113.2 (local), d=198.51.100.1 (Ethernet0/3), len 100, sendingIP: s=203.0.113.2 (local), d=198.51.100.1 (Ethernet0/3), len 100, sending full packetIP: s=198.51.100.1 (Ethernet0/3), d=203.0.113.2 (nil), len 100, input feature, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=198.51.100.1 (Ethernet0/3), d=203.0.113.2 (nil), len 100, rcvd 2IP: s=198.51.100.1 (Ethernet0/3), d=203.0.113.2 (nil), len 100, stop process pak for forus packetIP: tableid=0, s=198.51.100.1 (Ethernet0/3), d=203.0.113.2 (Ethernet0/3) nexthop=203.0.113.2, routed via RIB
Impact A debug adds work for the router. Keep it on for a few seconds only, then turn it off again.
By longest match, the packet for 10.2.1.2 left through Ethernet0/1 to next hop 10.0.12.2, the one for 10.2.3.4 through Ethernet0/2 to 10.0.14.4, and the one for 198.51.100.1 through Ethernet0/3 to 203.0.113.1.
R1 compares all the routes that match before it chooses, so a route’s place in the table plays no part.
On R1, with the default route removed, the line debug ip packet printed for one test packet to 198.51.100.1:
Without the default route, R1 found no route for 198.51.100.1 and sent nothing.
R1#show logging | include IP:1IP: s=10.0.12.1 (local), d=198.51.100.1 (nil), len 100, unroutable
- After the
d=address the parentheses hold(nil)instead of an interface, and the line ends withunroutable: no route matched.
A router discards a packet that no route matches. It does not send copies of it out of all its interfaces instead.
Key idea
R1 uses the longest of all matching routes, not the first match it finds.
Verify
Read routes that overlap
Where does R1’s table show the default route, and which line serves 10.2.3.4?
show ip route prints the default route in two places: a line above the routes, and a route line with a star.
On R1, from the whole table:
The legend explains the star, and two lines show the default route.
R1#show ip route… 6 more lines (see Full output)1 ia - IS-IS inter area, * - candidate default, U - per-user static route… 6 more lines (see Full output)2Gateway of last resort is 203.0.113.1 to network 0.0.0.0 3S* 0.0.0.0/0 [1/0] via 203.0.113.1, Ethernet0/3… 12 more lines (see Full output)
* - candidate default: the star marks the default route.- The gateway of last resort: 203.0.113.1, the next hop of the default route. “network
0.0.0.0” is the route it belongs to. S*: a typed-in route, with the star. It is 0.0.0.0/0, out of Ethernet0/3 to 203.0.113.1.
Full output · 28 lines
R1#show ip routeCodes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route H - NHRP, G - NHRP registered, g - NHRP registration summary o - ODR, P - periodic downloaded static route, l - LISP a - application route + - replicated route, % - next hop override, p - overrides from PfR & - replicated local route overrides by connected Gateway of last resort is 203.0.113.1 to network 0.0.0.0 S* 0.0.0.0/0 [1/0] via 203.0.113.1, Ethernet0/3 10.0.0.0/8 is variably subnetted, 8 subnets, 3 masksC 10.0.12.0/24 is directly connected, Ethernet0/1L 10.0.12.1/32 is directly connected, Ethernet0/1C 10.0.14.0/24 is directly connected, Ethernet0/2L 10.0.14.1/32 is directly connected, Ethernet0/2C 10.1.1.0/24 is directly connected, Ethernet0/0L 10.1.1.1/32 is directly connected, Ethernet0/0S 10.2.0.0/16 [1/0] via 10.0.12.2, Ethernet0/1S 10.2.3.0/24 [1/0] via 10.0.14.4, Ethernet0/2 203.0.113.0/24 is variably subnetted, 2 subnets, 2 masksC 203.0.113.0/24 is directly connected, Ethernet0/3L 203.0.113.2/32 is directly connected, Ethernet0/3
On R1, the “Gateway of last resort” line repeats the default route’s next hop; R1 has no separate setting for it.
Each route line comes from one of R1’s connected interfaces or from a typed-in route (Figure 2.4).
The network, with two values beside each cable, one on each side of it: R1’s interface on that cable and the route lines it carries. They sit at R1’s end of the cables to H1, R2 and R4, and half-way along the cable to R3, above R1’s name. “Et0/0” and “C + L” on the cable to H1, “Et0/1” and “C + L + S” on the cable to R2, “Et0/2” and “C + L + S” on the cable to R4, and “Et0/3” and “C + L + S*” on the cable to R3. The S on the cable to R2 is the /16, the S on the cable to R4 the /24, and S* is the default route.
To leave the legend out, add | begin Gateway, and R1 starts at the line that holds “Gateway”.
On R1, from Gateway on:
Tap a line, or “Not in the output”, then submit.
Find the line R1 uses for a packet to 10.2.3.4.
R1#show ip route | begin Gateway
R1 has three overlapping typed-in routes and C and L lines for its four own networks.
- S*: the default route, through R3. Printed first, yet the shortest prefix of all.
- A heading, not a route: it groups the lines under it.
- S: the whole 10.2.0.0/16 block, next hop 10.0.12.2, R2.
- S: the branch network 10.2.3.0/24, next hop 10.0.14.4, R4. The longest match for 10.2.3.4.
Ask R1 about the branch address itself, and it names the same route.
On R1, asking for 10.2.3.4:
R1 names one route for 10.2.3.4, the /24.
R1#show ip route 10.2.3.41Routing entry for 10.2.3.0/24 Known via "static", distance 1, metric 0 Routing Descriptor Blocks:2 * 10.0.14.4, via Ethernet0/2 Route metric is 0, traffic share count is 1
- The longest match: 10.2.3.0/24, not the /16 and not the default.
- The next hop, 10.0.14.4, and the interface, Ethernet0/2. This * marks the next-hop line, not the default route.
You can ask about any address. For 10.2.1.2 it names the /16. For 198.51.100.1, which only the default covers, it prints “% Network not in table”, yet R1 still uses the default route; read “Gateway of last resort” instead.
Key idea
“Gateway of last resort” and the S* line show the default route. For any address, the line R1 uses is the matching one with the longest prefix, whatever its place in the table.
Troubleshoot
No route, or the wrong one
A route goes missing from R1’s table. Are its packets then dropped, or sent the wrong way?
It depends on whether a shorter route still matches. Either way, a test from R1 fails in this network. With ping, R1 by default sends five test packets to an address; each ! is a reply, and each . a packet that got no reply in time.
Case 1 of 2.R1 gets no answer from the internet
Case 1 · Symptom
R1 tests 198.51.100.1, an address on the internet side, and gets no answer.
R1#ping 198.51.100.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 198.51.100.1, timeout is 2 seconds:1.....2Success rate is 0 percent (0/5)
- Five dots, one for each test packet.
Success rate is 0 percent: not one answer came back.
Case 1 · Command
Does R1 still have a default route?
Case 1 · Output
On R1:
R1#show ip route | begin Gateway1Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 8 subnets, 3 masksC 10.0.12.0/24 is directly connected, Ethernet0/1L 10.0.12.1/32 is directly connected, Ethernet0/1C 10.0.14.0/24 is directly connected, Ethernet0/2L 10.0.14.1/32 is directly connected, Ethernet0/2C 10.1.1.0/24 is directly connected, Ethernet0/0L 10.1.1.1/32 is directly connected, Ethernet0/02S 10.2.0.0/16 [1/0] via 10.0.12.2, Ethernet0/12S 10.2.3.0/24 [1/0] via 10.0.14.4, Ethernet0/2 203.0.113.0/24 is variably subnetted, 2 subnets, 2 masksC 203.0.113.0/24 is directly connected, Ethernet0/3L 203.0.113.2/32 is directly connected, Ethernet0/3
- Key line
Gateway of last resort is not set: no default route. No S* line is printed either. - The two S lines left cover only addresses that start 10.2. No line covers 198.51.100.1.
- Key line
Case 1 · How far it reaches
R1 tests the branch, which has a route of its own, the /24.
On R1, a test of the branch, 10.2.3.4:
R1#ping 10.2.3.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 10.2.3.4, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent: the branch answers.
Case 1 · What it means
Figure 2.5 · Case 1 · Without a default route nothing matches 198.51.100.1: R1 drops it. R1 with R3 above it and R2 left of it, each joined to R1 by one cable. Right of the cable to R3 the highlighted note “no route for 198.51.100.1”, and under it a cross beside the cable, just above R1.
- No route in R1’s table matches 198.51.100.1: the default route was the only one that did.
- With nothing to match, R1 drops the packets.
- Addresses that another route matches still work: the branch answered.
Case 1 · Fix
Put the default route back.
On R1, the lines that change it:
R1#configure terminalEnter configuration commands, one per line. End with CNTL/Z.1R1(config)#ip route 0.0.0.0 0.0.0.0 Ethernet0/3 203.0.113.1R1(config)#end
- The default route: address and mask 0.0.0.0 0.0.0.0, which is 0.0.0.0/0, out of Ethernet0/3 to next hop 203.0.113.1.
Impact A wrong default route sends every packet that no other route matches the wrong way.
Case 1 · Proof
R1 tests 198.51.100.1 again.
R1#ping 198.51.100.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 198.51.100.1, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent: the internet side answers again.
End of case 1. Solved: The default route is back, through R3 again.
Case 2 of 2.R1 gets no answer from the branch
Case 2 · Symptom
R1 tests the branch, 10.2.3.4, and gets no answer.
R1#ping 10.2.3.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 10.2.3.4, timeout is 2 seconds:1.U.U.2Success rate is 0 percent (0/5)
- Each
Umeans a router on the way answered that it cannot reach the address. Each dot means no answer came in time. Success rate is 0 percent: no test reached the branch.
- Each
Case 2 · Command
Which route does R1 use for 10.2.3.4 now?
Case 2 · Output
On R1:
R1#show ip route 10.2.3.41Routing entry for 10.2.0.0/16 Known via "static", distance 1, metric 0 Routing Descriptor Blocks:2 * 10.0.12.2, via Ethernet0/1 Route metric is 0, traffic share count is 1
- Key line The /16, 10.2.0.0/16, not the branch /24.
- So the next hop is 10.0.12.2, R2, out of Ethernet0/1: the way to HQ.
Case 2 · How far it reaches
R1 tests HQ.
On R1, a test of HQ, 10.2.1.2:
R1#ping 10.2.1.2Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 10.2.1.2, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent: HQ answers.
Case 2 · What it means
Figure 2.6 · Case 2 · Without the /24, the /16 sends branch packets to R2, which has no route for them. The whole network: R1 at the center, R3 above it, R2 left, the branch router R4 right and H1 under it. A highlighted short arrow beside the cable to R2 points from R1 to R2, with the highlighted notes “to 10.2.3.4 by the /16” and “R2 has no route for it” under it. The cable from R1 to R4, the way the branch packets should take, has no arrow, only the note “no /24 route” at R1’s end.
- The /24 route to R4 is gone, so the longest match for 10.2.3.4 is now the /16: R1 sends branch packets to R2.
- R2 has one typed-in route, back to the office network, and nothing for 10.2.3.0/24. With no route for the address, R2 answers that it cannot reach it: those are the U marks.
- HQ still answers: only the addresses the missing /24 covered go the wrong way.
Case 2 · Fix
Put the branch route back.
On R1, the lines that change it:
R1#configure terminalEnter configuration commands, one per line. End with CNTL/Z.1R1(config)#ip route 10.2.3.0 255.255.255.0 Ethernet0/2 10.0.14.4R1(config)#end
- The branch route: 10.2.3.0/24 (mask 255.255.255.0), out of Ethernet0/2 to next hop 10.0.14.4.
Impact A route added or removed changes at once where R1 sends its packets.
Case 2 · Proof
R1 tests the branch again.
R1#ping 10.2.3.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 10.2.3.4, timeout is 2 seconds:!!!!!1Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Success rate is 100 percent: the branch answers again.
End of case 2. Solved: The /24 is back as the longest match for the branch.
Both cases
Key idea
No match means a drop. When a longer route is missing but a shorter one still matches, the shorter route carries the traffic, possibly the wrong way.
Check
On R1:
Tap a line, or “Not in the output”, then submit.
Find the line R1 uses for a packet to 10.2.3.4.
R1#show ip route | begin Gateway
Summary
The network under a strip of two chips that read “three addresses” and “longest match wins; no match: drop”. Three short arrows beside the cables point away from R1: left to R2 noted /16, right to R4 noted /24, and, left of the cable to R3, up to R3 noted /0.
- When several routes match a destination, the router uses the one with the longest prefix, whatever its place in the table.
- The default route 0.0.0.0/0 is used only when nothing longer matches. A host sends packets for other networks to its default gateway.
- With no match at all, the router drops the packet.
show ip route 10.2.3.4names the route R1 uses for the branch address, its longest match, the /24. For an address only the default route covers, read “Gateway of last resort”, the default route’s next hop.- A missing route may drop a packet or send it the wrong way by the next-longest match.