How to Add or Remove a Static Route on Windows

How to Add or Remove Static Route on Windows blog banner image

Static routes define fixed paths for network traffic that would otherwise have their path calculated automatically. This guide explains static routes, why you would use them, and provides step-by-step instructions showing how to add and remove static routes on Windows. It also looks at adding persistent routes and other tips for network management on Windows.

Get full control over your Windows networks with NinjaOne’s powerful endpoint management tools.

Try it for free.

What are static routes?

In computer networking, a “route” is the path network packets take to reach their destination. Data from your computer is broken into small packets for transfer over the local network (for example, between your computer and wireless printer), or for transmission over the internet (such as when you submit an online form). Network routing then takes care of making sure all of these packets reach their destination where they can be re-assembled into the original complete message.

Computer networks are designed in this way so that if there’s a disruption somewhere in the network, packets can be re-routed through a different connection. When there is no disruption, routing protocols can optimize for efficiency, sending data through different paths simultaneously to improve speed.

The key components in network routing are:

  • Routing table: This is where each device (including your Windows PC) stores the information about the routes to different destinations.
  • Next hop: Most network routes need to cover large distances over complex networks. The “next hop” is the next stop along the path to the destination (for example, there is a hop between your PC and a wireless printer — packets need to go first to your Wi-Fi router, then your printer).
  • Routing protocols and metrics: Routing protocols are the software that is used by network devices to keep routing tables up-to-date with the latest paths data should take. This is done based on the number of hops, bandwidth, and/or latency.

Usually, routes are automatically calculated by the routing protocol and stored in a routing table based on routing metrics. These dynamic routes change based on network conditions. The default route can be set for all traffic with no route otherwise assigned in the routing table.

Static routes can be manually configured in a devices routing table, to set fixed paths traffic should take instead of dynamic routes or the default route. If this route is broken, traffic will not be able to reach the destination and a dynamic alternate route will not be calculated.

Why do you need to use static routes?

In some situations, the dynamic route is not the route you want specific traffic to take. You may want to take a known optimal route or send traffic along a secure connection. Example use-cases for static routes include:

  • Sending traffic via a known reliable route that avoids faulty networking conditions that are outside your control or that fully utilizes a better connection for optimization.
  • Building efficient networks using low-power devices that do not need to run routing protocols.
  • Maintaining full control over the path network traffic takes for optimization or to ensure protected data only travels over your secure network infrastructure.
  • Ensuring network traffic takes a predictable path for troubleshooting or easier management.
  • Adding redundancy and resiliency to your networks by providing a known alternative path as a fallback to dynamic routes.

Static routes are frequently used to ensure certain traffic is sent over a VPN connection. This can be important when you handle sensitive data that you do not want routed over the internet. While static routes are usually not required for day-to-day tasks on home Windows PCs, there are situations where they are added for troubleshooting or to set up remote networks for work-from-home setups.

IP addresses and network masks

Route tables use the IPV4 or IPV6 IP address of the destination and hops to identify routes. You’ll need a basic understanding of IP addresses and network masks to write effective static routes.

How to use the route command for Windows

The route command is built-in to Windows and lets you view currently set static routes, as well as adding, removing, and editing them. The route command is available in all versions of Windows including Windows 11, Windows 10, and Windows Server. The route command can be run from either the Command Prompt or PowerShell, and needs to be run as an administrator.

To open PowerShell or the Command Prompt to use the route command, right-click on the Start menu, and then:

  • Click Terminal (Admin) if you’re using Windows 11
  • Click Command Prompt (Admin) if you’re using Windows 10

How to list static routes on Windows

To list the existing static routes, enter the following command:

route print

This will output the current route table, showing all the currently configured static routes. You can use this command to verify that you’ve successfully added, removed, or edited a static route.

How to add a static route on Windows

The below example route command adds a static route:

route add 0.0.0.0 mask 0.0.0.0 192.168.77.1

The command is constructed as follows:

  • The route executable is called.
  • The add command tells it to add a static route to the routing table.
  • The first 0.0.0.0 is the destination network. In this case, 0.0.0.0 matches all networks.
  • The second 0.0.0.0 specifies the subnet mask this static route should apply to, in this case again matching all subnets.
  • 192.168.77.1 specifies the gateway address. This is the next hop through which all matching traffic will be sent.

This static route sends all network traffic to 192.168.77.1, effectively adding a default route.

The next example adds a route to a specific network:

route add 192.168.10.0 mask 255.255.255.0 192.168.77.1

The command differs from the previous example:

  • 192.168.10.0 is the destination network.
  • 255.255.255.0 specifies the subnet mask this static route should apply to, in this case matching all addresses in the 192.168.10.0 subnet.
  • 192.168.77.1 specifies the gateway address. This is the next hop through which all matching traffic will be sent.

In effect, this static route sends traffic destined for the 192.168.10.0 network to 192.168.77.1.

How to remove a static route on Windows

To delete a static route, use the route delete command, and match the details with the static route you wish to delete.

route delete 0.0.0.0 mask 0.0.0.0 192.168.77.1

The above command deletes the static route created in the previous step.

How to remove all static routes on Windows

To delete all static routes on Windows, use the command:

route -f 

Make a static route permanent/persistent on Windows

Static routes will be cleared from the route table on Windows when you reboot. To make a persistent route — one that is permanent and will survive a reboot — add the -p parameter to your route add command:

route -p add 0.0.0.0 mask 0.0.0.0 192.168.77.1

Troubleshooting and best practices for managing static routes

If you are manually managing static routes on Windows machines, you should document which routes are set on which machines to avoid a forgotten static route, causing a troubleshooting issue.

You should also regularly review which static routes are set (this can be done using the route print command in Windows), and remove ones that are no longer required. Network monitoring solutions will assist with identifying network changes and broken routes that may need to be addressed.

If you are working in an enterprise environment with multiple devices that all require the same static routes, you should implement them at the network level rather than per device.

Windows route management tools

In addition to the route command that is built into Windows, you can use the following tools to manage routes and perform other networking tasks on Windows:

  • NetRouteView is a free routing utility for Windows that provides a graphical interface for viewing, adding, and modifying static routes.
  • Angry IP Scanner and Advanced IP Scanner can help you find and identify devices on your local network, and manage static routes on connected Windows devices by executing remote commands or scripts.

Effortlessly manage your Windows networks with NinjaOne’s time-saving automations and comprehensive control over devices.

➤ Find out more.

Managing large Windows networks efficiently

If you need to manage static routes on a fleet of Windows devices, either on a single network or in bring-your-own-device (BYOD) scenarios with traveling or remote employees, you shouldn’t rely on manually adding static routes and other network configurations to individual devices.

The NinjaOne remote management and monitoring platform (RMM) helps you secure, manage, and monitor Windows devices at scale, ensuring that they are all correctly configured. This allows you to deploy updated networking and security policies from a centralized interface, removing the time-consuming tasks of updating, cataloging, and enforcing static routes and other policies.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service deliver tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about Ninja Endpoint Management, check out a live tour, or start your free trial of the NinjaOne platform.

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).