Pcornel
Windows

Routing

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

Back to the Topic

Answer

Windows routing decides which interface and gateway each packet uses, from the routing table with longest prefix match first and then the lowest combined route and interface metric. View it with route print.

Remember

  • Longest matching prefix always wins before any metric is compared.
  • Among equal prefixes the lowest route + interface metric wins.
  • VPN clients add routes and can steal the default route.

First checks

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

Commands

Get-NetRoute [-DestinationPrefix <prefix>]
Display Windows routes.
route.exe
Display and change the Windows routing table.
New-NetRoute
Add a route to the Windows routing table.
Get-NetRoute
Windows route table as PowerShell objects.
Get-NetRoute -AddressFamily IPv4 | Sort-Object RouteMetric
Shows Windows route table entries and metrics.
Find-NetRoute -RemoteIPAddress {{destination}}
Shows the route and source address Windows would use for a destination.

Verify in this order

destination → route lookup → next hop/interface

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=3080

Confirmation

Confirm action

Continue?