How to add static routes in Windows

Let’s say we have a network with the following data:

– IP address of the gateway (default gateway) – 192.168.1.1
– subnet mask 255.255.255.0
– VPN server address 10.0.0.3
then to add a static route, open the command line (cmd) by clicking on the menu “Start” – “Run” – “cmd” or using the Win+R key combination and type the command:

route ADD -p 10.0.0.3 MASK 255.255.255.255 192.168.1.1 METRIC 1

Or suppose we have:
– Network: 192.168.1.0/24
– IP of the first computer 192.168.1.2 with VPN connection
– IP of the second computer 192.168.1.3
– IP address of the gateway 192.168.1.1
It is necessary that the first computer can see the second computer when the VPN connection is enabled:

route –p add 192.168.1.0 mask 255.255.255.0 192.168.1.1

You can view the entire routing table with the command:

route print

Commands and keys:
route.exe routing routine;
add – add route command;
change – changes the route in the routing table;
delete – removes a route from the routing table;
gateway – parameter for specifying a gateway;
metric – a parameter that determines the priority from 1 to 9999, which is the cost metric for the route, 1 – the highest;
-f removes all routes from the routing table;
-p save key, without which the added route will disappear after rebooting the computer;
mask – subnet mask.

See also my article:
Configuring Network in Linux

Leave a comment

Leave a Reply