Static Routes in the Cisco IOS

As a network administrator, you must be able to configure your routers to route traffic across the network. Static routes are commonly used on routers to accomplish this. For a network admin, knowing how to use a static route is a requirement. Let’s learn about static routes, and how to properly use them.

Static vs. Dynamic

There are two types of routing that can be configured on a network device- static and dynamic. Static routes are hard-coded on a network device. They tell the device exactly where to send traffic, no matter what. Dynamic routes, on the other hand, use a routing protocol to determine the best path. If one route becomes less preferred, the route being used may change. With dynamic routes, routes communicate with each other and exchange routing information. Examples of dynamic routing protocols are RIP, EIGRP, OSPF, and BGP.

Basics of Static Routes

Now that you know the difference between static and dynamic routes, let’s learn the basics of static routes. When there are two or more routes to the same destination, routers use administrative distance to decide which routing protocol (or static route) to trust more. For example, here are some administrative distances (the lower the number, the more trustworthy the type of route is): – Static Route to a connected interface = 0 – Static Route to a IP address = 1 – Internal EIGRP = 90 – OSPF = 110 – RIP = 120

Because of how administrative distance works, when you enter static routes that are the same as a dynamic route (learned from another router), your static route will be used over the dynamic route. As you may be overriding routes manually, you must make sure your routes are accurate.

As you may have noticed above, there are static routes that point to an interface on the router, and static routes that point to an IP address on the network. For example, a static route to an interface may tell a router “send all traffic going to X network out interface Ethernet0/0”. A static route to an IP address may tell a router “send all traffic going to X network to IP address 1.1.1.1”. Either of these types of routes can be used, depending on the situation.

There is a special kind of static route called a default route. Sometimes a default route is called a “zero / zero” route. This is because the network and subnet you are specifying, as the destination for the traffic it would match, are all zeros. A default route says “for any traffic that does not match a specific route in the routing table, send that traffic to this destination”. In other words, a default route is a “catch-all”.

The syntax for the global configuration command used to enter a static route is: ip route {destination prefix} {destination prefix mask} {interface OR forwarding router’s IP address}

For example, a static route sending all traffic out Serial 0/0 would look like this:

 

A specific route, sending traffic going to network 10.10.10.0, to router 1.1.1.1, would look like this:

 

Once these routes are configured, you can use the show ip route command to see the routing table:

 

Notice in this output the static routes being with an S on the left-hand side. You can see our two static routes 10.10.10.0, and 0.0.0.0/0. You can also see our connected interfaces (shown with a C). As a side-note, the show ip route command can be abbreviated sh ip ro.

Real-World Example of using Static Routes

Now that we understand the basics of using static routes, let me provide a real-world example. Say that you have two locations, connected by a WAN T1 circuit. On the LAN side of each of these locations, you have a small Ethernet network. Here is a network diagram:

The only way for the devices on Ethernet LAN 10.10.1.0 to communicate with devices on network 10.10.2.0, is to use routing. With such a simple network, static routing is a perfect solution. You can enter one route on each router and be done with the configuration. With dynamic routing, there would be slightly more configuration. You would also forever have the network overhead of the routing protocols communicating across the WAN circuit.

To configure the static routes for this simple network, here is what you would do:

San Diego, CA Router-

Chicago, IL Router-

By doing this, you have told the San Diego Router that any traffic destined for the Chicago LAN, should be sent to IP address 20.1.1.2. The IP address 20.1.1.2 is the WAN serial interface of the Chicago router. In other words, you are sending that traffic to the “next hop” on the WAN, which happens to be the destination for this traffic. On the Chicago router, you are doing just the reverse so that the response from your San Diego traffic can find its way back to San Diego.

In two simple commands you have configured routing for this network.

Summary

Static routes are essential knowledge for any network administrator. While they do not scale well to a large network, they have their uses in all sizes of networks. Even if you are using a dynamic routing protocol, there are cases where using a static route is still a requirement. The ip route command has many more options than what we were able to explore in this short article. To learn more, go to your router and type ip route ?, or consult the Cisco IOS documentation on the ip route command.