Sometimes you need to create static route to make communication with different network which is connected via different gateway than the default gateway set in your computer IP address. Gateways is simply a network router which route the network traffic between different networks. When you have more than one gateway (router) on your network, then you may need to implement static route technique on Windows 10, Windows 2012 R2 or Windows 2016 server. Static route will tell the Operating System to send network packets to appropriate router instead of sending to default router. This simple guide shows how to add and delete static route on Windows 10/2012 R2 and 2016 server Operating Systems.
There are few useful commands you must know. Route delete, add and print. These commands will be handy to any user who has administrative access and know which router/gateway should be used for which network.
Route Add on Windows 10 and Windows 2012 R2/2016 Server
Make sure you run below commands on command prompt (or PowerShell) which is opened as Administrator.
This is to add the entries.
route add 10.10.10.0 mask 255.255.255.0 10.10.29.1
It indicates that any packets to 10.10.10.0 (in class C – 255.255.255.0) network should be forwarded to 10.10.29.1 router (gateway). Obviously the PC/server which we run this command is in 10.10.29.0/24 network, because the PC/server should communicate to gateway from the same network.
The issue with the above command is, when you shutdown or restart the computer, these route entries will disappear. To make it permanent and save in Windows OS routing table, we should use –p key with the route add command. So, permanent static route add on Windows 10 command will be like this;
route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.1
Okay, you kept on adding static route entries, now how to see them? or if you need to modify a route entry which is already in the routing table on Windows 10 or Windows 2016 server, how to modify it? Firstly, we have to see the existing route entries on the computer. To do it, use route print command.
Route Delete on Windows 10/2012 R2/2016
This is to delete an existing persistent route entry from a computer. Even though we have added a route entry with network, network mask and gateway, to delete, we need to mention the network only. So, it goes like this;
route delete 10.10.10.0
That will delete the 10.10.10.0 route entry from the computer. You may not need to restart the computer to take effect.
How to Modify a Static Route Entry on Windows 10/2016
Let’s say that after the recent network change, now the network 10.10.10.0 should be routed through 10.10.29.200 gateway. Obviously you have to modify the existing route for this network and change the gateway to 10.10.29.200, how to modify it?
You can’t modify an existing route entry. The simple method is delete it and enter the new route entry. So, in this case you would perform below commands.
Route delete 10.10.10.0 Route add –p 10.10.10.0 mask 255.255.255.0 10.10.29.200
We hope this simple guide will help in understanding the route add, delete and print commands in Windows 10 client PC and 2012 R2 and 2016 server Operating Systems. Make sure you open the command prompt or PowerShell as Administrator to perform these commands. If you want to use cosmetic variables to identify the fast hops to reach a network, you can use metric key as described at Microsoft site here.