At its most basic form, routing is the process of analyzing Layer 3 addresses (IP addresses) and then forwarding the packet containing the address out of the correct port based on the routing information, which is stored in system memory contained in the routing table.
In this Daily Drill Down, I will show you how to configure static routing for your smaller internetwork with the help of Cisco routers.
The routing table
The routing table is simply a list of all known network addresses along with the port or next hop router to be used to reach the destination address. (For a better understanding of network addresses vs. host addressing, see Jim McIntyre's IP subnetting article.) How the routing table is built depends on if the router is configured as a static router or a dynamic router. If the router has been configured as a static router, the network administrator is responsible for adding entries into the routing table. Dynamic routing, however, uses the services of one of many different routing protocols to discover network information.
Static routing is more prevalent in small internetworks. With static routing, the router administrator is responsible for populating each router’s routing table with the information needed to forward packets based on the destination Layer 3 addresses. For example, in Figure A, router A is only aware of networks 192.168.1.0/24 and 192.168.2.0/24 because both of these networks are directly connected to router A. If host 192.168.1.5 were to ping the destination address of 192.168.3.15, the packet would be discarded by router A because router A has no knowledge of network 192.168.3.0.
|With static routing, router A is only aware of what is available on its routing table.|
Configuring static routes
Router A needs a route entry in the routing table that lists a way to get to network 192.168.3.0. Static entries can be entered into the routing table using a Cisco global configuration command. Click here to view the command.
Here is a breakdown of what the options and arguments (for the global configuration command) mean:
- Prefix: A network address for which you want to enter a route
- Mask: The network mask used for the network address
- Address: IP address of the next hop address
- Interface: If you do not know the IP address of the next hop, you can enter the interface that you want the packets to exit in order to reach the destination address. You cannot interface a parameter if it is a point-to-multipoint interface such as Ethernet or frame relay.
- Distance (optional): The Administrative distance (By default, the distance is 1 for all static routes that use a next hop address, or 0 for all static routes that specify an exit interface.)
- Tag (optional): A value that can be used to match a value for controlling redistribution via route maps
- Permanent (optional): Specifies that the route will not be removed from the routing table, even if the interface is down
To add the correct route for router A, we would add a static route for the 192.168.3.0 network by issuing the following command in global configuration mode:
RouterA (config) ip route 192.168.3.0 255.255.255.0 192.168.2.2
(Next Hop Address)
RouterA (config) ip route 192.168.3.0 255.255.255.0 Serial0
Once we enter this command, we can again try and ping host 192.168.3.15 from host 192.168.1.5. However, again we will find that we do not receive a reply from host 192.168.3.15. So what gives? Let’s take a look at what happened.
Router A will receive the ICMP echo request packets destined for 192.168.3.15. Router A will consult its routing table and find an entry that informs router A that packets destined for 192.168.3.0 should be forwarded to 192.168.2.2. Router A will then forward the packets to router B's serial 0 interface with the address of 192.168.2.2. Router B will see that they are destined for a local network and will forward the packets to the host 192.168.3.15. Host 192.168.3.15 will then send echo reply messages to router B destined for the host 192.168.1.5. Router B does not have a route for the 192.168.1.0 network so the packets get dropped.
To correct the routing problem, router B needs information on how to get to network 192.168.1.0. Again, simply add a static route to router B's routing table as follows:
RouterB (config) ip route 192.168.1.0 255.255.255.0 192.168.2.1
RouterB (config) ip route 192.168.1.0 255.255.255.0 Serial0
Only point-to-point interfaces can be used in the definition of a static route. Ethernet interfaces cannot be used in static routes.
Now, if you ping host 192.168.3.15 from host 192.168.1.5, you should receive replies. Let’s look at a more complex network.
|As you add more routes to your network, you must remember to add to your routers’ routing table.|
Each router requires a route for each network address throughout the internetwork. To allow for proper routing for Figure B, additional static routes would have to be entered. Click here to view those static routes.
For computers on network B to communicate with network C, router B must send all packets through router A. Router A will accept and route packets from network B just as it would from network A. One drawback to this configuration is that hosts on network B cannot communicate with hosts on network C if the connection to router A is down. To correct this issue, you could add another connection between network C and network B, which would give you a fully meshed network.
|Once your routing tables are complete, your network should be able to fully communicate.|
Figure C shows a fully meshed network where all routers have a direct connection to all other routers. Each router must have routes defined for each network. Click here to view a sample static route configuration for each router.
While this configuration allows connectivity among all hosts, it does not provide any fault tolerance or redundancy. The network in Figure C provides physical redundant routes to any network; however, each router only has one routing entry for each network. If the primary route fails, network connectivity will be lost. For example, if the T1 line between network A and network C is lost, hosts on networks A and C will not be able to communicate because router A has only one route defined for network C and vice versa. To define a failover route, you have to create a floating static route.
Floating routes are secondary routes that are used by a router to reach a destination if the primary route fails. Floating routes are configured just as static routes are; however, an administrative distance (AD) is configured with the static route.
The AD is used to identify the preferred route. The default AD for a static route is 1. Defining a second route and assigning a higher AD of 100 ensures that this route will only be used if the primary route fails. Do not confuse the term administrative distance with the term metric. The metric is used by many routing protocols to identify the shortest distance between two networks, while the AD identifies the preferred route when more than one route exists to the same network.
For example, if the primary link between router C and router A fails, traffic should be rerouted through router B. To accomplish this, you could configure router A and router C with the static and floating static routes. Click here to view those routes.
Notice that a 100 follows each duplicate static route entry. The 100 is the AD being assigned to the route. If an AD is not specified, the entry is assigned the default AD of 1. The router will use the route with the least AD as long as that route is usable. If the T1 between router A and router C fails, the serial 1 interface on router A will be down and will force the use of the floating static route utilizing interface serial 0.
In the previous example, only one path is used at any time. To more efficiently utilize all available bandwidth, each router can be configured to load balance between each path. Load balancing can be configured for equal cost or unequal cost, where cost is the metric used to identify the best path.
- Equal cost load balancing: Traffic is distributed evenly over all available paths.
- Unequal cost load balancing: Traffic is routed down multiple paths inversely proportional to the cost associated with each path. For example, network C has two unequal paths to network A. Path 1 has a cost of 1 and Path 2 has a cost of 2. Unequal load balancing would forward two packets over the Path 1 for every one packet over the Path 2.
Static routing supports only equal cost routing. Since static routes do not have costs (metrics), all routes have the same cost or lack thereof. To configure load balancing across multiple routes, simply configure multiple routes to the same destination with the same administrative distance. For example, router A could be configured to load balance all traffic destined for network C by configuring the static routes on router A. Click here to view those routes.
With these configured routes, router A will send half of all traffic destined for network C to 192.168.4.2 and the other half to 192.168.2.2.
Static routing provides many advantages over dynamic routing. It does not require network bandwidth or processor resources. It is also much easier to configure but provides very little fault tolerance or ability to discover new routes as the network changes. Static routes are better suited to small networks with fewer than 10 routers that rarely change. Dynamic routing is better suited for larger networks with redundant paths and complex routing schemes.