Static Routing for Cisco Routers - CCNA
October 18th, 2008Most of us are already are familiar with routers due to DSL, cable, wireless, and satellite Internet services. What’s probably missing is the meaty part of what routers do and how they function.
The basic purpose of a router is to find the best path to a destination. For example, your switch sends a frame to a router via its Ethernet interface. When the router receives the frame, it captures the frame’s destination IP (Internet Protocol) address. Next, the router checks its routing table to determine whether it knows how to get to that destination.
First, the router checks for what is known as a static route. If there is no static route to the destination, next, the router looks for a route discovered via a routing protocol (such as CDP, RIP, EIGRP, or OSPF). If no discovered route exists, the router looks for a default route. Finally, the router routes the (newly created) packet if one of these routes exists (in the order presented). A key point to keep in mind is that if the router cannot find a route to the destination IP address, it will simply drop (or destroy) the frame.
To view the routing table of a Cisco router, type the commands listed below:
show ip route
at the CLI (command line interface) when you’re logged into user mode (immediately after you type “enable”). Before you configure a static route, you should first configure the router’s interfaces. To configure a router’s serial 0/0 interface with an IP address of 192.168.10.2 /24 and then verify the configuration, type the following commands:
enable
configure terminal
interface serial0/0
ip address 192.168.10.1 255.255.255.0
no shutdown
exit
exit
show ip interface serial0/0
Notice that in the configuration above, I did not specify a data speed rate for this interface, which is what you’d generally expect. If you guessed that I’m referring to the DCE (data circuit-terminating equipment) or DTE (data terminating equipment) status of a router, you’re right! Typically, your router will act as the DTE since the DCE role is usually played by your ISP’s router. If you have a difficult time remembering this, just commit to memory that the “C” in DCE refers to the clock (or timing) and that your ISP will set the clock rate for communication it controls.
At this point, you’re probably wondering just what a static route is. A static route is best used when you want to ‘rig’ how a packet is routed. For example, if your router possesses a discovered (or dynamic) route to a destination IP address, but you always want the router to use another route, you should configure the router with a static route.
You can use static routes for stub routers too. A stub router is a one that is connected to one and only one router. In other words, the stub router only has one path through which to route packets. When this is the case, configuring a routing protocol such as EIGRP is not useful. It’s easier and more efficient to use a static route.
You enter static routes when in global configuration mode (after you’ve typed in “configure terminal” at the CLI). The highly abbreviated command syntax for a static route is:
ip route major_network_address subnet_mask exit_interface
Now, let’s break this down into pieces:
1. “ip route” is the command used to initiate a static route command.
2. “major_network_address” represents the destination subnet for which you are configuring the static route. For example, if you want the static route to apply to all destination hosts in the 192.168.10.0 /24 subnet, then you would list that address in the command.
3. “subnet_mask” is the subnet that this command applies to. So, using the example in #2 above, you should type out the /24 as 255.255.255.0.
4. “exit_interface” is the interface name on your router through which the packet should exit. If you want the packet to exit via serial 0/0, then you would list that here.
The complete command, using the information froma above, would look like:
ip route 192.168.10.0 255.255.255.0 serial0/0
Cisco’s training material tells you that rather than listing your exit interface name, you can also list the IP address of the router on the other end of your router’s interface. However, I don’t recommend this because this slightly decreases your router’s speed.
When I outlined the router’s routing logic, I listed CDP as one of the router’s routing protocols, which is mostly true! CDP helps routers learn about routes, but not very many.
The Cisco Discovery Protocol runs only on Cisco routers and adds to the routing table information about interfaces (and their networks) that are directly-connected to the router. I can’t stress enough that if your router is running CDP and no other routing protocol, your router will only know about directly-connected routes (not routes directly-connected to other routers). One good thing about CDP is that it can learn about switches (Layer 2) and routers (Layer 3). Finally CDP is enabled by default on all Cisco routers. If all of your routers are not made by Cisco, you can turn it off for the router or per interface.
I also mentioned default routes. A default route is known as the router’s gateway of last resort because if no other route exists to a destination, the router will use a default route rather than drop a packet. Most routers should have a default route configured.
A default route is configured similarly to a static route except that the major_network_address and subnet_mask entries consist of all zeroes. If you want packets routed out of your serial 1/0 interface instead of dropping them, then in global configuration mode, type the following at the CLI:
ip route 0.0.0.0 0.0.0.0 serial1/0
Many writers refer to this as the ‘quad-zero’ command. The zeros are what make the route a default route.
Lastly, it’s important to point out that routers make routing decisions based on what they know - not on what other routers know. In other words, if a route is in your routing table, but not in mine, that does not help me at all. In addition, just because a router1 knows how to get to router2, this does not mean that router2 knows how to get to router1.
This means that once you configure your router, you should use the ping command to prove that you can get from router1 to router2 (and vice-versa if you need that type of connectivity).
We’ve covered a lot of material in this lesson. If you have any questions, please feel free to write for clarification.