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

Configuring and Testing Static Routes 145

Foundation Topics

Configuring and Testing Static Routes

The purpose of configuring static routes, as well as RIP and IGRP, is to add routes to a router’s routing table. RIP and IGRP do so automatically. In fact, after you read all the conceptual material in this chapter, the actual RIP and IGRP configuration can be a little anticlimactic. In most networks, all you need are two configuration commands to configure RIP or IGRP. You don’t have to understand how they work—they just work. You need to understand both static routing and the distance vector concepts behind RIP and IGRP.

Static routing consists of individual configuration commands that define a route to a router. A router can forward packets only to subnets in its routing table. The router always knows about directly connected routes—routes to subnets off interfaces that have an “up and up” status. By adding static routes, a router can be told how to forward packets to subnets that are not attached to it.

Adding static routes to a router is relatively easy. To see the need, and to see the configuration, look at Example 5-1, which shows two ping commands testing IP connectivity from Albuquerque to Yosemite (see Figure 5-1).

Figure 5-1 Sample Network Used in Static Route Configuration Examples

Bugs Daffy

10.1.1.0

10.1.1.251

10.1.128.251

s0

 

 

 

0

 

 

.

 

 

.128

 

 

 

1

 

 

.

 

10.1.128.252

10

 

 

 

 

 

s0

 

 

 

Albuquerque

 

s1

10.1.130.251

 

10

 

 

.

 

 

1

 

 

.

 

 

130

10.1.130.253

 

.

 

0

 

 

 

s0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

10.1.129.0

 

 

 

 

 

 

 

 

 

 

 

 

 

Yosemite

 

 

s1

 

 

 

 

 

s1

 

 

 

Seville

 

10.1.129.252

 

 

 

 

 

 

 

10.1.2.252

 

 

 

 

 

 

 

 

 

10.1.129.253

 

10.1.3.253

10.1.2.0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

10.1.3.0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sam

Emma

Elmer

Red

146 Chapter 5: RIP, IGRP, and Static Route Concepts and Configuration

Example 5-1 Albuquerque Router EXEC Commands with Only Connected Routers

Albuquerque#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 not set

10.0.0.0/24 is subnetted, 3 subnets

C10.1.1.0 is directly connected, Ethernet0

C10.1.130.0 is directly connected, Serial1

C10.1.128.0 is directly connected, Serial0 Albuquerque#ping 10.1.128.252

Type escape sequence to abort.

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

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms

Albuquerque#ping 10.1.2.252

Type escape sequence to abort.

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

.....

Success rate is 0 percent (0/5)

The ping command sends an ICMP echo request packet to the stated destination address. The TCP/IP software at the destination then replies to the ping echo request packet with a similar packet, called an ICMP echo reply. The ping command sends the first packet and waits on the response. If a response is received, the command displays a “!”. If no response is received within the default timeout of 2 seconds, the ping command displays a “.”. The IOS ping command sends 5 of these packets by default.

In Example 5-1, the ping 10.1.128.2 command works, but the ping 10.1.2.252 command does not. The first ping command works because Albuquerque has a route to the subnet in which 10.1.128.2 resides (subnet 10.1.128.0). However, the ping to 10.1.2.252 does not work, because the subnet in which 10.1.2.252 resides, subnet 10.1.2.0, is not connected to Albuquerque, so Albuquerque does not have a route to that subnet. So, none of the five ping packets works, resulting in five periods in the output of the ping command.

Configuring and Testing Static Routes 147

Configuring Static Routes

One simple solution to the failure of the ping command is to enable an IP routing protocol on all three routers. In fact, in a real network, that is the most likely solution. As an alternative, you can configure static routes. Many networks have a few static routes, so you need to configure them occasionally. Example 5-2 shows the ip route command on Albuquerque, which adds static routes and makes the failed ping from Example 5-1 work.

Example 5-2 Static Routes Added to Albuquerque

ip route 10.1.2.0 255.255.255.0 10.1.128.252

ip route 10.1.3.0 255.255.255.0 10.1.130.253

The ip route commands supply the subnet number and the next-hop IP address. One ip route command defines a route to 10.1.2.0 (mask 255.255.255.0), which is located off Yosemite, so the next-hop IP address as configured on Albuquerque is 10.1.128.252, which is Yosemite’s Serial0 IP address. Similarly, a route to 10.1.3.0, the subnet off Seville, points to Seville’s Serial0 IP address, 10.1.130.253. Note that the next-hop IP address is an IP address in a directly connected subnet—the goal is to define the next router to send the packet to. Now Albuquerque can forward packets to these two subnets.

You can configure static routes in a couple different ways. With point-to-point serial links, you can also configure the outgoing interface instead of the next-hop IP address. For instance, you could have configured ip route 10.1.2.0 255.255.255.0 serial0 for the first route in Example 5-2.

Unfortunately, adding these two static routes to Albuquerque does not solve all the network’s routing problems. The static routes help Albuquerque deliver packets to these two subnets, but the other two routers don’t have enough routing information to forward packets back toward Albuquerque. For instance, PC Bugs cannot ping PC Sam in this network. The problem is that although Albuquerque has a route to subnet 10.1.2.0, where Sam resides, Yosemite does not have a route to 10.1.1.0, where Bugs resides. The ping request packet goes from Bugs to Sam correctly, but Sam’s ping response packet cannot be routed by the Yosemite router back through Albuquerque to Bugs, so the ping fails.

Extended ping Command

In real life, you might not be able to find a user, like Bugs, to ask to test your network by pinging. So you can use the extended ping command on a router to test routing in the same way a ping from Bugs to Sam tests routing. Example 5-3 shows Albuquerque with the working ping 10.1.2.252 command, but with an extended ping command that works

148 Chapter 5: RIP, IGRP, and Static Route Concepts and Configuration

similarly to a ping from Bugs to Sam—a ping that fails in this case (only the two static routes from Example 5-2 have been added at this point).

Example 5-3 Albuquerque: Working Ping After Adding Default Routes, Plus Failing Extended ping Command

Albuquerque#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 not set

10.0.0.0/24 is subnetted, 5 subnets

S10.1.3.0 [1/0] via 10.1.130.253

S10.1.2.0 [1/0] via 10.1.128.252

C10.1.1.0 is directly connected, Ethernet0

C10.1.130.0 is directly connected, Serial1

C10.1.128.0 is directly connected, Serial0 Albuquerque#ping 10.1.2.252

Type escape sequence to abort.

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

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms

Albuquerque#ping

Protocol [ip]:

Target IP address: 10.1.2.252

Repeat count [5]:

Datagram size [100]:

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 10.1.1.251

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]:

Sweep range of sizes [n]:

Type escape sequence to abort.

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

. . . . .

Success rate is 0 percent (0/5)

Configuring and Testing Static Routes 149

The simple ping 10.1.2.252 command works for one obvious reason and one not-so-obvious reason. First, Albuquerque can forward a packet to subnet 10.1.2.0 because of the static route. The return packet, sent by Yosemite, is sent to address 10.1.128.251—Albuquerque’s Serial0 IP address. Why? Well, the following points are true about the ping command on a Cisco router:

The Cisco ping command uses, by default, the output interface’s IP address as the packet’s source address unless otherwise specified in an extended ping. The first ping in Example 5-3 uses a source of 10.1.128.251, because the route used to send the packet to 10.1.2.252 points out interface Serial0, whose IP address is 10.1.128.251.

Ping response packets reverse the IP addresses used in the received ping request to which they are responding. So, in this example, Yosemite uses 10.1.128.251 as the destination address and 10.1.2.252 as the source IP address.

Because the ping command on Albuquerque uses 10.1.128.251 as the packet’s source address, Yosemite can send back a response to 10.1.128.251, because Yosemite happens to have a route to 10.1.128.0.

When you troubleshoot this network, you can use the extended ping command to act like you issued a ping from a computer on that subnet, without having to call a user and ask to enter a ping command for you on the PC. The extended version of the ping command can be used to refine the problem’s underlying cause by changing several details of what the ping command sends in its request. In fact, when a ping from a router works, but a ping from a host does not, the extended ping could help you re-create the problem without needing to work with the end user on the phone.

For instance, in Example 5-3, the extended ping command on Albuquerque sends a packet from 10.1.1.251 (Albuquerque’s Ethernet) to 10.1.2.252 (Yosemite’s Ethernet). According to the output, no response was received by Albuquerque. Normally, the ping would be sourced from the IP address of the outgoing interface. With the use of the extended ping source address option, the source IP address of the echo packet is set to Albuquerque’s Ethernet IP address, 10.1.1.251. Because the ICMP echo generated by the extended ping is sourced from an address in subnet 10.1.1.0, the packet looks more like a packet from an end user in that subnet. Yosemite builds a reply, with destination 10.1.1.251, but it does not have a route to that subnet. So Yosemite cannot send the ping reply packet back to Albuquerque.

To solve this problem, all routers could be configured to use a routing protocol. Alternatively, you could simply define static routes on all the routers in the network.