route -p add <DestinationNetwork> mask <SubnetMask> <GatewayIP> metric <MetricValue> if <InterfaceIndex>. The -p switch writes the route to the Windows registry alongside the active routing table so that it survives system restarts. This procedure applies identically to all editions of Windows 10, Windows 11, and Windows Server (2016 through 2025) for IPv4 and IPv6 routing tables.By default, a Windows PC sends all traffic destined for non-local subnets to its single default gateway. When your machine is connected to a network with secondary routers, site-to-site gateways, split-tunnel VPNs, or isolated lab VLANs—or when your PC has multiple network adapters—the default gateway may not know how to reach a specific remote subnet. Adding a static route tells the Windows TCP/IP stack to forward packets aimed at a specific destination network through a designated next-hop router (gateway) and network interface instead of sending them to the default gateway.
Prerequisites and Network Information Needed
Before modifying your routing table, verify that you have the following requirements and network values ready:
- Administrator privileges: Viewing the routing table (
route print) works in a standard command window, but adding, changing, or deleting routes (route add,route change,route delete) requires an elevated Command Prompt or PowerShell session running as Administrator. - Destination network ID and subnet mask: The network address you want to reach (for example,
10.41.0.0) and its corresponding subnet mask in dotted-decimal format (for example,255.255.0.0). When targeting a single specific host IP rather than an entire subnet, use255.255.255.255as the subnet mask. - Next-hop gateway IP address: The IP address of the local router or gateway interface that forwards traffic to the destination subnet (for example,
10.27.0.1). This gateway IP must be reachable on a subnet directly connected to one of your PC's active network interfaces. - Return path routing on the remote network: A static route on your Windows PC only controls outbound packets leaving your machine. The destination device or the intermediate router must also have a valid route back to your PC's subnet (or perform Network Address Translation), or two-way communication will fail even when your local static route is configured properly.
Inspect the Current Routing Table and Interface Indexes
Before adding a new route, inspect the current Windows IP routing table to check for conflicting entries and to find the decimal Interface Index (IF) for the network adapter that should carry the traffic. While route.exe tries to guess the best interface automatically based on the gateway IP, explicitly specifying the interface index prevents Windows from binding the route to the wrong adapter on multi-homed systems, Hyper-V hosts, or PCs with virtual VPN adapters.
- Open an elevated terminal:
- Windows 11: Right-click the Start button and select Terminal (Admin) or Command Prompt (Admin).
- Windows 10: Right-click the Start button and select Command Prompt (Admin) or Windows PowerShell (Admin).
- When prompted by User Account Control (UAC), click Yes.
- Run the following command to display the full IPv4 routing table:
route print -4
(If you are working with IPv6 routes, runroute print -6instead.) - Scroll to the top of the output and locate the Interface List section. Every physical and virtual network adapter has a number in the left column, followed by its MAC address and adapter description:
Note the number at the far left of the adapter that connects to your target gateway (for example,Code:=========================================================================== Interface List 12...00 15 5d 01 02 03 ......Intel(R) Ethernet Connection 15...00 15 5d 01 02 04 ......Hyper-V Virtual Ethernet Adapter 1...........................Software Loopback Interface 1 ===========================================================================12). As confirmed by Microsoft's officialroutecommand documentation, theInterface Listat the top ofroute printdisplays these index numbers in decimal format, so you can use that exact number directly with theifparameter. - Review the IPv4 Route Table section directly below the Interface List, which is divided into Active Routes and Persistent Routes:
- Network Destination and Netmask: Define the target IP range. A destination of
0.0.0.0with a netmask of0.0.0.0represents your default route. - Gateway: Shows the next-hop router IP address, or says
On-linkif the subnet is directly attached to your local network adapter without needing a router. - Interface: Shows the local IP address assigned to your PC's adapter for that route.
- Metric: Indicates the route's cost. When multiple routes match the exact same destination prefix and subnet mask, Windows prefers the route with the lowest metric number.
- If your routing table is large, filter the output to check whether a route to your target network already exists. For example, to view only routes beginning with
10.41., run:
route print 10.41.*
Add a Persistent Static Route with route.exe
Warning: Adding an incorrect static route—especially one that overlaps with 0.0.0.0, your local LAN subnet, or an active management interface—can immediately drop your network or remote desktop connection. If you are configuring a remote machine over RDP or SSH, consider testing the command without the -p flag first; a non-persistent route disappears automatically if you reboot the machine.
- In your elevated Command Prompt or Windows Terminal window, use the following syntax to add a persistent IPv4 static route:
route -p add <Destination> mask <SubnetMask> <Gateway> metric <Cost> if <InterfaceIndex> - Replace the placeholders with your specific network values. For example, to route all traffic destined for the
10.41.0.0/16subnet (255.255.0.0) through the local gateway10.27.0.1using interface12and a metric of10, run:
route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 10 if 12
(Note: Windows accepts-peither before or after theaddverb, so bothroute -p add ...androute add -p ...work identically. Themaskkeyword is mandatory whenever you specify a subnet mask; omittingmaskcauses a syntax error.) - Check the command output. When the syntax and parameters are valid, Windows prints a single confirmation line:
OK!
No system restart is required; the route takes effect immediately in the active routing table and is simultaneously saved to the persistent registry store.
Adding a Single-Host Static Route
If you want to route traffic for only one specific IP address (a /32 host route) through an alternate gateway rather than a whole subnet, specify the exact host IP as the destination and 255.255.255.255 as the mask:
route -p add 10.41.50.25 mask 255.255.255.255 10.27.0.1 metric 10 if 12
Because Windows evaluates routes using longest prefix match before comparing metrics, a /32 host route (255.255.255.255) will always take priority over a broader /24 (255.255.255.0), /16 (255.255.0.0), or default (0.0.0.0) route, regardless of the metric value.
Verify That the Static Route Is Active and Persistent
After receiving the OK! prompt, confirm both that the route is stored in the Windows routing table and that Windows actually selects it for outbound traffic.
- Run the filtered print command in Command Prompt to inspect the routing table:
route print 10.41.* - Verify that your entry appears in two places at the bottom of the output:
- Under Active Routes, you should see
10.41.0.0, netmask255.255.0.0, gateway10.27.0.1, the IP address of interface12, and the effective metric. (Note that under Active Routes, Windows adds your specified route metric to the network adapter's base interface metric, so the displayed active metric may be higher than the number you typed.) - Under Persistent Routes, you should see
10.41.0.0, netmask255.255.0.0, gateway address10.27.0.1, and the exact metric you specified (10). - Test which route Windows chooses for an IP address inside that target subnet by opening PowerShell and running
Find-NetRoute:
Find-NetRoute -RemoteIPAddress 10.41.1.50
Look at theNextHopandInterfaceIndexfields in the bottom section of the output.NextHopmust show your specified gateway (10.27.0.1). - Trace the live network path to a reachable host on that destination subnet from Command Prompt:
tracert -d 10.41.1.50
The-dswitch skips DNS reverse lookups so the trace completes quickly. Confirm that hop1in thetracertoutput is10.27.0.1and not your default gateway.
Alternate Method: Manage Persistent Routes Using PowerShell (NetTCPIP)
If you prefer CIDR notation (such as /16 or /24 instead of typing dotted-decimal subnet masks) or are writing an administrative deployment script, use the native NetTCPIP PowerShell module in Windows 10 and Windows 11.
- Open Windows PowerShell (Admin) or Terminal (Admin).
- List your active network adapters to identify the
ifIndex(Interface Index) orName(Interface Alias):
Get-NetAdapter - Create the persistent route using
New-NetRoute. By default, when you omit the-PolicyStoreparameter,New-NetRouteautomatically writes the route to both theActiveStore(current session) and thePersistentStore(across reboots):
New-NetRoute -DestinationPrefix "10.41.0.0/16" -InterfaceIndex 12 -NextHop 10.27.0.1 -RouteMetric 10
(If you ever want to add a temporary route in PowerShell that clears on reboot, append-PolicyStore ActiveStoreto the command.) - Verify the newly created route in both stores by running:
Code:Get-NetRoute -DestinationPrefix "10.41.0.0/16" -PolicyStore ActiveStore Get-NetRoute -DestinationPrefix "10.41.0.0/16" -PolicyStore PersistentStore
Modify or Remove a Persistent Static Route (Rollback)
When your network topology changes or you need to undo a misconfigured route, you can update the gateway/metric in place or delete the persistent route completely.
Change an Existing Route
To change the gateway, metric, or interface of an existing route in route.exe, use route change:
route change 10.41.0.0 mask 255.255.0.0 10.27.0.254 metric 5 if 12
If you need to make sure the persistent record is cleanly updated without leftover entries, the safest practice is to delete the route and re-add it with -p.
Delete a Static Route
- Open an elevated Command Prompt or Terminal window.
- Run
route deletewith the destination network and subnet mask:
route delete 10.41.0.0 mask 255.255.0.0
If you have multiple routes to the exact same destination network going through different gateways, include the gateway IP so Windows only removes the intended entry:
route delete 10.41.0.0 mask 255.255.0.0 10.27.0.1
Runningroute deleteremoves the route from both the Active Routes table and the Persistent Routes store at the same time. - If you added the route via PowerShell or prefer removing it with
NetTCPIP, run:
Remove-NetRoute -DestinationPrefix "10.41.0.0/16" -NextHop 10.27.0.1 -Confirm:$false - Run
route print 10.41.*to confirm the entry no longer appears under either Active Routes or Persistent Routes.
Inspecting the Registry Storage Location
When you use route -p add, Windows stores the persistent route as a string value inside the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes
(IPv6 persistent routes are stored under Tcpip6\Parameters\PersistentRoutes.)
Each value name in this key is formatted as Destination,Netmask,Gateway,Metric (for example, 10.41.0.0,255.255.0.0,10.27.0.1,10). While you should always use route delete or Remove-NetRoute so the active TCP/IP stack updates cleanly without a reboot, network administrators auditing a system or cleaning up orphaned routes offline can inspect this registry key using regedit.exe or reg query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\PersistentRoutes.
Warning: Never run route -f on a production or remote machine unless you intend to wipe the entire routing table. The -f parameter clears the routing tables of all gateway entries (including your default gateway 0.0.0.0), which immediately drops all network connectivity until you either re-add the default gateway manually, renew your DHCP lease, or restart the computer.
Troubleshooting Common Static Route Failures
- "The requested operation requires elevation."
- Cause: You ran
route add,route change, orroute deletein a non-administrative Command Prompt or PowerShell window. - Fix: Close the window, right-click Start, choose Terminal (Admin) or Command Prompt (Admin), and run the command again.
- "The route addition failed: The specified mask parameter is invalid."
- Cause: The destination IP address has host bits set to
1outside the subnet mask boundary—meaning(Destination & Mask) != Destination. For example, typingroute -p add 10.41.1.50 mask 255.255.0.0 10.27.0.1fails because.1.50is a specific host address, whereas the255.255.0.0mask expects the network ID ending in.0.0. - Fix: Either change the destination to the base network ID (
10.41.0.0for255.255.0.0, or10.41.1.0for255.255.255.0) or change the subnet mask to255.255.255.255if you intended to route only the single host10.41.1.50. - "The route addition failed: The parameter is incorrect."
- Cause: This error occurs for one of three reasons:
- You provided an invalid Interface Index (
if <number>) that does not exist inroute print, or you typed a0xhexadecimal prefix whenroute.exeexpected the decimal index shown in the Interface List. - The gateway IP address is not on the same subnet as the network interface you specified (Windows cannot reach the next-hop gateway directly on link).
- You omitted the
maskkeyword before the subnet mask. - Fix: Run
ipconfigto confirm your adapter has an active IP address on the same local subnet as the gateway IP you are specifying, verify the decimal interface number at the top ofroute print, and ensure the wordmaskprecedes the subnet mask. - "The route addition failed: The object already exists."
- Cause: A route with the exact same destination, subnet mask, and gateway is already present in the routing table.
- Fix: Run
route print <destination>to inspect the existing route. Useroute delete <destination> mask <netmask>to remove the old entry before re-adding it, or useroute changeto update its metric. - The route appears under "Persistent Routes" but is missing from "Active Routes".
- Cause: The network adapter associated with that route is currently disconnected, disabled, waiting for a VPN tunnel to come up, or has lost its IP address lease, making the next-hop gateway unreachable.
- Fix: Check
ipconfigorGet-NetAdapterto verify the interface isUpand has a valid IP address in the gateway's subnet. If the route is meant for a VPN or removable adapter, note that Windows often cannot bind a persistentroute.exeentry to a virtual VPN interface that does not exist at boot time; for Windows built-in VPN connections, use the PowerShell cmdletAdd-VpnConnectionRouteinstead so Windows injects the route automatically whenever the VPN connects. - Traffic still goes out the default gateway despite the static route being active.
- Cause: Another active route has a more specific subnet mask (longer prefix match) covering the destination IP. In Windows routing, prefix length always wins over metric: a
/24(255.255.255.0) route with metric500will always beat a/16(255.255.0.0) route with metric1. - Fix: Run
Find-NetRoute -RemoteIPAddress <TargetIP>in PowerShell to see the exact route Windows is selecting for that destination IP, then either remove the conflicting narrower route or create a more specific route prefix.