Longest Prefix Match Packet Tracer Lab: Static vs OSPF
Most CCNA and Network+ candidates learn early that on Cisco IOS, a static route has a default Administrative Distance (AD) of 1, while OSPF has a default Administrative Distance of 110. That leads directly to a common routing table exam trap: assuming a static route always beats OSPF. In this hands-on Cisco Packet Tracer lab, you will build a two-server Layer 3 topology where two separate servers hold the exact same IPv4 address (10.1.1.37) in overlapping subnets across isolated Layer 2 broadcast domains. Through four live CLI scenarios, you will prove that Longest Prefix Match (LPM) always wins among installed routes, regardless of Administrative Distance or Metric—and see the exact moment Administrative Distance takes over during route installation.
Download Cisco Packet Tracer Lab Files
Lab Architecture & Why Two Servers Share 10.1.1.37
Normally, putting the same IP address on two devices triggers an IP conflict. In this topology, Server-A and Server-B sit behind separate Layer 3 routers (R2 and R3), keeping their broadcast domains completely isolated:
- Top Path (Static /16 | AD 1): R1 reaches Server-A (10.1.1.37/16) through R2 using a broad static route for 10.1.0.0/16.
- Bottom Path (OSPF /24 | AD 110): R1 reaches Server-B (10.1.1.37/24) through R3 using a more specific OSPF Area 0 route for 10.1.1.0/24.
Because both servers respond to 10.1.1.37, every tracert (and optional HTTP check) from PC1 gives unambiguous proof of which path R1 selected.

Required Devices & Cabling
- Software: Cisco Packet Tracer 9.0.0 (or another compatible version supporting the router models and IOS commands used in this lab)
- Routers: 3 × Cisco 2911 (R1, R2, R3). Other router models may be used if they provide the required routed Ethernet interfaces. Adjust interface names accordingly.
- End Devices: 1x PC (PC1), 2x Generic Servers (Server-A, Server-B)
-
Cabling (Copper Straight-Through):
- PC1 [FastEthernet0] ↔ R1 [GigabitEthernet0/2]
- R1 [GigabitEthernet0/0] ↔ R2 [GigabitEthernet0/0]
- R1 [GigabitEthernet0/1] ↔ R3 [GigabitEthernet0/1]
- R2 [GigabitEthernet0/1] ↔ Server-A [FastEthernet0]
- R3 [GigabitEthernet0/0] ↔ Server-B [FastEthernet0]
IP Addressing & Subnet Table
| Device | Interface | IP Address | Subnet Mask | Default Gateway | Role / Purpose |
|---|---|---|---|---|---|
| PC1 | Fa0 | 192.168.1.10 | 255.255.255.0 | 192.168.1.1 | Client testing source |
| R1 | G0/2 | 192.168.1.1 | 255.255.255.0 | N/A | LAN gateway for PC1 |
| R1 | G0/0 | 192.168.12.1 | 255.255.255.0 | N/A | Interconnect to R2 (Static path) |
| R1 | G0/1 | 192.168.13.1 | 255.255.255.0 | N/A | Interconnect to R3 (OSPF path) |
| R2 | G0/0 | 192.168.12.2 | 255.255.255.0 | N/A | Link to R1 |
| R2 | G0/1 | 10.1.0.1 | 255.255.0.0 | N/A | Gateway for Server-A (/16) |
| Server-A | Fa0 | 10.1.1.37 | 255.255.0.0 | 10.1.0.1 | Destination host in /16 |
| R3 | G0/1 | 192.168.13.2 | 255.255.255.0 | N/A | Link to R1 |
| R3 | G0/0 | 10.1.1.1 | 255.255.255.0 | N/A | Gateway for Server-B (/24) |
| Server-B | Fa0 | 10.1.1.37 | 255.255.255.0 | 10.1.1.1 | Destination host in /24 |
Step-by-Step Device Configuration
1. Configure End Devices
On PC1, Server-A, and Server-B, open Desktop → IP Configuration and enter the IPv4 address, subnet mask, and default gateway from the table above.
(Optional Visual Proof) Open Services → HTTP → index.html on both servers and replace the HTML so you can also verify the active path in PC1's web browser at http://10.1.1.37:
Server-A index.html:
<html><body style="font-family:Arial; text-align:center; padding-top:40px; background:#a7f3d0;">
<h1 style="color:#065f46;">PATH TAKEN: SERVER-A</h1>
<h2>Static Path (via R2 - 192.168.12.2)</h2>
</body></html>Server-B index.html:
<html><body style="font-family:Arial; text-align:center; padding-top:40px; background:#c7d2fe;">
<h1 style="color:#312e81;">PATH TAKEN: SERVER-B</h1>
<h2>OSPF /24 Path (via R3 - 192.168.13.2)</h2>
</body></html>2. Configure R1 (Edge Router)
R1 advertises PC1's subnet (192.168.1.0/24) into OSPF Area 0 so R3 automatically learns the return route, and uses a static /16 route pointing to R2.
enable
configure terminal
hostname R1
no ip domain lookup
interface GigabitEthernet0/0
description Link-to-R2-Static
ip address 192.168.12.1 255.255.255.0
no shutdown
interface GigabitEthernet0/1
description Link-to-R3-OSPF
ip address 192.168.13.1 255.255.255.0
no shutdown
interface GigabitEthernet0/2
description LAN-PC1
ip address 192.168.1.1 255.255.255.0
no shutdown
exit
router ospf 1
router-id 1.1.1.1
network 192.168.13.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 0
exit
ip route 10.1.0.0 255.255.0.0 192.168.12.2
end
write memory3. Configure R2 (Static Path Router)
enable
configure terminal
hostname R2
no ip domain lookup
interface GigabitEthernet0/0
description Link-to-R1
ip address 192.168.12.2 255.255.255.0
no shutdown
interface GigabitEthernet0/1
description LAN-Server-A
ip address 10.1.0.1 255.255.0.0
no shutdown
exit
ip route 0.0.0.0 0.0.0.0 192.168.12.1
end
write memory4. Configure R3 (OSPF Path Router)
enable
configure terminal
hostname R3
no ip domain lookup
interface GigabitEthernet0/1
description Link-to-R1
ip address 192.168.13.2 255.255.255.0
no shutdown
interface GigabitEthernet0/0
description LAN-Server-B
ip address 10.1.1.1 255.255.255.0
no shutdown
exit
router ospf 1
router-id 3.3.3.3
network 192.168.13.0 0.0.0.255 area 0
network 10.1.1.0 0.0.0.255 area 0
end
write memoryScene 1: Baseline Verification — Longest Prefix Match Overrides AD
In the baseline state, R1 has two valid routes that cover 10.1.1.37.
1. Inspect R1's Routing Table
R1# show ip route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S 10.1.0.0/16 [1/0] via 192.168.12.2
O 10.1.1.0/24 [110/2] via 192.168.13.2, 00:01:14, GigabitEthernet0/1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/2
L 192.168.1.1/32 is directly connected, GigabitEthernet0/2
192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.12.0/24 is directly connected, GigabitEthernet0/0
L 192.168.12.1/32 is directly connected, GigabitEthernet0/0
192.168.13.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.13.0/24 is directly connected, GigabitEthernet0/1
L 192.168.13.1/32 is directly connected, GigabitEthernet0/1
Notice that both routes coexist in the Routing Information Base (RIB). Because /16 and /24 represent different prefixes, Administrative Distance does not pit them against each other.
2. Query Cisco IOS for 10.1.1.37
R1# show ip route 10.1.1.37
Routing entry for 10.1.1.0/24
Known via "ospf 1", distance 110, metric 2, type intra area
Last update from 192.168.13.2 on GigabitEthernet0/1, 00:01:45 ago
Routing Descriptor Blocks:
* 192.168.13.2, from 3.3.3.3, 00:01:45 ago, via GigabitEthernet0/1
Route metric is 2, traffic share count is 1
Why /24 Beats /16 (Bitwise Breakdown)
To understand R1's forwarding decision, represent 10.1.1.37 in binary (00001010.00000001.00000001.00100101) and compare the matching prefixes from left to right:
| Candidate Route | Source & AD | Bitwise Match Against 10.1.1.37 | Matching Bits | Result |
|---|---|---|---|---|
| 10.1.0.0/16 | Static (AD 1) | 00001010.00000001 | xxxxxxxx.xxxxxxxx | 16 bits | Valid backup |
| 10.1.1.0/24 | OSPF (AD 110) | 00001010.00000001.00000001 | xxxxxxxx | 24 bits | Winner (LPM) |
24 matching bits beat 16 matching bits. R1 selects the OSPF route immediately—Administrative Distance is never even checked.
3. Verify End-to-End Forwarding from PC1
C:\>tracert 10.1.1.37
Tracing route to 10.1.1.37 over a maximum of 30 hops:
1 0 ms 0 ms 0 ms 192.168.1.1
2 0 ms 0 ms 0 ms 192.168.13.2
3 * 1 ms 0 ms 10.1.1.37
Trace complete.Note: An initial * timeout on Hop 3 may occur while R3 resolves Server-B's MAC address through ARP. Subsequent traces may resolve all three probes cleanly.

Hop 2 is 192.168.13.2 (R3), confirming traffic lands on Server-B.
Scene 2: Dynamic Failover — Proving the /16 Static Route Was Only Shadowed
Shut down Server-B's LAN interface on R3 to withdraw the /24 OSPF advertisement:
R3# configure terminal
R3(config)# interface GigabitEthernet0/0
R3(config-if)# shutdown
R3(config-if)# endR3 updates its Router-LSA to remove the advertisement for 10.1.1.0/24 and floods the updated link-state information. After OSPF converges, query R1 again:
R1# show ip route 10.1.1.37
Routing entry for 10.1.0.0/16
Known via "static", distance 1, metric 0
Routing Descriptor Blocks:
* 192.168.12.2
Route metric is 0, traffic share count is 1
Running show ip route ospf on R1 now returns empty. Re-run tracert from PC1:
C:\>tracert 10.1.1.37
Tracing route to 10.1.1.37 over a maximum of 30 hops:
1 0 ms 0 ms 0 ms 192.168.1.1
2 0 ms 0 ms 0 ms 192.168.12.2
3 0 ms 0 ms 0 ms 10.1.1.37
Trace complete.Hop 2 shifts automatically to 192.168.12.2 (R2), routing traffic cleanly to Server-A without a single configuration change on R1.
Scene 3: The /32 Host Route Override
First, restore R3's link so OSPF re-installs 10.1.1.0/24:
R3# configure terminal
R3(config)# interface GigabitEthernet0/0
R3(config-if)# no shutdown
R3(config-if)# endNext, inject a /32 static host route (255.255.255.255) on R1 pointing back toward R2:
R1# configure terminal
R1(config)# ip route 10.1.1.37 255.255.255.255 192.168.12.2
R1(config)# endInspect R1's routing table with show ip route:
10.0.0.0/8 is variably subnetted, 3 subnets, 3 masks
S 10.1.0.0/16 [1/0] via 192.168.12.2
O 10.1.1.0/24 [110/2] via 192.168.13.2, 00:00:22, GigabitEthernet0/1
S 10.1.1.37/32 [1/0] via 192.168.12.2All three overlapping routes now coexist in the RIB. Querying show ip route 10.1.1.37 returns 10.1.1.37/32 via 192.168.12.2, and tracert 10.1.1.37 from PC1 diverts straight back to R2 / Server-A.
| Candidate Route | Matching Bits | Outcome |
|---|---|---|
| 10.1.0.0/16 | 16 bits | Valid candidate |
| 10.1.1.0/24 | 24 bits | Valid candidate |
| 10.1.1.37/32 | 32 bits (100% match) | Winner (Longest Prefix Match) |

Scene 4: Exact /24 Prefix Tie — Administrative Distance Takes Over
Finally, remove the /32 host route on R1 and add a static /24 route that matches OSPF's exact network prefix and subnet mask:
R1# configure terminal
R1(config)# no ip route 10.1.1.37 255.255.255.255 192.168.12.2
R1(config)# ip route 10.1.1.0 255.255.255.0 192.168.12.2
R1(config)# endNow run show ip route on R1:
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S 10.1.0.0/16 [1/0] via 192.168.12.2
S 10.1.1.0/24 [1/0] via 192.168.12.2The OSPF 10.1.1.0/24 entry is gone from the RIB, and show ip route ospf returns no routes.

Proving OSPF Is Still Healthy Behind the Scenes
Did OSPF crash? Verify with two diagnostic commands on R1:
R1# show ip ospf neighbor
R1# show ip ospf databaseTo inspect the subnet information within R3's Router-LSA, use the following command if supported by your Packet Tracer router:
R1# show ip ospf database router 3.3.3.3R1 still maintains a FULL adjacency with neighbor 3.3.3.3 on GigabitEthernet0/1, and R3's Router-LSA remains in the OSPF Link-State Database (LSDB), retaining the advertisement for 10.1.1.0/24. Because both sources offered the exact same /24 prefix, Administrative Distance stepped in as the RIB admission filter: Static (AD 1) beat OSPF (AD 110), denying OSPF entry into the routing table. A final tracert 10.1.1.37 from PC1 confirms Hop 2 routes through 192.168.12.2 (R2) to Server-A.
The 3-Tier Router Decision Hierarchy
Commit this exact order to memory for CCNA, Network+, and production troubleshooting:
- Longest Prefix Match (Forwarding Engine): When forwarding packets, the most specific matching installed prefix (/32 down to /0) wins regardless of routing protocol or Administrative Distance.
-
Administrative Distance (RIB Admission Filter):
Administrative Distance determines the preferred routing source when different sources offer the exact same network prefix and mask. Lower Administrative Distance is preferred.
Cisco IOS defaults: Connected = 0, Static = 1, eBGP = 20, Internal EIGRP = 90, OSPF = 110, RIP = 120.
- Metric (Protocol-Specific Path Selection): When the same routing protocol learns multiple paths to the exact same prefix and mask, it uses its own path-selection rules and metrics to determine the preferred path.
Quick CCNA Self-Check
Suppose R1 simultaneously learns or has configured:
- Default route: 0.0.0.0/0 (Static, AD 1)
- Supernet route: 10.1.0.0/16 (Static, AD 1)
- EIGRP route: 10.1.1.0/24 (Internal EIGRP, AD 90)
- OSPF route: 10.1.1.0/24 (OSPF, AD 110)
Which /24 route gets installed in the RIB, and which installed route is selected for destination 10.1.1.37?
Reveal Answer
Answer: The EIGRP 10.1.1.0/24 (AD 90) route wins. During route installation, EIGRP (AD 90) beats OSPF (AD 110) for the identical /24 prefix. The static /16 and /0 routes remain installed. During packet forwarding, Longest Prefix Match selects the installed EIGRP /24 route for destination 10.1.1.37.
Author Laxmi Goswami Updated on 2026-11-28