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 127.0.0.1 127.0.0.1 UH 1 132 lo0 172.16.12.0 172.16.12.2 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 172.16.12.0 through interface le0. Address 172.16.12.2 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 127.0.0.0. The destination address shown (127.0.0.1) 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, 172.16.12.0. 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 (172.16.12.1): icmp_seq=0. time=11. ms 64 bytes from almond.nuts.com (172.16.12.1): icmp_seq=1. time=10. ms ^C ----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 207.25.98.2
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 207.25.98.2 is on. There are only two routes in the peanut routing table and neither is a route to 207.25.98.0.
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 172.16.1.2
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.