Полезная информация

TCP/IP Network Administration

TCP/IP Network AdministrationSearch this book
Previous: 7.1 Common Routing Configurations Chapter 7
Configuring Routing
Next: 7.3 Building a Static Routing Table

7.2 The Minimal Routing Table

Let's look at the contents of the routing table constructed by ifconfig when peanut's network interfaces were configured:

% netstat -rn
Routing tables

Destination       Gateway          Flags    Refcnt Use      Interface        UH       1      132      lo0      U        26     49041    1e0

The first entry is the loopback route to localhost created when lo0 was configured. The other entry is the route to network through interface le0. Address is not a remote gateway address. It is the address assigned to the le0 interface on peanut.

Look at the Flags field for each entry. Both entries have the U (up) flag set, indicating that they are ready to be used, but neither entry has the G (gateway) flag set. The G flag indicates that an external gateway is used. The G flag is not set because both of these routes are direct routes through local interfaces, not through external gateways.

The loopback route also has the H (host) flag set. This indicates that only one host can be reached through this route. The meaning of this flag becomes clear when you look at the Destination field for the loopback entry. It shows that the destination is a host address, not a network address. The loopback network address is The destination address shown ( is the address of localhost, an individual host. This particular host route is in most routing tables.

Although every routing table has this host-specific route, most routes lead to networks. One reason network routes are used is to reduce the size of the routing table. An organization may have only one network but hundreds of hosts. The Internet has thousands of networks but millions of hosts. A routing table with a route for every host would be unmanageable.

Our sample table contains only one network route, Therefore, peanut can communicate only with hosts located on that network. The limited capability of this routing table is easily verified with the ping command. ping uses the ICMP Echo Message to force a remote host to echo a packet back to the local host. If packets can travel to and from a remote host, it indicates that the two hosts can successfully communicate.

To check the routing table on peanut, first ping another host on the local network:

% ping -s almond
PING almond.nuts.com: 56 data bytes
64 bytes from almond.nuts.com ( icmp_seq=0. time=11. ms
64 bytes from almond.nuts.com ( icmp_seq=1. time=10. ms
----almond.nuts.com PING Statistics----
2 packets transmitted, 2 packets received, 0% packet loss
round-trip (ms)  min/avg/max = 10/10/11

ping displays a line of output for each ICMP ECHO_RESPONSE received. [3] When ping is interrupted, it displays some summary statistics. All of this indicates successful communication with almond. But if we check a host that is not on nuts-net, say a host at O'Reilly, the results are different.

[3] Sun's ping would only display the message "almond is alive" if the -s option was not used. Some other ping implementations do not require the -s option.

% ping
sendto: Network is unreachable

Here the message "sendto: Network is unreachable" indicates that peanut does not know how to send data to the network that host is on. There are only two routes in the peanut routing table and neither is a route to

Even other subnets on nuts-net cannot be reached using this routing table. To demonstrate this, ping a host on another subnet. For example:

% ping
sendto: Network is unreachable

These ping tests show that the routing table created by ifconfig allows communication only with other hosts on the local network. If your network does not require access to any other TCP/IP networks, this may be all you need. However, if it does require access to other networks, you must add more routes to the routing table.

Previous: 7.1 Common Routing Configurations TCP/IP Network AdministrationNext: 7.3 Building a Static Routing Table
7.1 Common Routing Configurations Book Index7.3 Building a Static Routing Table