Have you ever wondered how data travels from one source to the other? There are several nodes in a network, so how do you think your data manages to reach the chosen destination in a short time? Well! Networks employ a system called routing that helps find the best path to transfer your data from one device on your network to another.
Routing is a hub around which all IP connections resolve. Each Windows operating system has a built-in routing protocol that aids in making the right routing decision for transferring data packets. It establishes basic internetwork communications and examines every possible path that the data packet can take across a network to reach the final destination.
Overall, routing procedures can improve your performance and ensure that the network runs efficiently.
Here we will talk about routing in detail – how it works, why choose static routing, what is routing table then show you how to add a static route using a Powershell.
What is Routing?
Routing is the process of choosing a pathway to deliver a message to a recipient. The practice applies to any network right from telephone networks to public transportation. It can be done through different methods, such as it can be manually set up or updated automatically, i.e., routing changes over time.
In computer networking, a device named a router connects computing devices and networks to several networks. It helps perform the job by choosing the best path for data packets to reach the final node. The role of a router is to read the heading of the received data packet stating its final destination, cross-check the details with the routing table entries, and determine the best path to transfer the message to the recipient.
Static, Dynamic, and Default routing are the three different types of the routing table. Under the static routing table, only the administrator can manually set up or update any changes. In the case of a dynamic routing table, it requires more computing power and updates automatically. They usually choose the shortest and fastest path to transfer data packets to the final node.
The routing process usually forwards the messages based on the routing tables and using some predetermined rules.
Routing provides faster access to data, prevents bandwidth overload, and immediately looks for another pathway for data to take if a node is unavailable. There are various benefits of routing that can create a good impact on your network’s performance.
Why Should We Add Static Routes?
In most cases, small networks prefer static routing over dynamic routing for the administrator to manually update them. While medium and large-sized networks often choose the dynamic routing process because they find it more efficient.
Here we have listed a few situations under which it is best to implement static routes for your network.
- There are cases when routes cannot be added to a default gateway device. Generally, the condition occurs due to security considerations, and you need to switch to other routing devices to transfer the data packet to the final node. The best solution is to configure a local Windows computer and continue performing the necessary routing functions.
- Static routes are highly useful when you want to direct traffic to a particular subnet or set up multiple subnets or VLANs on your network.
- In case you want to use two different internet routers for sending traffic. For instance, the primary router for sending all other traffic and the secondary for sending social media or video streaming services traffic.
- To get better control of the routing table or traffic workflow when using a Windows PC as a router.
In simple terms, static routes are best for cases when you have multiple routers or multiple IP subnets on your network.
Static Routes help route packets from an interface to a destination address and are best applied where the routing protocol cannot be used, and traffic must be routed manually. For example, when a link goes down between two routers or when a router fails, Static Routes can be configured on the router that has the link with the failed router so that it will know which interface to use next in order to reach its destination.
How Does Routing Work?
Routing is the process of establishing a path to transfer messages from one point to another. It may be necessary when there is more than one possible path between two devices, or when the network topology changes and an alternate route is needed.
Routing is used in networks with dynamic topologies, where nodes may come and go over time. In these networks, it’s not always possible for every node to know every other node in the network. It means that routing protocols must exist in order for nodes within a network to communicate with each other and find paths through the network that allows them to connect with their desired destination node.
Routing can be done in two ways:
- Static routing, where the routing is predetermined and does not change over time. To be more precise, only the administrator can manually set up or update any changes.
- Dynamic routing, where the routing changes over time. It requires more computing power and updates automatically.
What is a Routing Table?
A routing table, also called a routing protocol, is a data structure used to find out routes for IP packets in a TCP/IP packet. Organizations use these tables, which are often stored on routers, to understand how sites are plugged together and how traffic moves through them.
Routing tables are responsible for determining the best path for the data packet when sent from a device. They are a set of rules that act like a map and direct the right path over an Internet Protocol network. It carries information related to the arrangement of a communication network that aids in delivering a message to the recipient.
Each device has a routing table that manages and controls packet paths with the router, firewalls, and layer 3 switches. The communication network arrangements provided by the routing table help in discovering the next hop or the best path to transfer a data packet to the final node.
Users can maintain a routing table manually or dynamically based on different occasions. It is important to know where to send data before dispatching the data packet.
If the network device finds it difficult to connect directly to the destination device, it uses other devices along a route to the destination device. To track each way and choose the best path to deliver various packets of data, it uses a routing table.
View Routing Table in Windows
In the Windows system, you can view the routing table using the PowerShell.
To view a routing table:
- Go to the Windows search bar and type ‘Powershell’.
- Open the app and run it as administrator.
- Once the command prompt opens, enter the route print command to view the routing table.
You should see the routing table in the following screen:
Add a Static Route Using a Powershell CMDLET
The basic syntax to add a static route to a routing table in a Windows-based routing device as shown below:
route /f /p [command] [destination] [mask <netmask>] [gateway] [metric <metric>]] [if <interface>]
A brief explanation of each option is given below:
- /f – Clear an existing routing table.
- /p – Add the new routing table permanently.
- command – Here, you can use add, change, and delete commands as per your need.
- destination – Define destination network.
- mask netmask – Define the subnet mask of the destination network.
- gateway – Define the gateway IP address.
- metric – Identify an integer cost metric.
- if interface – Define the network interface name.
If you want to add a static route to the destination 172.16.0.0 with the subnet mask of 255.255.0.0 and the following hop address of 172.16.0.1, open your PowerShell and run the following command:
route /p add 172.16.0.0 mask 255.255.0.0 172.16.0.1 if 0x2
You can now run the following command to verify the newly added static route:
Delete a Static Route
You can also delete a specific route or all routes using the route command.
For example, to remove all static routes, run the following command:
If you want to remove a specific route, run the following command followed by route IP:
route /p delete 172.16.0.0 mask 255.255.0.0 172.16.0.1 if 0x2
In this guide, we introduced static routing, routing table, then explained how to add and remove a static route using the PowerShell CMDLET. We also showed you how to see the added route using the route print command. I hope this post will help you better understand the concept of the static route and how to set it up in Windows systems.