Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [207]

By Root 2694 0
13 provided a short introduction to IP packet forwarding. In this chapter, we examine the forwarding process in more detail and investigate several network protocols that allow routers to discover efficient routes automatically. Routing protocols not only lessen the day-to-day administrative burden of maintaining routing information, but they also allow network traffic to be redirected quickly if a router or network should fail.

It’s important to distinguish between the process of actually forwarding IP packets and the management of the routing table that drives this process, both of which are commonly called “routing.” Packet forwarding is simple, whereas route computation is tricky; consequently, the second meaning is used more often in practice. This chapter describes only unicast routing; multicast routing involves an array of very different problems and is beyond the scope of this book.

Conventional wisdom says that IP routing is exceptionally difficult, understood only by a few long-haired hippies that live in the steam tunnels under the Lawrence Berkeley Laboratories campus in Kalifornia. In reality, this is not the case, as long as you understand the basic premise that IP routing is “next hop” routing. At any given point, you only need to determine the next host or router in a packet’s journey to its final destination. This is a different approach from that of many legacy protocols which determine the exact path a packet will travel before it leaves its originating host, a scheme known as source routing.1

1 It is also possible to source-route IP packets, but this is almost never done. The feature is not widely supported because of security considerations.

14.1 PACKET FORWARDING: A CLOSER LOOK

Before we jump into the management of routing tables, let’s take a more detailed look at how the tables are used. Consider the network shown in Exhibit A.

Exhibit A Example network

Router R1 connects the two Ethernets, and router R2 connects one of the nets to the outside world. (For now, we’ll assume that R1 and R2 are UNIX computers rather than dedicated routers.) Let’s look at some routing tables and some specific packet forwarding scenarios. First, host A’s routing table:

A% netstat -rn

Routing tables

Destination Gateway Flags Refs Use If

127.0.0.1 127.0.0.1 UH 6 563131 lo0

199.165.145.0 199.165.145.17 U 5 2845294 le0

default 199.165.145.24 UG 2 168589 le0

Host A has the simplest routing configuration of the four machines. The first two routes describe the machine’s own network interfaces in standard routing terms. These entries exist so that forwarding to directly connected networks need not be handled as a special case. le0 is host A’s Ethernet interface,2

and lo0 is the loopback interface, a virtual network interface emulated in software. Entries such as these are normally added automatically by ifconfig when a network interface is configured.

See page 300 for more information about ifconfig.

As indicated by the H flag, the loopback route is a “host route” to one particular IP address rather than an entire network. This route could also be configured as a network route, but since 127.0.0.1 is the only IP address that will ever exist on the loop-back network, it doesn’t really matter how it’s defined. The only changes you’d see in the routing table would be 127.0.0.0 in the destination column instead of 127.0.0.1 and no H in the Flags column.

There is no substantive difference between a host route and a network route. They are treated exactly the same when the kernel goes to look up addresses in the routing table; only the length of the implicit mask is different.

See the discussion of netmasks starting on page 272.

The default route on host A forwards all packets not addressed to the loopback address or to the 199.165.145 network to the router R1, whose address on this network is 199.165.145.24. The G flag indicates that this route goes to a gateway, not to one of A’s local interfaces. Gateways can be only one hop away.

Suppose a process on A sends a packet to B, whose

Return Main Page Previous Page Next Page

®Online Book Reader