The Routing Table


At the heart of IPv4 routing is the route table, which contains a number of entries detailing how to get to various destinations. The route table is consulted when the exchange of data between two hosts is required. The netstat -r command is used to view the entries in the route table. The following example shows the route table for the hostname ultra10 :

 ultra10# netstat -r Routing Table: IPv4   Destination           Gateway           Flags  Ref   Use   Interface -------------------- -------------------- ----- ----- ------ --------- ultra-net            ultra10               U        1    177  hme0 multicast            ultra10               U        1      0  hme0 sparc-net            ultra-r1              UG       1    255  hme0 localhost            localhost             UH       3    635  lo0 

Notice from this code that the first two columns are displaying names , rather than IP addresses. If you do not want any name resolution to be applied, then use the -n option as well. The following example shows the route table without any name resolution for the same host ultra10 , which has an IP address of 192.168.28.28 :

 ultra10# netstat -rn Routing Table: IPv4   Destination           Gateway           Flags  Ref   Use   Interface -------------------- -------------------- ----- ----- ------ --------- 192.168.28.0         192.168.28.28         U        1    177  hme0 224.0.0.0            192.168.28.28         U        1      0  hme0 192.168.47.0         192.168.28.1          UG       1    255  hme0 127.0.0.1            127.0.0.1             UH       3    635  lo0 

The standard behavior of the netstat -r command is to display only host, network, and default routes. To see all route table entries, including broadcast and local entries, use the -a option. The following example lists all routing entries, without any name resolution, for the same host:

 # netstat -arn Routing Table: IPv4   Destination           Gateway           Flags  Ref   Use   Interface -------------------- -------------------- ----- ----- ------ --------- 192.168.28.0         192.168.28.28         U        1     69  hme0 224.0.0.0            192.168.28.28         U        1      0  hme0 default              192.168.28.28         UG       1      0 0.0.0.0              192.168.28.28         UHB      1      0  hme0 0.0.0.0              192.168.28.28         UHB      1      0  hme0 192.168.28.19            --                UHA      2     79  hme0 192.168.28.28            --                UHL      5   1874  hme0 192.168.28.25            --                UHA      1      1  hme0 192.168.28.0         192.168.28.28         UHB      1      0  hme0 192.168.28.0         192.168.28.28         UHB      1      0  hme0 192.168.28.255       192.168.28.28         UHB      1     29  hme0 192.168.28.255       192.168.28.28         UHB      1      0  hme0 255.255.255.255      192.168.28.28         UHB      1      0  hme0 255.255.255.255      192.168.28.28         UHB      1      0  hme0 127.0.0.1            127.0.0.1             UH       3     10  lo0 

The output from the netstat -r command contains several fields, which are described as follows :

  • Destination ” The destination host or network.

  • Gateway ” The host or router that is being used to deliver data to an indirectly connected destination. When this field displays -- , then the destination is on the same physical network and therefore a direct route is already known.

  • Flags ” The status of the route and some characteristics of the route. Valid values for this item are as follows:

    • D ” Denotes a route that was dynamically created by an ICMP redirect.

    • G ” Denotes that the route is to a gateway.

    • H ” Denotes that the route is to a host rather than a network.

    • U ” Denotes that the route is up and available.

    If the -a option to netstat was used, then some additional flags are also displayed, which can be any of the following:

    • A ” Denotes combined routing and address resolution entries.

    • B ” Denotes a broadcast entry.

    • L ” Denotes a local address.

  • Ref ” This field shows the number of routes that use this network interface.

  • Use ” The number of packets that have used this route.

  • Interface ” The network interface that is used on the outgoing path to the destination host or network.

When you try to contact another system, whether it is on the local network or remote, the routing algorithm carries out a search of the route table in a specific order:

  1. The local network is first checked for a match to see whether the destination host is directly connected. If a successful match is found, then the data is passed through the local network interface for delivery.

  2. The route table is checked to see whether there is an IP address match in the destination field. If a successful match is found, the data is forwarded to the IP address designated in the gateway field for that route.

  3. The route table is checked to see whether there is a network number match in the destination field. If a successful match is found, the data is forwarded to the router that is associated with the route. This is not the final destination, so the router will have to forward the data on to either the destination network or another router.

  4. The route table is checked to see whether a default route entry is present. If the entry exists, then the data is passed to this address for delivery.

  5. No route has been found for the data, so an appropriate ICMP message is returned, such as Destination network is unreachable .

The /etc/inet/networks File

The /etc/inet/networks file is used to associate network numbers with network names, similar to the /etc/inet/hosts file that associates host IP addresses to hostnames. It is a convenient way to refer to networks by a familiar name, instead of remembering numerous IP addresses. The following is a sample /etc/inet/networks file:

 ultra10# cat /etc/inet/networks ultra-net       192.168.28.0 tech-net        192.168.42.0 sysadmin-net    192.168.66.0 market-net      192.168.145.0 

If you need to add static routes to the routing table, then using this file enables you to use the familiar names ”instead of the IP addresses ”to add the route entries.

graphics/alert_icon.gif

The file /etc/networks is a symbolic link to /etc/inet/networks and is included for BSD compatibility. The actual file is /etc/inet/networks , so be aware of this because it is a frequent exam question.




Solaris 9 Network Administration Exam Cram 2 (Exam Cram CX-310-044)
Solaris 9 Network Administrator Exam Cram 2 (Exam CX-310-044)
ISBN: 0789728702
EAN: 2147483647
Year: 2003
Pages: 174
Authors: John Philcox

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net