The Routing Table

At Grand Central Terminal, a big wall lists all the destinations and their corresponding track numbers (see Figure 1-4). Passengers find their destination on this wall and then proceed to the indicated platforms. Similarly, a routing table must contain at least two pieces of information: the destination network and the next hop toward that destination. This reflects a fundamental paradigm of IP routing: hop-by-hop routing. In other words, a router does not know the full path to a destination, but only the next hop to reach the destination.

Destinations and track numbers at Grand Central Terminal

Figure 1-4. Destinations and track numbers at Grand Central Terminal

Routes are installed in the routing table as they are learned through the mechanisms we have been discussing: directly connected networks, static routes, and dynamic routing protocols. A typical routing table in a Cisco router looks like this:

   Router>show ip route
   Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
          D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
          N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
          E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
         i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default

   Gateway of last resort is 0.0.0.0 to network 0.0.0.0

     

2       177.130.0.0/30 is subnetted, 2 subnets

   C       177.130.17.152 is directly connected, Serial1
   C       177.130.17.148 is directly connected, Serial0

3       10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
4  S       10.0.0.0/8 [1/0] via 160.4.115.74
5  S       10.254.101.0/24 [1/0] via 160.4.101.4
6       162.162.0.0/24 is subnetted, 2 subnets

   O IA    162.162.101.0 [110/3137] via 11.175.238.4, 02:16:02, Ethernet0
                       [110/3137] via 11.175.238.3, 02:16:02, Ethernet0
   O IA    162.162.253.0 [110/3127] via 11.175.238.4, 02:25:43, Ethernet0
                       [110/3127] via 11.175.238.3, 02:25:43, Ethernet0

7  O E2 192.188.106.0/24 [110/20] via 11.175.238.33, 20:49:59, Ethernet0

    ...

Note that the first few lines of the output attach a code to the source of the routing information: “C” and “S” denote “connected” and “static”, respectively, as we saw earlier, “I” denotes IGRP, etc. This code is prepended to each routing entry in the routing table, signifying the source of that route.

The body of the routing table essentially contains two pieces of information: the destination and the next hop. So, 177.130.0.0 (line 2) has two subnets, each with a 30-bit mask. The two subnets are listed in the following two lines.

Line 3 shows an interesting case. 10.0.0.0 has two subnets: 10.0.0.0/8 and 10.254.101.0/24. Not only are the subnet masks different, but the subnets are overlapping. A destination address of 10.254.101.1 would match both route entries! So, should a packet for 10.254.101.1 be routed to 160.4.115.74 or 160.4.101.4? Routing table lookups follow the rule of longest prefix match . 10.254.101.1 matches 8 bits on line 4 and 24 bits on line 5 -- the longer prefix wins, and the packet is forwarded to 160.4.101.4. 162.162.0.0 (line 6) has two subnets, each of which is known via two paths. 192.188.106.0 (line 7) is not subnetted.

What if a route is learnt via multiple sources -- say, via OSPF and as a static entry? Each source of routing information has an attached measure of its trustworthiness, called administrative distance in Cisco parlance. The lower the administrative distance, the more trustworthy the source.

Table 1-1 shows the default administrative distances.

Table 1-1. Default administrative distances

Route source

Default distance

Connected interface

0

Static route

1

External BGP

20

IGRP

100

OSPF

110

IS-IS

115

RIP

120

EGP

140

Internal BGP

200

Unknown

255

Thus, if a route is known both via OSPF and as a static entry, the static entry, not the entry known via OSPF, will be installed in the routing table.

Note that distance information and the route metric appear in the output of show ip route inside square brackets with the distance information first, followed by a “/” and the route metric: [distance/metric].

Administrative distance is only considered internally within a router; distance information is not exchanged in routing updates.

Get IP Routing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.