Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cisco Press CCNA ICND 2004 - Cisco Press.pdf
Скачиваний:
122
Добавлен:
24.05.2014
Размер:
13.19 Mб
Скачать

242 Chapter 7: Advanced Routing Protocol Topics

Regardless of how the default route shows up—whether it’s a gateway of last resort, a route to 0.0.0.0, or a route to some other network with an * beside it in the routing table—it is used according to the rules of classless or classful routing, depending on which is enabled on that router.

Classless Routing

Even if there is a default route in the routing table, it might not be used. Again consider the network shown in Figure 7-5, with the same default route. As shown in Example 7-13, on R3, a ping of 10.1.1.1 works when the default route is used. However, a ping of 168.13.200.1, which would seemingly need to use the default route as well, fails.

Example 7-13 Classful Routing Causes One Ping to Fail

R3#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, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR

P - periodic downloaded static route

Gateway of last resort is 168.13.100.1 to network 0.0.0.0

168.13.0.0/24 is subnetted, 4 subnets

R168.13.1.0 [120/1] via 168.13.100.1, 00:00:13, Serial0.1 C 168.13.3.0 is directly connected, Ethernet0

R168.13.2.0 [120/1] via 168.13.100.2, 00:00:06, Serial0.1 C 168.13.100.0 is directly connected, Serial0.1

R3#ping 10.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 84/89/114 ms

R3#

R3#ping 168.13.200.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 168.13.200.1, timeout is 2 seconds:

...

Success rate is 0 percent (0/5)

So the ping 10.1.1.1 command on R3 works, just as it should. However, the ping 168.13.200.1 command does not work. Why?

Classless Routing Protocols and Classless Routing 243

Cisco IOS software uses either classful or classless routing logic when “matching” between a destination IP address and the routing table’s routes. The key to knowing why one ping works, and another does not, is based on what Cisco IOS software thinks is a “match” of the routing table. With classful routing, the router first matches the Class A, B, or C network number in which a destination resides. If the Class A, B, or C network is found, Cisco IOS software then looks for the specific subnet number. If it isn’t found, the packet is discarded, as is the case with the ICMP echoes sent with the ping 168.13.200.1 command. However, with classful routing, if the packet does not match a Class A, B, or C network in the routing table, and a default route exists, the default route is indeed used—which is why R3 can forward the ICMP echoes sent by the successful ping 10.1.1.1 command.

In short, with classful routing, the only time the default route is used is when a packet’s destination Class A, B, or C network number is not in the routing table. With classless routing, the default is used whenever the packet does not match a more specific route in the routing table.

You can toggle between classful and classless routing with the ip classless and no ip classless global configuration commands. With classless routing, Cisco IOS software looks for the best match, ignoring class rules. If a default route exists, with classless routing, the packet always at least matches the default route. If a more specific route matches the packet’s destination, that route is used. If not, the default route is used, regardless of whether the Class A, B, or C network that destination resides in is in the routing table.

Example 7-14 shows R3 changed to use classless routing, and the successful ping.

Example 7-14 Classless Routing Allows Ping 168.13.200.1 to Now Succeed

R3#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R3(config)#ip classless

R3(config)#^Z

R3#ping 168.13.200.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 168.13.200.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 80/88/112 ms

R3#

The following lists close out this section with a more explicit description of what happens with classful routing that causes the ping in Example 7-13 to fail and what causes the ping in Example 7-14, using classless routing, to succeed.

244 Chapter 7: Advanced Routing Protocol Topics

The classful logic of Example 7-13 works like this:

1.I need to send a packet to 168.13.200.1.

2.I match Class B network 168.13.0.0 because I am using classful routing; there is a match.

3.I do not match a specific subnet of network 168.13.0.0 that contains 168.13.200.1.

4.Because I matched network 168.13.0.0, I cannot use the default route in this case, so I discard the packet.

The classless logic of Example 7-14 works like this:

1.I need to send a packet to 168.13.200.1.

2.I do not match a specific route that contains 168.13.200.1.

3.I use the default route only if there is not a more specific match. Because there is no match, I use the default route.