This tutorial explains how to configure static routing on routers. Learn how to create and manage static routes on routers through a packet tracer example.
Static routes are the routes you manually add to the router’s routing table. The process of adding static routes to the routing table is known as static routing. Let’s take a packet tracer example to understand how to use static routing to create and add a static route to the routing table.
Setting up a practice lab
Create a packet tracer lab as shown in the following image or download the following pre-created lab and load it on Packet Tracer.
Packet Tracer Lab with Initial IP Configuration
In this lab, each network has two routes to reach. We will configure one route as the main route and another route as the backup route. If the link bandwidth of all routes is the same, we use the route that has the least number of routers as the main route. If the link bandwidth and the number of routers are the same, we can use any route as the main route and another route as the backup route.
If we specify two routes for the same destination, the router automatically selects the best route for the destination and adds the route to the routing table. If you manually want to select a route that the router should add to the routing table, you have to set the AD value of the route lower than other routes. For example, if you use the following commands to create two static routes for network 30.0.0/8, the route will place the first route to the routing table.
#ip route 30.0.0.0 255.0.0.0 20.0.0.2 10 #ip route 30.0.0.0 255.0.0.0 40.0.0.2 20
If the first route fails, the router automatically adds the second route to the routing table.
Creating, adding, verifying static routes
Routers automatically learn their connected networks. We only need to add routes for the networks that are not available on the router’s interfaces. For example, network 10.0.0.0/8, 20.0.0.0/8 and 40.0.0.0/8 are directly connected to Router0. Thus, we don’t need to configure routes for these networks. Network 30.0.0.0/8 and network 50.0.0.0/8 are not available on Router0. We have to create and add routes only for these networks.
The following table lists the connected networks of each router.
Router | Available networks on local interfaces | Networks available on other routers’ interfaces |
Router0 | 10.0.0.0/8, 20.0.0.0/8, 40.0.0.0/8 | 30.0.0.0/8, 50.0.0.0/8 |
Router1 | 20.0.0.0/8, 30.0.0.0/8, 50.0.0.0/8 | 10.0.0.0/8, 40.0.0.0/8 |
Router2 | 40.0.0.0/8, 50.0.0.0/8 | 10.0.0.0/8, 20.0.0.0/8, 30.0.0.0/8 |
Let's create static routes on each router for networks that are not available on the router.
Router0 requirements
- Create two routes for network 30.0.0.0/8 and configure the first route (via -Router1) as the main route and the second route (via-Router2) as a backup route.
- Create two routes for the host 30.0.0.100/8 and configure the first route (via -Router2) as the main route and the second route (via-Router1) as a backup route.
- Create two routes for network 50.0.0.0/8 and configure the first route (via -Router2) as the main route and the second route (via-Router1) as a backup route.
- Verify the router adds only main routes to the routing table.
Router0 configuration
Access the CLI prompt of Router0 and run the following commands.
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 30.0.0.0 255.0.0.0 20.0.0.2 10 Router(config)#ip route 30.0.0.0 255.0.0.0 40.0.0.2 20 Router(config)#ip route 30.0.0.100 255.255.255.255 40.0.0.2 10 Router(config)#ip route 30.0.0.100 255.255.255.255 20.0.0.2 20 Router(config)#ip route 50.0.0.0 255.0.0.0 40.0.0.2 10 Router(config)#ip route 50.0.0.0 255.0.0.0 20.0.0.2 20 Router(config)#exit Router#show ip route static 30.0.0.0/8 is variably subnetted, 2 subnets, 2 masks S 30.0.0.0/8 [10/0] via 20.0.0.2 S 30.0.0.100/32 [10/0] via 40.0.0.2 S 50.0.0.0/8 [10/0] via 40.0.0.2 Router#
Router1 requirements
- Create two routes for network 10.0.0.0/8 and configure the first route (via -Router0) as the main route and the second route (via-Router1) as a backup route.
- Create two routes for network 40.0.0.0/8 and configure the first route (via -Router0) as the main route and the second route (via-Router2) as a backup route.
- Verify the router adds only main routes to the routing table.
Router1 configuration
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 10.0.0.0 255.0.0.0 20.0.0.1 10 Router(config)#ip route 10.0.0.0 255.0.0.0 50.0.0.1 20 Router(config)#ip route 40.0.0.0 255.0.0.0 20.0.0.1 10 Router(config)#ip route 40.0.0.0 255.0.0.0 50.0.0.1 20 Router(config)#exit Router#show ip route static S 10.0.0.0/8 [10/0] via 20.0.0.1 S 40.0.0.0/8 [10/0] via 20.0.0.1 Router#
Router2 requirements
Create static routes for network 10.0.0.0/8 and network 30.0.0.0/8 and verify the router adds both routes to the routing table.
Router2 configuration
Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip route 10.0.0.0 255.0.0.0 40.0.0.1 Router(config)#ip route 30.0.0.0 255.0.0.0 50.0.0.2 Router(config)#exit Router#show ip route static S 10.0.0.0/8 [1/0] via 40.0.0.1 S 30.0.0.0/8 [1/0] via 50.0.0.2 Router#
Verifying static routing
On Router0, we configured two routes for network 30.0.0.0/8. These routes are via Router1 and via Router2. We set the first route (via-Router1) as the main route and the second route as the backup route. We can verify this configuration in two ways.
By sending ping requests to a PC of network 30.0.0.0/8 and tracing the path they take to reach the network 30.0.0.0/8. For this, you can use 'tracert' command on a PC of network 10.0.0.0/8. The 'tracert' command sends ping requests to the destination host and tracks the path they take to reach the destination.
By listing the routing table entries on Router0. Since a router uses the routing table to forward data packets, you can check the routing table to figure out the route the router uses to forward data packets for each destination.
The following image shows the above testing.
We also configured a separate static host route for the host 30.0.0.100/8. The router must use this route to forward data packets to the host 30.0.0.100/8. To verify this, you can do the same testing for the host 30.0.0.100/8.
The following image shows this testing.
We also configured a backup route for network 30.0.0.0/8. The router must put the backup route to the routing table and use it to forward data packets to network 30.0.0.0/8 when the main route fails. To verify this, we have to simulate the failure of the main route.
To simulate the failure of the main route, you can delete the link between Router0 and Router1. After deleting the link, do the same testing again for the network 30.0.0.0/8.
The following link provides the configured packet tracer lab of the above example.
Packet Tracer Lab with Static Routing Configuration
Deleting a static route
To delete a static route, use the following steps.
- Use the 'show ip route static' command to print all static routes.
- Note down the route you want to delete.
- Use the 'no ip route' command to delete the route.
If you have a backup route, the backup route becomes the main route when you delete the main route.
In our example, we have a backup route and a main route for the host 30.0.0.100/8. The following image shows how to delete both routes.
That’s all for this tutorial. In this tutorial, we discussed static routing and learned how to create, add, and manage static routes on the router.