routing(7)
NAME
routing − system support for local network packet routing
DESCRIPTION
The network facilities provide general packet routing, leaving most routing table maintenance to applications processes.
A simple set of data structures comprise a routing table used in selecting the appropriate remote host or gateway when transmitting packets. The table contains a single entry for each route to a specific network or host.
The table contains the entry lo0 for the local loopback after system boot-up, and an entry ( lan0, lan1, lan2,...) for each interface card after the ifconfig command is executed (see ifconfig(1m)).
The super-user can change the table by using the route(1m) command (see route(1M), or by information received in Internet Control Message Protocol (ICMP) redirect messages.
To display the routing table, use the netstat -r command (see netstat(1)) which displays the destination internet address, which gateway to use to get to that destination, and flags. A routing table contains three types of entries: entries for a specific host, entries for all hosts on a specific network, and entries for any destination not matched by entries of the first two types (a wildcard route). The various types of routes are determined by the flags field of the display from netstat. The flags field is either U, UG, UH, or UGH. The U flag is always present. The G flag indicates a route using a gateway and is accompanied by a hop count. If a route is via a remote gateway, the hop count must be greater than zero. If no G flag is present, it indicates a route that does not use a remote gateway. The H flag indicates a route to a host. If the H flag is absent, it indicates a route to a network.
The keyword, default, in the destination field indicates a wildcard gateway. This is used as a last resort if no information exists in the table about how to get to a particular remote network. Routes that are not valid are not displayed (see Flags below for details).
First, an attempt is made to find a route to the specific host. If that search fails, the algorithm looks for a route to the host’s network. If both searches fail, the wildcard gateway is returned if one is in the table. If there are multiple routes of the same type (in other words, two routes to a host via different gateways, two routes to a network via different gateways, or two default routes), the packet is routed over the first route of the same type found in the route table (i.e, the first route of the same type displayed by netstat -r).
If all of the searches fail, an error is returned.
Flags
The following truth table shows the relationship between the count parameter used with the route command and the destination type, flags, and route type.
| Count | Destination Type | Flags | Route Type |
| =0 | network | 1=U | route to a network via a gateway which is the local host itself |
| >0 | network | 3=UG | route to a network via a gateway which is a remote host |
| =0 | host | 5=UH | route to a host via a gateway which is the local host itself |
| >0 | host | 7=UGH | route to a host via a gateway which is a remote host |
| =0 | "default" | 1=U | wildcard route via the local host |
| >0 | "default" | 3=UG | wildcard route via a remote gateway |
The routing algorithm used includes the ability to recognize subnets. Subnet addresses are similar to the network address portion of Internet addresses; network addresses identify physically distinct networks; subnet addresses identify physically distinct subnetworks of the same network. Subnets allow a network manager to partition the host number space associated with a given network number into discrete subnetworks. This facility is desirable if it is necessary for several physical networks to share a single network number. An example is a facility with a single class B network number and several Ethernet-like physical networks. The host space of a class B address is 16 bits, while a single physical network can have a limitation of 200-300 hosts. If subnets are used it is possible for all of the networks to have the same network number while each host recognizes that another host with the same network number is not necessarily on the same physical network. The routing algorithm attempts to find a gateway for a host if it is not on the same subnet, although it may have the same network number.
The subnet for a given host is specified in the ifconfig command (see ifconfig(1M)). It is specified as a 32-bit subnet mask. The next paragraph outlines an example use of subnets.
An example class C network number is 192.34.17.0, with the last field specifying the host number. Normally all hosts with the prefix 192.34.17 are recognized as being on the same logical and physical network. If subnets are not in use, the default mask used is 255.255.255.0. When routing, bit-wise logical AND s are performed between the mask and the Internet address of the remote host, and between the mask and the local Internet address. If the result is non-zero, it is assumed that the remote host is on the same subnet as the local host. If subnets are to be used and the 8-bit host field is to be partitioned into 2 bits of subnet and 6 bits of host, the subnet mask would be 255.255.255.192. Note that a subnet mask of all zeroes causes the routing mechanism to assume that all hosts, whether local or remote, are on the local physical network.
If a subnet mask is not specified in the ifconfig command, the default mask is used to indicate that subnets are not in use. The default masks for the various classes of Internet addresses are as follows:
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0
WARNINGS
Reciprocal route commands must be executed on the local host and the destination host, as well as all intermediate hosts, if routing is to succeed in the cases of virtual circuit connections or bidirectional datagram transfers.
AUTHOR
routing was developed by the University of California, Berkeley.
FILES
/etc/hosts
/etc/networks
SEE ALSO
netstat(1), ifconfig(1m), route(1m) .
Hewlett-Packard Company — HP-UX Release 9.0: August 1992