close
add-a-static-route-to-the-Windows-Routing-Table

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 Restart Windows’ Explorer.Exe Using Taskbar And Start Menu

How to Add Control Panel Shortcut to Windows 10 Right Click Menu

How to Take Screenshot of Complete Webpage With One Click

How To Make Adobe PDF And Sumatra PDF Readers To Restore Last Opened Files

How To Access The Most Recently Opened Documents In MS Word 2016

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.

For this

  • Open up Command Prompt or hit Windows+X
  • Select Command Prompt (Admin)
how to add route in windows 7

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
add static route windows server 2012 r2

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 
route add windows 10

Now, again give route print command to see your windows table again, you will see a new static route to table

route add command in windows 7

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.

Congratulation!

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  
how to delete a static route from the windows routing table

Let’s check with the “route print”  command in the command prompt either the route has been deleted or not?

how to delete a static route from the windows routing table 2

Wow!

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.

Tags : add a static TCP/IP route to the Windows Routing Table
Imran Chandio

The author Imran Chandio

1 Comment

  1. I discovered your How to Add a Static TCP/IP Route to the Windows Routing Table page and noticed you could have a lot more traffic. I have found that the key to running a website is making sure the visitors you are getting are interested in your subject matter. We can send you targeted traffic and we let you try it for free. Get over 1,000 targeted visitors per day to your website. Check it out here: http://0nulu.com/csy Unsubscribe here: http://0nulu.com/nbz

Leave a Response