Interpret the components of routing table
Determine how a router makes a forwarding decision by default
Today we review the two router functions: path determination and packet forwarding. Routers use routing tables to determine the best path. A router either uses a directly connected route, a route to a remote network, or a default route. Today, we review the structure of the routing table and its entries.
When a router receives an IP packet on one interface, it determines which interface to use to forward the packet to the destination. The primary functions of a router are to
Determine the best path for forwarding packets, based on the information in its routing table
Forward packets toward their destinations
The best path in the routing table is also known as the longest match. The router uses the longest match process to find a match between the destination IP address of the packet and a routing entry in the routing table. The prefix length of the route in the routing table is used to determine the minimum number of far-left bits that must match. The longest match is the route in the routing table that has the greatest number of far-left bits matching the destination IP address of the packet. The route with the greatest number of equivalent far-left bits, or the longest match, is always the preferred route.
In Table 17-1, an IPv4 packet has the destination IPv4 address 172.16.0.10. The router has three route entries in its IPv4 routing table that match this packet: 172.16.0.0/12, 172.16.0.0/18, and 172.16.0.0/26. Of the three routes, 172.16.0.0/26 has the longest match and would be chosen to forward the packet.
Table 17-1 IPv4 Address Longest Match Example
Destination IPv4 Address |
Address in Binary |
|
172.16.0.10 |
10101100.00010000.00000000.00001010 |
|
Route Entry |
Prefix/Prefix Length |
Address in Binary |
1 |
172.16.0.0/12 |
10101100.00010000.00000000.00001010 |
2 |
172.16.0.0/18 |
10101100.00010000.00000000.00001010 |
3 |
172.16.0.0/26 |
10101100.00010000.00000000.00001010 |
In Table 17-2, an IPv6 packet as the destination IPv6 address 2001:db8:c000::99. This example shows three route entries, but only two of them are valid matches; one of those is the longest match. The first two route entries have prefix lengths that have the required number of matching bits, as indicated by the prefix length. The third route entry is not a match because its /64 prefix requires 64 matching bits. For the prefix 2001:db8:c000:5555::/64 to be a match, the first 64 bits must match the destination IPv6 address of the packet. Only the first 48 bits match, so this route entry is not considered a match.
Table 17-2 IPv6 Address Longest Match Example
Route Entry |
Prefix/Prefix Length |
Does it match? |
1 |
2001:db8:c000::/40 |
Match of 40 bits |
2 |
2001:db8:c000::/48 |
Match of 48 bits (longest match) |
3 |
2001:db8:c000:5555::/64 |
Does not match 64 bits |
After a router has determined the best path based on the longest match in the routing table, it can do one of three things:
Forward the packet to a device on a directly connected network
Forward the packet to a next-hop router
Drop the packet because there is no match in the routing table
The primary responsibility of the packet forwarding function is to encapsulate packets in the appropriate data link frame type for the outgoing interface. For example, the data link frame format for a serial link could be Point-to-Point Protocol (PPP), High-Level Data Link Control (HDLC) protocol, or some other Layer 2 protocol.
A router examines the destination IP address of a packet and searches its routing table to determine where to forward the packet. The routing table contains a list of all known network addresses (prefixes) and where to forward the packet. These entries are known as route entries, or routes. The router forwards a packet using the best (longest) matching route entry.
Recall that a routing table stores three types of routing entries:
Directly connected networks: These network route entries are active router interfaces. In Figure 17-1, the directly connected networks in the R1 IPv4 routing table are 10.0.1.0/24, 10.0.2.0/24, and 10.0.3.0/24.
Remote networks: These network route entries are connected to other routers. Routers learn about remote networks either by being explicitly configured by an administrator or by exchanging route information using a dynamic routing protocol. In Figure 17-1, the remote networks in the R1 IPv4 routing table are 10.0.4.0/24 and 10.0.5.0/24.
Default route: The default route is used when there is no better (longer) match in the IP routing table. In Figure 17-1, the R1 IPv4 routing table has a default route to forward all packets to R2 for any remote network for which it does not have a more explicit route.
In Figure 17-1, R1 and R2 are using OSPF routing to advertise directly connected networks. R2 is connected to the Internet. The administrator configured a default route on R2 and propagated it to R1 in the OSPF routing process. R1 uses this propagated default route (O*E2) to send packets to R2 when there is not a more specific entry in the routing table that matches the destination IP address. The routing table in Example 17-1 displays all the known IPv4 destination routes for R1.
R1# show ip route Codes: L - local, C - connected, S - static, 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 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override, p - overrides from PfR Gateway of last resort is 209.165.200.226 to network 0.0.0.0 O*E2 0.0.0.0/0 [110/1] via 10.0.3.2, 00:51:34, Serial0/1/1 10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks C 10.0.1.0/24 is directly connected, GigabitEthernet0/0/0 L 10.0.1.1/32 is directly connected, GigabitEthernet0/0/0 C 10.0.2.0/24 is directly connected, GigabitEthernet0/0/1 L 10.0.2.1/32 is directly connected, GigabitEthernet0/0/1 C 10.0.3.0/24 is directly connected, Serial0/1/1 L 10.0.3.1/32 is directly connected, Serial0/1/1 O 10.0.4.0/24 [110/50] via 10.0.3.2, 00:24:22, Serial0/1/1 O 10.0.5.0/24 [110/50] via 10.0.3.2, 00:24:15, Serial0/1/1 R1#
The IPv6 routing table for R1 is shown in Example 17-2.
R1# show ipv6 route IPv6 Routing Table - 10 entries Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP U - Per-user Static route I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2 ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2 D - EIGRP, EX - EIGRP external OE2 ::/0 [110/1], tag 2 via FE80::2:C, Serial0/0/1 C 2001:DB8:ACAD:1::/64 [0/0] via GigabitEthernet0/0/0, directly connected L 2001:DB8:ACAD:1::1/128 [0/0] via GigabitEthernet0/0/0, receive C 2001:DB8:ACAD:2::/64 [0/0] via GigabitEthernet0/0/1, directly connected L 2001:DB8:ACAD:2::1/128 [0/0] via GigabitEthernet0/0/1, receive C 2001:DB8:ACAD:3::/64 [0/0] via Serial0/1/1, directly connected L 2001:DB8:ACAD:3::1/128 [0/0] via Serial0/1/1, receive O 2001:DB8:ACAD:4::/64 [110/50] via FE80::2:C, Serial0/1/1 O 2001:DB8:ACAD:5::/64 [110/50] via FE80::2:C, Serial0/1/1 L FF00::/8 [0/0] via Null0, receive R1#
At the beginning of each routing table entry is a code that is used to identify the type of route or how the route was learned. Common route sources (codes) include these:
L: Directly connected local interface IP address
C: Directly connected network
S: Static route manually configured by an administrator
O: OSPF
D: EIGRP
For directly connected routes, R1 adds three route entries with the codes C (for the connected network) and L (for the local interface IP address of the connected network). The route entries also identify the exit interface to use to reach the network.
R1 and R2 are also using the OSPF dynamic routing protocol to exchange router information. Therefore, R1 has a route entry, designated with the code O, for the 10.0.4.0/24 and 10.0.5.0/24 networks.
A default route has a network address of all zeros. For example, the IPv4 network address is 0.0.0.0. Instead of being statically configured, the default route was learned through OSPF and coded as O*E2 for IPv4 and OE2 for IPv6. The asterisk (*) in IPv4 means that this is a candidate for a default route. The E2 in IPv6 designates this route as an external type 2 route. In OSPF, this means the route is to another routing domain outside OSPF. In this case, the route is to the ISP router connected to the network, as shown in the topology in Figure 17-1. R2 is configured with a static default route and is propagating that route in OSPF with the default-information originate command configured in routing configuration mode.
Table 17-3 describes three routing table principles. These issues are addressed by the proper configuration of dynamic routing protocols or static routes on all the routers between the source and destination devices. The examples in the table refer to the R1 and R2 in Figure 17-1.
Table 17-3 Routing Principles and Examples
Routing Table Principle |
Example |
Every router makes its decision alone, based on the information it has in its own routing table. |
R1 can only forward packets using its own routing table. R1 does not know what routes are in the routing tables of other routers. |
The information in the routing table of one router does not necessarily match the information in the routing table of another router. |
Just because R1 has routed in its routing table to a network on the Internet through R2 does not mean that R2 knows about that same network. |
Routing information about a path does not provide return routing information. |
R1 receives a packet with the destination IP address of PC1 and the source IP address of PC3. Just because R1 knows to forward the packet out its G0/0/0 interface doesn’t necessarily mean that R1 knows how to forward packets originating from PC1 back to the remote network of PC3. |
Figure 17-2 shows IPv4 and IPv6 routing table entries on R1 for the route to remote network 10.0.4.0/24 and 2001:db8:acad:4::/64. Both of these routes were learned dynamically from the OSPF routing protocol.
In the Figure 17-2, the numbers identify the following information:
Route source: This indicates how the route was learned.
Destination network (prefix and prefix length): This identifies the address of the remote network.
Administrative distance: This identifies the trustworthiness of the route source. Lower values indicate preferred route sources.
Metric: This identifies the value assigned to reach the remote network. Lower values indicate preferred routes.
Next hop: This identifies the IP address of the next router to forward the packet to.
Route timestamp: This identifies how much time has passed since the route was learned.
Exit interface: This identifies the egress interface to use for outgoing packets to reach their final destination.
For today’s exam topics, refer to the following resources for more study.
Resource |
Module or Chapter |
Introduction to Networks v7 |
6 |
Switching, Routing, and Wireless Essentials |
14 |
CCNA 200-301 Official Cert Guide, Volume 1 |
16 |
18.227.228.181