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 :
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:
The /etc/inet/networks FileThe /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.
|