Config Server Firewall

Route Add Windows Command to Add Persistent Static Route in Windows 10/Server

add static route windows

Adding a static route in Microsoft Windows 10 or Server is done by using the route add command.

The following is the general syntax of the route add command we need to follow to add a permanent static route in Windows:

route add -p <destination> mask <subnet-mask> <gateway>

For example, the following route command tells the windows to add a new persistent route to the 192.168.1.0/24 network, using 10.0.0.1 as the gateway to reach the network.

route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1

When you want to add a static route to a single host, use the netmask 255.255.255.255.

For example, the following command adds a static route to the destination host 192.168.1.100 with the gateway address 10.0.0.1.

route add -p 192.168.1.100 mask 255.255.255.255 10.0.0.1

The most important part of the route add command is the -p option. Without the -p switch, our new route would not be persistent. It will disappear the next time you reboot your Windows PC/Server.

We can print the windows routing table using the route print command. Under the Persistent Routes header, you will see the list of permanent static routes.

Windows routing table
Routing Table

Following is another static route example with a metric value:

route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1 metric 5

In case if you have more than one network interface, you could also specify the interface ID using the if command option.

route add -p 192.168.1.0 mask 255.255.255.0 10.0.0.1 if 1

When specifying the network interface, you have to provide the interface ID which you can find using the route print command.

Route Add Windows Command to Add Persistent Static Route in Windows

Windows hold permanent static routes in the following registry
location: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi
ces\Tcpip\Parameters\PersistentRoutes
.