Did you know Windows wants to be a router too?
Indeed, any device that relies on TCP/IP for network communications has a routing table – including Windows.
Go ahead and open a command prompt and type:
he output is divided into three sections:
- Interfaces List
- IPv4 Route Table
- IPv6 Route Table
The Interfaces List enumerates all your interfaces by MAC address and the next two sections list your dynamic and persistent routes for IPv4 and IPv6.
Each line under Active Routes is a TCP/IP route to a network or a specific device on the network.
To add a route we use the route ADD command to tell Windows which Network to add and then we enter the Subnet mask and Gateway.
But why would you ever add a static route in the first place? People often add static routes when troubleshooting routing related problems. For example, maybe you can’t ping a workstation from a server or perhaps can successfully ping that workstation but the ICMP echo reply chronically times out. Sometimes we can isolate networking problems like this by manually entering a known route. That’s where static routes come in.
So let’s say we’re on the 172.16.100.0 network and the default gateway is 172.16.100.1 and we want to add static route to our management VLAN located on the 184.108.40.206 network.
Assuming our subnet mask is 255.255.248.0 we could add the route like this:
route ADD 220.127.116.11 MASK 255.255.248.0 172.16.100.1
The format is as follows:
route ADD this network with this mask via this gateway IP.
The only drawback to this method is that after you reboot your static route will go poof!
In order to make it stay we need to make it persistent with the -p modifier. So just add a -p to the end of the route and it’ll be permanent.
route ADD 18.104.22.168 MASK 255.255.248.0 172.16.100.1 -p
If later you decide to remove the static route, you can use route DELETE followed by the destination network IP.
route DELETE 22.214.171.124
Alternatively, if you want to add multiple routes, for fault tolerance in the event you have a failure, you can do the following:
(Obviously for this to work, you’d need two networks and two network adapter’s connected to your Windows PC/Server/VM)
route ADD 126.96.36.199 MASK 255.255.248.0 172.16.100.1 Metric 1 -proute ADD 172.16.25.0 MASK 255.255.254.0 172.16.101.1 Metric 2 -p
Additionally, if you have multiple Network Adapter’s being used you can also specify which interface card to use, When you do the “Route Print” command you will notice at the top a field called “Interface List”, on the left there is a number followed by a bunch of ….. – that number is the interface number. So say for instance you have 3 Network Adapter’s, each one would have there own number on the left, you would assign them to the route to make sure all traffic for the subnet on that Network Adapter to flow out of that Network Card, as shown below:
route ADD 188.8.131.52 MASK 255.255.248.0 172.16.100.1 Metric 1 IF 11 -proute ADD 172.16.25.0 MASK 255.255.254.0 172.16.101.1 Metric 2 IF 22 -p
This can be very useful in a VMware VM setting where you have multiple VMXNET3 or E1000 Virtual Nic’s and you want to make sure the traffic flows out the correct interface towards the correct subnet on a specific vLAN. However this can also be useful in Linux too, I just don’t have those commands but the concept is the same.
Hope this helps someone else out, as this helps me out from time to time.