How to configure Static Route | Windows | Linux

Hey, sometimes we have to configure a static route to connect to a network. Like routes, our host machine maintains its routing table. These routing tables are defined in the Operating System Kernel. In this article, we will discuss how we can configure a static route on different operating systems like Windows, Linux, etc.

What is Static Route

Static Route is a network route or network information, which can be configured on the router, firewall, or in Microsoft Windows, Linux to make the particular network reachable. Static Route uses next-hop IP address as a default route to reach that network. Likewise Router, also maintains their routing table, netmask, gateway, interface, and Metric to that network. By default, a default route is propagated, to the main network router or switch. The Routing Table of the Windows Operating System is given below:

Microsoft Windows Routing Table

As we discussed earlier in this article, a default route is present in the windows routing table. This default route has gateway, interface IP and Metric is 25.

Steps to configure Static Route on Windows Operating System

In this session, we will configure a static route on the Windows Operating System. Steps to configure a static route on windows given below:

  • Click on Start Menu, type cmd, right-click on it and choose open as administrator and open a command prompt.
  • Type to the following command to check the current status of the routing table:[terminal]route print[/terminal]
  • Now, add the following command to add a route in Windows routing table:[terminal] route add Static_Route_IP mask Subnet_Mask_of_Route Gateway¬†metric¬†30
    [/terminal] where Static_Route_IP is the IP address of route you want to add, Subnet_Mask_of_Route is the subnet mask of the route, and Gateway IP is the IP address of the next-hop IP address. Metric is used to define the priority of that route. Lower the matric, the higher the priority of the route. eg : [terminal]route add mask metric 15[/terminal]
Adding a static route in windows machine
  • Now, test your Windows machine routing table:[terminal]route print[/terminal]
Windows Routing Table

So, we have successfully configured the static route in the windows machine. The route added is a default route and the gateway to that route is However, you can see that there are various other routes available which are predefined as loopback address and other addresses.

How to configure Static Route in Linux (Ubuntu/Mint)

Now, we will configure the same static route on the Ubuntu operating system. Likewise, Windows Operating System, Routing Table of Linux operating system maintained by Kernel of the system. Below is the screenshot of the Linux Routing Table.

Linux Routing Table

Steps to Configure Static Route on Linux Operating System

Here, we will discuss how we can add a static route on Linux Machine. Just follow the given steps to add a route in Linux Machine.

  • First, open your terminal using a shortcut key (Alt+Ctrl+T) or using GUI (Graphical User Interface).
  • Type the following command using root privileges:[terminal]sudo route add -net ROUTE/ROUTE_NETMASK gw GATEWAY_IP metric METRIC[/terminal]where Route is the network you want to add and ROUTE_NETMASK is the netmask of the network. GATEWAY_IP is the IP address of the next-hop address. Like windows, Metric is used to define the priority of the route. Lower the metric higher priority of that route. So, In my case this command will be:[terminal]sudo route add -net gw metric 25[/terminal].
  • Now, we verify our configuration with the following command. [terminal]ruote -n[/terminal]
Ubuntu Routing Table

Thus, we verify that a static route of network is configured in Linux Machine Routing Table, which is via and its metric is 25.


In this article, we discussed how we can configure a static route on Microsoft Windows and Linux (Ubuntu/Mint) machines. However, the routing table is stored in the system kernel of both the operating system. The default route can be configured with the help of a static route.

Related Articles

Did you find this article helpful! Please leave a comment in comment box.


  1. If you use an FQDN as a static route next hop, that FQDN must resolve to an IP address that belongs to the same subnet as the interface you configured for the static route; otherwise, the firewall rejects the resolution and the FQDN remains unresolved.

    1. I agree with you! You can configure local DNS entry for the next-hop FQDN. If you are using Linux just access /etc/hosts and configure the FQDN! Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *