This section introduces the concept of IP routing and the commands required
to set up routes and routing tables.
Devices communicate with each other
over routes. A route is
a path from the sending device to the receiving device.
Devices on a network learn about routes in a variety of ways. Routes can
be manually configured by an administrator; devices can send out probes
to discover how to get to a destination; or devices can receive updates
about what routes are available. Once a device obtains information about
a route, the device stores the route information in a routing table for
future reference, as shown in Figure
10-1.
If the destination device is on the same network as the sending device,
the sending device simply transmits the datagram directly to the destination.
When a destination is not on the local network, a sending device forwards
the datagram to a router. In order to forward a datagram, the sending device
must first know what routers are connected to the local network.
Based on the network shown in Figure
10-1, a packet destined for 10.1.3.0 would be dropped. When a router
first comes up, it knows only about the networks that are directly connected
to its interfaces.
A router refers to entries about networks or subnets on which the router
is directly connected. Each router connection to a network is configured with
an IP address and mask, which are then associated with a router interface.
The Cisco IOS software learns about this IP address and mask information from
configuration information input from some source, such as a network administrator.
Key Concept
A route is a path from the sending device to the receiving device.
Routers learn about nonlocal routers and the shortest path to destination devices
through a variety of methods, discussed next.
Routers learn paths to destinations
in three ways:
-
Static routesManually
defined by the system administrator as the only path to the destination;
useful for controlling security and reducing traffic.
-
Default routesManually defined by the system administrator
as the path to take when no route to the destination is known.
-
Dynamically learned routesRouter learns of paths to
destinations by receiving periodic updates from other routers.
IP routing is automatically enabled in the Cisco IOS software. To disable IP routing, enter the following
command in global configuration mode:
When IP routing is disabled, the router will act as an IP end host for
IP packets destined for or sourced by the router. To re-enable IP routing,
issue the following command in global configuration mode:
Note that this book primarily focuses on dynamic routing. Refer to the
Cisco Press title Advanced Cisco Router Configuration
for more information on static and default routes.
An administrative
distance is a rating of the trustworthiness of a routing information
source, such as an individual router or a group of routers. An administrative
distance is an integer from 0 to 255. In general, the higher the value, the
lower the trust rating. An administrative distance of 255 means the routing
information source cannot be trusted at all and should be ignored.
Specifying administrative distance values enables the Cisco IOS software
to discriminate between sources of routing information, as shown in Figure
10-2 To get to network 128.10.0.0, Router A will choose to send the
packet to Router B because Router B has a lower administrative distance
than Router C.
The software always picks the route whose routing protocol has the lowest administrative distance. Table 10-1 shows the default administrative distances
for some routing information sources.
If a router has both routing protocols IGRP and RIP enabled, the Cisco
IOS software uses the IGRP-derived information because the default IGRP administrative
distance is lower than that for RIP and ignores the RIP-derived information.
However, if you lose the source of the IGRP-derived information (for example,
because of a power shutdown), the software uses the RIP-derived information
until the IGRP-derived information reappears.
Static routes are user-defined routes that cause packets moving between a source
and a destination to take a specified path. Static routes are important when
the Cisco IOS software cannot build a route to a particular destination. Routers
can forward packets only to known routes, and if the router cannot learn of
a route dynamically, the static entry can be used to enable the router to
route the incoming packet. Static routes are also useful for specifying a gateway of last
resort to which all unroutable packets will be sent. This gateway
(which is actually a router) is used as a last attempt to find some device
to handle the packet.
Dynamic routing is typically preferred because static routing can be
unwieldy in a large, complex, or volatile network because the administrator
would have to make many manual changes. In small, simple, stable networks,
however, static routing affords precision and control over the network without
too much work.
To configure a static route, enter
the ip
route command in global configuration mode. A static route allows
manual configuration of the routing table. No dynamic changes to this
table entry will occur as long as the path is active. The complete parameters
for the ip route
command are as follows:
where the parameters have the following meanings:
-
networkDestination network or subnet
-
maskSubnet mask
-
addressIP address of next-hop router
-
interfaceName of interface to use to get to destination
network
-
distanceThe administrative distance
-
permanent (Optional)Specifies that the route
will not be removed, even if the interface shuts down
If the mask is omitted in the ip route command, the router
assumes it can use the default mask. Figure
10-3 provides a static route example based on the following ip
route command:
In the example in Figure 10-3,
the ip route command identifies the static route command;
172.16.1.0 specifies a static route to the destination subnetwork; 255.255.255.0
indicates the subnet mask (eight bits of subnetting are in effect); and
172.16.2.1 is the IP address of next-hop router in the path to the destination.
The assignment of a static route to reach the stub network 172.16.1.0
is proper for the Cisco A router because there is only one way to reach that
network. A stub
network is one that has only one connection to another network.
If the network connects to more than one network and allows traffic to cross
it to get from one network to another, that network is called a transit network.
The assignment of a static route from Cisco B to the cloud networks
is also possible. However, a static route assignment is required for each
destination network, so a default route may be more appropriate.
Key Concept
You can have more than one IP routing protocol
operational in the same router at the same time. Each route is distinguished
by administrative distance. The lower this number, the better the route is
considered to be. It is basically a measurement of how good the router considers
the metric of that protocol to be. For a static route, the administrative
distance can be very low (for example, 0 or 1). The default administrative
distance for RIP is 120 and for IGRP is 100.
Because static routes have a low default administrative distance, they
are always chosen over dynamic routes. You can change this effect by overwriting
the administrative distanceessentially creating a static
backup routethat is effective only when the protocol is down.
A router might not know the routes to all other networks. To provide
complete routing capability, the common practice is to
use some routers as default routers and give the remaining routers default
routes to those routers.
To establish a default router, issue the following command in global
configuration mode:
where network-number is equal to the IP network
number or subnet number defined as the default.
When an entry for the destination network does not exist in the routing
table, the packet is sent to the default network, so the default network must
exist in the routing table. One benefit of default routes is that they reduce
the length of routing tables.
Use the default network number when you need a route but have only partial
information about the destination network. Because the router does not have
complete knowledge about all destination networks, it can use a default network
number to indicate the direction to take for unknown network numbers.
In addition to the normal IP network addresses, IP Routing Information
Protocol (RIP) uses 0.0.0.0 as the default route.
In the example shown in Figure 10-4,
the ip default-network 192.168.17.0 global command defines
the Class B network 192.168.17.0 as the destination path for packets that
have no routing table entry.
To prevent unwanted updates from entering from the public network, company
X could install a firewall in router A. To group those networks that will
share company X's routing strategy, router A could implement an autonomous
system number.
In Figure 10-4, you saw how company
X used a default router to connect to a public network. It was mentioned
that you could group routers into autonomous
systems. An autonomous system is a set of routers and networks
under the same administration. An autonomous system may consist of one
router directly connected to one LAN to the Internet; or an autonomous
system may be a corporate network linking several local networks through
a corporate backbone. The autonomous system presents a consistent view
of routing to the external world. For a router to belong to an autonomous
system, all routers in that system must be:
The Network Information Center (InterNIC) assigns
a unique autonomous system to enterprises. This autonomous system is a 16-bit
number. A routing protocol such as Cisco's Interior Gateway
Routing Protocol (IGRP) requires that you specify this unique, assigned autonomous
system number in your configuration. A InterNIC-assigned autonomous system
number is needed only if your organization plans to use an exterior router
protocol, such as Border Gateway Protocol (BGP). If your company performs
only interior routing, you need only ensure consistency and uniqueness of
autonomous system numbers within your
organization.
The design criteria for an interior routing protocol require it to find the best path through
the network. In other words, the metric and how that metric is used is the most important element in an interior routing
protocol.
Exterior protocols are used to exchange routing information between
networks that do not share a common administration. IP exterior gateway protocols
require the following three sets of information before routing can begin:
A list of neighbor (or peer) routers or access servers with
which to exchange routing information
A list of networks to advertise as directly reachable
The autonomous system number of the local router
As shown in Figure 10-5, the supported
exterior gateway protocols are as follows:
An exterior routing protocol must isolate autonomous systems. Basically,
another autonomous system is managed by some other staff. Because you have
no control over how that network is configured, you need to protect the network against errors that
could arise from misconfiguration. BGP and EGP are covered in more detail
in the Cisco Press title Advanced Cisco Router
Configuration.
The most common problem that could arise is a
routing loop or a convergence problem. This problem could be propagated
into the network as many routing updates specifying changes in metric. Hence,
an exterior routing protocol usually attempts to eliminate the metric in its
connection to the other network. For more information on routing loop and
convergence problems, refer to Chapter 4, “Network
Layer and Path Determination.”
At the Internet layer of the TCP/IP suite of protocols, as shown in
Figure 10-6, a router can use
the IP routing protocol to accomplish routing through the implementation
of a specific routing algorithm.
Interior protocols are used for routing networks that are under a common
network administration. All IP interior gateway protocols must be specified
with a list of associated networks before routing activities can begin. A
routing process listens to updates from other routers on these networks and
broadcasts its own routing information on those same networks. Cisco IOS software supports the following interior
routing protocols:
Routing Information Protocol (RIP)
Internet Gateway Routing Protocol (IGRP)
Enhanced Internet Gateway Routing Protocol (Enhanced IGRP)
Open Shortest Path First (OSPF)
Intermediate System-to-Intermediate System (IS-IS)
The following pages focus on how to configure the first two of these protocols: RIP and IGRP.
The selection of IP as a routing protocol involves the setting of both
global and interface parameters. Global tasks include:
The interface task is to assign interface-specific addresses and the
appropriate subnet mask.
Dynamic routing uses broadcasts and multicasts to communicate with other
routers. The routing metric helps routers find the best path to each network
or subnet.
Two primary commands are used
to configure dynamic routing: router and network.
The router
command starts a routing process; its form is as follows:
where the parameters specify the following:
-
protocolEither RIP, IGRP, OSPF, or Enhanced IGRP
-
keywordFor example, autonomous system number,
which is used with those protocols that require an autonomous system,
such as IGRP
The network
command is required because it allows the routing process to determine
which interfaces will participate in the sending and receiving of routing
updates. The network command starts up the routing protocol
on all interfaces that the router has in the specified network. The network
command also allows the router to advertise that network. Its form is
as follows:
where network-number specifies a directly connected
network.
The network number must be based on the InterNIC network numbers, not
subnet numbers or individual addresses. The network number also must identify
a network to which the router is physically connected.