Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

Longest Prefix Match

Direct answer

Like a router, Windows uses the most specific route that contains the destination: a /24 to a VPN wins over the /0 default route, whatever the metrics.

When to use this

Use it when traffic goes through a VPN or another interface although the default route points elsewhere.

First 30 seconds

1. List matching prefixes for the destination.

2. Most specific wins regardless of metric.

3. A /32 or more specific VPN route overrides default.

4. Remove or adjust the specific route.

5. Verify with Find-NetRoute.

Operational verification

all routes containing the destination → longest prefix wins

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Windows networking and network services
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformWindows networking and network services
Key commandGet-NetRoute -DestinationPrefix 10.20.0.0/16
Scope / prerequisiteUse it when traffic goes through a VPN or another interface although the default route points elsewhere.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Commands Verify boundary
Get-NetRoute -DestinationPrefix 10.20.0.0/16
Find-NetRoute -RemoteIPAddress 10.20.5.9
route print -4
Step 2 Common mistakes Narrow the fault
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Metrics only decide between routes of the same prefix length. A VPN that pushes specific routes takes those destinations regardless of interface metrics. Check with Get-NetRoute for routes containing the destination.

Key checks
  • Get-NetRoute — routing table
  • Find-NetRoute -RemoteIPAddress <ip> — selected route and source
  • route print — routing table in CMD
  • tracert <dest> — path
ReferenceWhy it matters1 section · depth on demand

Worked example

Longest prefix match: the most specific matching route wins regardless of metric.

Worked example: routes 10.0.0.0/8 via 10.1.1.1 (metric 1), 10.20.0.0/16 via 10.2.2.1 (metric 50), 0.0.0.0/0 via 192.168.1.1. Destination 10.20.5.9 → /16 route (longest match, despite higher metric). Destination 10.99.0.1 → /8 route. Destination 8.8.8.8 → default route.

Find-NetRoute -RemoteIPAddress 10.20.5.9
ReferenceImportant terms & boundaries1 section · depth on demand
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docWindows networking and network services current

Authoritative/upstream documentation reviewed for bounded claims in Routing → Longest Prefix Match. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/windows-server/networking/ · confidence 94%
Confirmation

Confirm action

Continue?