Pcornel
Windows · Routing

Longest Prefix Match

Cheat sheet · https://pcornel.dk/topic.php?topic=3083

Back to the Topic

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.

Remember

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.

First checks

  • Get-NetRoute — routing table
  • Find-NetRoute -RemoteIPAddress <ip> — selected route and source
  • route print — routing table in CMD
  • tracert <dest> — path

Verify in this order

all routes containing the destination → longest prefix wins

Where it usually breaks

First mismatch in host/interface identity → local config/routing/name state → Windows service/provider → firewall/security/session → remote service → application-visible exchange; preserve identity/native error/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3083

Confirmation

Confirm action

Continue?