Frequently Asked Question
Add Static Routes
Adding a static route that survives a reboot
(Windows 10, Windows 11 and Windows Server 2025)
Static routes created with the plain route add command disappear when the PC is restarted. To make them permanent you have two reliable options:
| Method | When to use | Key command |
|---|---|---|
Command Prompt – route -p |
Quick, one‑off IPv4 routes | route -p add … |
PowerShell – New‑NetRoute / Set‑NetRoute |
Scripting, IPv4 & IPv6, modern management | New-NetRoute … |
Below are step‑by‑step instructions for each method, plus notes on IPv6, verification and removal.
1. Use the legacy route -p command (IPv4 only)
- Open an elevated command prompt
Press Win + X → Windows Terminal (Admin) or Command Prompt (Admin).
- Identify the interface number (optional but recommended)
route print
The list under Interface List shows the numeric IDs (e.g. 12 … Ethernet). You can also use the interface’s name later with if <number>.
- Add the persistent route
route -p add <destination> mask <netmask> <gateway> metric <metric> if <if‑index>
Example – send traffic for 10.20.30.0/24 via 192.168.1.1 on interface 12:
route -p add 10.20.30.0 mask 255.255.255.0 192.168.1.1 metric 10 if 12
What the switches mean
-p– makes the entry persistent (saved in the registry).<destination>– network or host you want to reach.mask <netmask>– subnet mask for the destination.<gateway>– next‑hop IP address.metric <metric>– cost of the route (lower = preferred).if <if‑index>– optional; forces the route onto a specific NIC.
- Verify the entry
route print
Persistent routes appear under the Persistent Routes heading.
- Remove a persistent route (if needed)
route -p delete <destination> mask <netmask> <gateway>
Or delete by destination only: route -p delete 10.20.30.0
2. Use PowerShell (recommended for IPv4 and IPv6)
PowerShell’s networking cmdlets store routes in the same place as route -p but give you richer syntax and easier scripting.
2.1 Add a persistent IPv4 route
New-NetRoute -DestinationPrefix "10.20.30.0/24" `
-InterfaceIndex 12 `
-NextHop "192.168.1.1" `
-RouteMetric 10 `
-PolicyStore PersistentStore
Key parameters
| Parameter | Description |
|---|---|
-DestinationPrefix |
Network and CIDR (e.g. 10.20.30.0/24). |
-InterfaceIndex / -InterfaceAlias |
NIC identifier (index or name). |
-NextHop |
Gateway IP. |
-RouteMetric |
Cost of the route. |
-PolicyStore PersistentStore |
Forces the route to be saved across reboots. |
2.2 Add a persistent IPv6 route
New-NetRoute -DestinationPrefix "2001:db8:100::/64" `
-InterfaceAlias "Ethernet" `
-NextHop "fe80::1" `
-RouteMetric 5 `
-PolicyStore PersistentStore
Note: The legacy route -p command does not support IPv6 persistence; PowerShell is the only built‑in way.
2.3 Verify routes
Get-NetRoute -PolicyStore PersistentStore | Format-Table
2.4 Remove a persistent route
Remove-NetRoute -DestinationPrefix "10.20.30.0/24" -PolicyStore PersistentStore
3. Where Windows stores persistent routes
- Registry location:
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes - PowerShell writes the same data, so both methods share the storage area.
You normally never need to edit the registry directly; use the commands above.
4. Tips & common pitfalls
| Issue | Cause | Fix |
|---|---|---|
| Route disappears after a network‑adapter reset | Route was added without -p (or without -PolicyStore PersistentStore). |
Re‑add using the persistent options. |
| “The route already exists” error | A duplicate persistent entry already exists. | Delete the old entry first (route -p delete … or Remove‑NetRoute). |
| Wrong interface used | Interface index changed after driver update. | Use the interface name (-InterfaceAlias) instead of the numeric index. |
| IPv6 route not persisting | Used route add without -p (IPv6 not supported). |
Use PowerShell’s New‑NetRoute with -PolicyStore PersistentStore. |
| Metric not being honoured | Multiple routes to the same destination with different metrics. | Ensure the metric you set is the lowest for the desired path. |
| Need the route on many computers | Manual entry on each machine is labour‑intensive. | Deploy a PowerShell script via Group Policy, SCCM, Intune or a login script. |
5. Quick cheat‑sheet (copy‑paste)
:: ---------- Command Prompt (IPv4) ----------
REM Open admin CMD first
route -p add 10.20.30.0 mask 255.255.255.0 192.168.1.1 metric 10 if 12
route print
route -p delete 10.20.30.0
:: ---------- PowerShell (IPv4 & IPv6) ----------
# Open PowerShell as Administrator
# IPv4
New-NetRoute -DestinationPrefix "10.20.30.0/24" `
-InterfaceIndex 12 `
-NextHop "192.168.1.1" `
-RouteMetric 10 `
-PolicyStore PersistentStore
# IPv6
New-NetRoute -DestinationPrefix "2001:db8:100::/64" `
-InterfaceAlias "Ethernet" `
-NextHop "fe80::1" `
-RouteMetric 5 `
-PolicyStore PersistentStore
# Verify
Get-NetRoute -PolicyStore PersistentStore | ft DestinationPrefix,NextHop,InterfaceAlias,RouteMetric
# Remove
Remove-NetRoute -DestinationPrefix "10.20.30.0/24" -PolicyStore PersistentStore
6. When to choose which method
| Situation | Recommended method |
|---|---|
| One‑off IPv4 route on a single workstation | route -p in an elevated CMD |
| Need IPv6 persistence | PowerShell (New‑NetRoute) |
| Deploying to many machines or need scripting | PowerShell script (can be run from a login script or GPO) |
| Want to use a friendly interface name rather than numeric index | PowerShell (-InterfaceAlias) |
Bottom line: Add the -p switch in the classic route utility for IPv4, or use PowerShell’s New‑NetRoute with -PolicyStore PersistentStore for both IPv4 and IPv6. Both store the route in the system’s persistent route table, ensuring it survives every reboot on Windows 10, Windows 11 and Windows Server 2025.
