Sometimes in the environment, we have multiple interfaces in windows or if we want to route the traffic from a specific interface we need to add routes in the IP route table of windows. Adding static IP routes in windows is easy and simple. Follow the below steps to add static routes in windows.
- Open Command Prompt with administrative access.
- Use “ipconfig” to identify the interface you want to use for routing.
- Use “route print” to check the routing in the windows routing table.
- Add Static route in windows.
1. Open Command prompt with administrative access.
To open command prompt with administrative access. Go to Windows and write cmd then right click on command prompt and choose option “Run as administrator”.
2. Use IPCONFIG to identify the interface you want to use for routing.
Now, First, we need to identify the interface which will be used for static IP routing.
To view, all the interface present in the windows use the below command-
c:\windows\system32> ipconfig
3. Use “route print” to check the routing in the windows routing table.
After identifying the interface use below command to check the current routing in the windows routing table.
c:\windows\system32> route print
4. Add a static route in Windows.
To add static route in windows we need to use below syntax where we need to provide network address and its mask and after mask we need to mention the gateway which will be used to forward the traffic.
route ADD destination_network MASK subnet_mask gateway_ip metric_cost
below is the example to route 192.168.35.0/24 network via 192.168.0.2
c:\windows\system32> route ADD 192.168.35.0 MASK 255.255.255.0 192.168.0.2
The subnet_mask
and metric_cost
components are optional to the command. once you add a static route in windows, you can use command route print to view the routing in windows.
To delete a static route from windows use below commands
route delete destination_network
To delete the route with the destination network 192.168.35.0, all we’d have to do is type this command and hit Enter:
route delete 192.168.35.0