How to Add a Static TCP/IP Route to the Windows Routing Table

Route Table Header

In some specific types of environments, you might find it useful to add a static route to the routing table. Here’s how to go about it in Windows 11, 10, 8, and 7.

RELATED: How to Use Traceroute to Identify Network Problems

What Are Routing Tables?

A routing table dictates where all packets go when they leave a system — whether that system is a physical router or a PC. Most routers — including the one built into your Windows PC — use some form of dynamic routing, where the router is capable of selecting the best place to forward packets based on information it gets from other routers. You can see it at work if you use the traceroute command to watch the connections a packet makes as it reaches it’s final destination.

Most routers also allow you to add a static route (one that doesn’t get dynamically updated) if you want to always forward certain traffic to a specific router or gateway. Why? Well, most people using Windows in their home or small business probably won’t — but this can be useful under certain circumstances, such as:

  • You have two internet connections — maybe one for regular use and one for connecting to a work network — and you want all traffic to a certain IP address range to go out over one of those connections.
  • You have set up multiple subnets on your network and need to direct traffic to a particular subnet. Static routes can be particular useful in testing these types of environments.
  • You’re actually using a Windows PC as a router for your network and you want finer control over it.

If any of those apply to you, read on. You’ll need to dive into the Command Prompt to add a static route to the Windows routing table, but it’s easy and we’ll walk you through the steps.

View the Windows Routing Table

Before you get started adding routes, it may be helpful to view the routing table first. Fire up Command Prompt by hitting Windows+X and then selecting “Command Prompt (Admin)” on the Power Users menu.

Run Command Prompt as an Administrator through the Poweruser Menu.

Note: If you see PowerShell instead of Command Prompt on the Power Users menu, that’s a switch that came about with the Creators Update for Windows 10. It’s very easy to switch back to showing the Command Prompt on the Power Users menu if you want, or you can give PowerShell a try. You can do pretty much everything in PowerShell that you can do in Command Prompt, plus a lot of other useful things.

RELATED: How to Put the Command Prompt Back on the Windows+X Power Users Menu

At the Command Prompt, type the following command and hit Enter:

route print

You’ll see a long list of network destinations and the gateways to which packets are forwarded when they are headed to that destination. Unless you’ve already added static routes to the table, everything you see here will be dynamically generated.

Add a Static Route to the Windows Routing Table

To add a static route to the table, you’ll type a command using the following syntax:

route ADD destination_network MASK subnet_mask  gateway_ip metric_cost

The subnet_mask and metric_cost components are optional to the command. If you don’t specify a subnet mask, 255.255.255.0 will be used automatically. If you don’t specify a metric cost, a cost one greater than the 0.0.0.0 destination entry will be used. The metric cost value is just a cost that is relative to other costs in the table and is used when Windows decides between multiple routes that could reach the same destination.

So, for example, if you wanted to add a route specifying that all traffic bound for the 192.168.35.0 subnet went to a gateway at 192.168.0.2 and you just wanted to use the automatic metric cost, you would use the following command:

route ADD 192.168.35.0 MASK 255.255.255.0 192.168.0.2

If you were to use the route print command to look at the table now, you’d see your new static route.

Type

That’s all easy enough, but there is one extra little catch. When you add a static route, by default it only lasts until the next time you start Windows. The reason for this is that many companies use a coordinated list of static routes that gets updated fairly often. Rather than adding and updating all those routes on every machine, they just distribute a batch script file that adds the newest routes during Windows startup. This keeps the routing table relatively uncluttered.

RELATED: How to Write a Batch Script on Windows

You could certainly use the batch script method yourself. Writing batch scripts isn’t hard. But if you’re just adding one or two static routes that you don’t expect to change often, you can instead just add the -p option to the command to make the route persistent. A persistent route stays in place even when Windows starts up. Using the same command we used earlier, you could make that route persistent with the following modification:

route -p ADD 192.168.35.0 MASK 255.255.255.0 192.168.0.2

Adding

Remove a Static Route from the Windows Routing Table

Of course, there will come a time you might want to remove a static route from your table. All you have to do is type a command using the following syntax:

route delete destination_network

So, to delete the route we created earlier 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

Type


Yes, using static routes is a bit esoteric when it comes to managing most home and small business networks. But if you do need to do it, it’s a pretty easy process. And if you don’t need to do it right now, at least you know it’s an option in the future.

Note: This article have been indexed to our site. We do not claim legitimacy, ownership or copyright of any of the content above. To see the article at original source Click Here

Related Posts
6 books about the UK to read this summer thumbnail

6 books about the UK to read this summer

TravelExplore our lakes, beaches and bays with these perfect reads for a summer staycation.Published July 9, 20233 min readThis article was produced by National Geographic Traveller (UK).1. The Seaside: England’s Love Affair, Granta, £20.Journeying around the country, from Scarborough to Blackpool, Madeleine Bunting aims to understand the enduring appeal of seaside resorts, many faded from
Read More
Charles Babbage’s Difference Engine Turns 200 thumbnail

Charles Babbage’s Difference Engine Turns 200

It was an idea born of frustration, or at least that’s how Charles Babbage would later recall the events of the summer of 1821. That fateful summer, Babbage and his friend and fellow mathematician John Herschel were in England editing astronomical tables. Both men were founding members of the Royal Astronomical Society, but editing astronomical…
Read More
Detect Solar Flares and Gamma-Ray Bursts for Less Than $100 thumbnail

Detect Solar Flares and Gamma-Ray Bursts for Less Than $100

Derek Smith’s method of mapping viral antigens was first used to track how flu strains were changing. James King-Holmes/Science Source Genetic sequencing gives researchers early clues about those changes, but only laboratory and clinical testing can indicate what they mean for the human immune system and current vaccines. To that end, scientists around the world…
Read More
New Research Challenges Long-Held Views on Brain Processing thumbnail

New Research Challenges Long-Held Views on Brain Processing

Recent research reveals that body movements, specifically whisking in mice, modulate sensory processing in the brain differently than previously thought, challenging the established role of motor cortices. This discovery, which highlights the significant impact of secondary sensory and thalamus inputs, could revolutionize the development of technologies mimicking human sensory-motor integration.Scientists have revealed a new understanding
Read More
Index Of News
Consider making some contribution to keep us going. We are donation based team who works to bring the best content to the readers. Every donation matters.
Donate Now

Subscription Form

Liking our Index Of News so far? Would you like to subscribe to receive news updates daily?

Total
0
Share