How to Add a Static TCP/IP Route to the Windows Routing Table
There come multiple scenarios in which you have to add a static route to the Windows Routing Table. Here’s how you can do it.
A routing table is the one which performs routing of the packets or simply an indexing of multiple routes with the instructions where all these packets will go when they leave a system. Whether it’s a physical router or a PC.
Most of the routers, including the built-in Windows PC router, use dynamic routing. As the router is an intelligent device and it selects the best route while sending packets.
You can look out everything in-depth detail with “traceroute” command that will show you all the connections a packet make and finally reaches its final destination.
Let’s try to understand somehow, what is static route?
A static route is the one, which is not updated dynamically.
Sometimes you want to add some certain traffic from your company/home router or gateway then we add a static route.
Almost all the routers allow us to add a static route to pass a certain traffic.
Most people use windows PC at home just like me and want to add a static TCP/IP route to the Windows Routing Table.
For this, let’s take a scenario
You have two internet connections, one is for your regular use and the other is for official working. Now you want to send/receive some traffic to a certain IP address range using only one internet connection.
You also have done subnetting on your network and want to send traffic to a certain subnet.
Then static routes are most useful in such testing environment.
You also want your Windows PC should be used as a router for your network and you want an overall control over it.
If you are facing any of the above situation then this article is for you.
Stay with me!
We will simply use the command prompt to add a static route to Windows routing table.
The Fanman Show recommended articles for you.
How to View the Windows Routing Table
Before starting to add a static TCP/IP route to the Windows Routing Table, it is necessary for judgment to view the routing table first.
- Open up Command Prompt or hit Windows+X
- Select Command Prompt (Admin)
Note:- If you see PowerShell, instead of Command Prompt on the power user menu, then you don’t need to worry about, you can use PowerShell as you use the command prompt. The functionality of the both is same.
After opening the Command Prompt, type the following command and hit Enter:
route print You will be followed by
You can see the list of the network with destinations and the default gateways in the above Windows PC routing table to which packets are forwarded whenever they are sent to some destination. It is the default gateway which forward all type of information to specific destinations.
Now let’s add a static TCP/IP route to the Windows Routing Table
Add a Static Route to the Windows Routing Table
To add a static route to the table, You need to type the following command as according to the syntax.route ADD destination_network MASK subnet_mask gateway_ip metric_cost
The subnet mask and the cost metrics are optional to the command. If you do not mention the subnet mask then it will take a Class C subnet mask that is 255.255.255.0 automatically.
Also if you do not provide metric cost, a cost one greater than the 0.0.0.0 destination entry will be used
The cost metric value is used when Windows has to decide to select the best path among the all the routes pointing towards the same destination.
For, example, you wanted to add a Static Route to the Windows Routing Table saying that all the traffic should merge at 192.168.20.0 subnet through the gateway 192.168.0.3 with automatic metric cost.
Then, again you need to write another command at the command prompt.route ADD 192.168.20.0 MASK 255.255.255.0 192.168.0.3
Now, again give route print command to see your windows table again, you will see a new static route to table
where 192.168.20.0 is the network destination, 255.255.255.0 is the network mask specifying class C IP address and 192.168.0.3 is the default gateway or the router’s IP address with 56 metric cost.
You have added a Static Route to the Windows Routing Table.
But there is something other necessary to know about in order to add a static route to the windows routing table and that is:
When you add a static route, with by default behavior its session end until the next restart of your Windows PC.
Because many major companies use a coordinated list of static routes that are often updated.
Instead of adding static routes every time on every machine, they use a batch script file that adds all the latest routes at the time of Windows startup. This technique keeps the windows routing table stable and organized.
You can write the batch script with your own hands. Because writing script is an easy job to do.
But if your network is so small or you are a home user and you want to add just a few static routes to your windows routing table then you can add the –p option to the command to make the route persistent.
A persistent route is the one, which stays in place when the windows starts up.
Here’s how you can add a static route to the windows routing table and make that route persistent.route -p ADD 192.168.20.0 MASK 255.255.255.0 192.168.0.3
How to Delete a Static Route from the Windows Routing Table
Once you add a static route to the windows routing table, it can be easily deleted. Because in future, maybe you don’t need it and you have to remove it.
Then here’s the following syntax to remember how to delete a static route from the windows routing table.route delete destination_network
So, to delete the static route we have created so far with the destination network 192.168.20.0, all we’d have to do is type this command and hit Enter:
So, this is the static route, 192.168.20.0, we have just added to the windows routing table, now let’s delete it by entering the following command at the command prompt.route delete 192.168.20.0
Let’s check with the “route print” command in the command prompt either the route has been deleted or not?
You can see the above table there is no static route entry because it has been deleted with the typed command.
Static routes are used for testing and other multiple-purpose at home or in every small and large scale organizations networks. Use it with your own consent.
We have learned “how to add a static TCP/IP route to the Windows Routing” and also how to delete a static route from the windows routing table.
Share it with your friends and your thoughts with us through the comments section that how it was helpful for you.