We will use Figure 1 to explain the basic concepts of Routing. When host 1 needs to send IP packets to host 2 it will see whether host 2 IP address is within its own subnet, since host 2 does not belong to the same subnet host 1 will send the packet to the default gateway. An important point to note here is that when host 1 sends the packet it will use the destination IP address of host 2 and a destination MAC address of the Router since host 1 already has the IP address of default gateway it will use Address Resolution Protocol to obtain the MAC address. When the Router receives the Packet it will examine the destination IP address to make a routing decision to find an outgoing interface to forward the packet out. To make this decision the router must consult a table called the Routing table, this table at a minimum must include two entries for successfully routing the Packet, a destination address, and a pointer to the destination which can be a directly connected interface or an IP address of next-hop router. The Pointer to the destination will finally recurse to an outgoing interface, the Router will then only change Layer 2 destination address that will now point to the next-hop router and the Layer 3 Header that contains the source and destination IP address will remain intact. This process is repeated and every router independently performs a routing decision and switches packet from an incoming interface to an outgoing interface until the packet reaches the destination. If the router does not have the information to successfully route a packet it will drop the packet and send an ICMP destination unreachable message.
The Routing Table can get routing information dynamically through Routing Protocols or it may be defined statically.
In case of static routing, an administrator has to define static routes on every router for every network in an internetwork. This process is cumbersome and a lot of manual intervention will be required when networks are removed and added. On the other hand, dynamic routing will adapt to changes in the network and automatically converge.
We will use Figure 2 throughout the rest of the article to explain various routing concepts. If host 1 needs to communicate with host 2 every router in the path must be able successfully route the packet. It may be able to do so by gathering information dynamically through Routing Protocols or learn it manually through static routes. A static route can be defined on a Cisco Router using the following syntax
Config)# ip route network
The ip route command specifies the destination network, mask and a pointer to the destination, the pointer to the destination can either be an interface or a next-hop router IP address. The difference between the two is explained in the following points
- When the next-hop address is specified the router does another routing table lookup to find the outgoing interface. For example, if the ip route is specified as Config)# ip route 188.8.131.52 255.255.255.0 10.1.123.2 the router will now have to do another routing table lookup for 10.1.123.2. The route for this ip address is called a connected route in the routing table and associated with a directly connected interface, E0/1 in this case because 10.1.123.2 is in the same subnet as E0/1. The router will then perform a layer 2 to layer 3 resolution for 10.1.123.2
- When an Interface is specified as the pointer to destination, no extra lookup is needed.
- When routing to a next-hop value the router performs layer 2 to layer 3 resolution on the next-hop address.
- When routing to an interface the router performs layer 2 to layer 3 resolution on the final destination
To reach a destination a router might have multiple paths, as shown in Figure 2, R5 can reach 10.1.1.0/24 subnet via to R2 through serial 0/0 and via R4 through serial 0/1. Now how does a router determine which path to use?
Metrics are variables assigned to routes in order to rank them for comparison. The route that will be installed in the routing table will be the one that has the shortest metric. This route is called the best route.
Different Routing Protocols use different metrics. For example, Routing Information Protocol defines the best metric as the one with the least number of router hops, while OSPF uses cost as the metric. If we are using RIP as the dynamic Routing Protocol in the network shown in figure 2, R5 will use Serial 0/0 as the outgoing interface for 10.1.1.0/24 subnet because it being fewer hops away from via R2 then via R4.
A Cisco Router can also load balance traffic over multiple links that report the same metric for the destination.
Administrative Distance is used to prefer one routing protocol over another when both report the same destination network. When a Cisco router receives routing information from different protocols for the same destination network it will use the Routing Protocol that has a lower administrative distance.
Table 1 lists the AD Values for different Routing Protocols
|Route Source||Administrative Distance|
|RIP (V1 and V2)||120|
Since static routes have a lower AD than any of the dynamic routing protocols they will always be preferred over routes for same destination network learned from dynamic routing protocols. If you have seen the command syntax for a static route you must have seen the distance keyword. We can specify multiple static routes via different interfaces with higher administrative distance for the purpose of failover. If an interface goes down, the route through it will be removed and the other static route with a higher AD will be installed. These routes are known as floating static routes.
Today we covered a very important lesson for the CCNA Certification, and as we move further in our preparation we will come across many topics that require a firm understanding of these concepts.