|HP-UX Reference > R
routing(7)HP-UX 11i Version 3: February 2007
routing — system support for local network packet routing
The network facilities for HP-UX provide general packet routing support. Routing table maintenance is handled by application processes.
A routing table consists of a set of data structures used by the network facilities to select the appropriate remote host or gateway when transmitting packets. The table contains a single entry for each route to a specific network or host, as displayed by the netstat command with the -r or -rn options (see netstat(1)). Routes that are not valid are not displayed.
_______________________________________________________________ # netstat -r Routing tables Destination Gateway Flags Refs Use Interface Pmtu hpindwr.cup.hp.com localhost UH 1 39 lo0 4608 localhost localhost UH 0 68 lo0 4608 126.96.36.199 localhost UH 0 0 lo0 4608 188.8.131.52 localhost UH 0 0 lo0 4608 default hpinsmh.cup.hp.com UG 1 21 lan0 1500 15.13.136 hpindwr.cup.hp.com U 1 92 lan0 1500 147.253.56 184.108.40.206 U 0 7 lan2 1500 220.127.116.11 18.104.22.168 U 0 7 lan1 1500 _______________________________________________________________ # netstat -rn Routing tables Destination Gateway Flags Refs Use Interface Pmtu 22.214.171.124 127.0.0.1 UH 1 39 lo0 4608 127.0.0.1 127.0.0.1 UH 0 68 lo0 4608 126.96.36.199 127.0.0.1 UH 0 0 lo0 4608 188.8.131.52 127.0.0.1 UH 0 0 lo0 4608 default 184.108.40.206 UG 2 30 lan0 1500 220.127.116.11 18.104.22.168 U 1 113 lan0 1500 22.214.171.124 126.96.36.199 U 0 7 lan2 1500 188.8.131.52 184.108.40.206 U 0 7 lan1 1500 _______________________________________________________________ # netstat -rv Routing tables Dest/Netmask Gateway Flags Refs Use Interface Pmtu hpindwr.cup.hp.com/0xffffffff localhost UH 1 39 lo0 4608 localhost/0xffffffff localhost UH 0 68 lo0 4608 220.127.116.11/0xffffffff localhost UH 0 0 lo0 4608 18.104.22.168/0xffffffff localhost UH 0 0 lo0 4608 default/0x00000000 hpinsmh.cup.hp.com UG 2 31 lan0 1500 15.13.136/0xfffff800 hpindwr.cup.hp.com U 1 129 lan0 1500 147.253.56/0xfffffe00 22.214.171.124 U 0 7 lan2 1500 126.96.36.199/0xfffffff0 188.8.131.52 U 0 7 lan1 1500 _______________________________________________________________ # netstat -rnv Routing tables Dest/Netmask Gateway Flags Refs Use Interface Pmtu 184.108.40.206/255.255.255.255 127.0.0.1 UH 1 39 lo0 4608 127.0.0.1/255.255.255.255 127.0.0.1 UH 0 68 lo0 4608 220.127.116.11/255.255.255.255 127.0.0.1 UH 0 0 lo0 4608 18.104.22.168/255.255.255.255 127.0.0.1 UH 0 0 lo0 4608 default/0.0.0.0 22.214.171.124 UG 3 40 lan0 1500 126.96.36.199/255.255.248.0 188.8.131.52 U 1 153 lan0 1500 184.108.40.206/255.255.254.0 220.127.116.11 U 0 8 lan2 1500 18.104.22.168/255.255.255.240 22.214.171.124 U 0 8 lan1 1500 _______________________________________________________________
The following columns are of particular interest:
The values of the count and destination type fields in the route command determine the presence of the G and H flags in the netstat -r display and thus the route type, as shown in the following table.
The network facilities support variable-length subnetting. An Internet address is made up of a network address portion, and a host address portion of an address in the form:
Subnet addresses are defined as a portion of the network's Internet address. This scheme provides for:
A network manager can subdivide the Internet address of the local network into subnets using the host number space. This facility allows several physical networks to share a single Internet address.
To allow for this, three Internet classes are defined, each accommodating a different amount of network and host addresses. The address classes are defined by the most significant bit of the binary form of the address.
The following table lists the number of networks, nodes, and the address ranges for each address class:
The first 8 bits of a Class A network has network space for only 127, while accommodating the largest number of nodes possible among the classes defined. A single class B network has the network address limitation of 16 bits, and 16 bits to define the nodes.
For example, a Class C address space is as follows:
______________________________________ Indicates Class C Class C subnet networks portion | | --- --- 10000000.00000110.00000001.11100001 -------------------------- ----- | | Network Address Host = 192.6.1 Address = 1 ______________________________________
A subnet for a given host is specified with the ifconfig command (see ifconfig(1M)), using the netmask parameter with a 32-bit subnet mask.
The default masks for the three 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
An example Class C network number is 126.96.36.199. The last field specifies the host number. Thus, 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.
If subnets are used and the 8-bit host field is partitioned into 3 bits of subnet and 5 bits of host as in the above example, then the subnet mask would be 255.255.255.192.
If a host has multiple interfaces, then it can belong to different subnets. Unlike past releases, the subnets can have different sizes even if they may have the same network address. This is accomplished by using a different netmask on each of the host interfaces. For example, the lan1 and lan2 interface shown in the netstat tables above are connected to two distinct subnets of the same network, 147.253. The subnet that lan1 belongs to can have at most 14 hosts, because its netmask is 255.255.255.240.
The subnet that lan2 belongs to can have up to 510 hosts, because its netmask is 255.255.254.0.
A supernet is a collection of smaller networks. Supernetting is a technique of using the netmask to aggregate a collection of smaller networks into a supernet. This technique is particularly useful for class C networks. A Class C network can only have 254 hosts. This can be too restrictive for some companies. For these companies, a netmask that only contains a portion of the network part can be applied to the hosts in these class C networks to form a supernet. This supernet netmask should be applied to those interfaces that connect to the supernet using the ifconfig command (see ifconfig(1M)). For example, a host can configure its interface to connect to a class C supernet, for example, 192.6, by configuring an IP address of 188.8.131.52 and a netmask of 255.255.0.0 to its interface.
The routing table entries are of three types:
To select a route for forwarding an IP packet, the network facilities select the complete set of "matching" routing table entries from the routing table. A routing table entry is considered a match, if the result of the bit-wise AND operation between the netmask in the routing entry and the IP packet's destination address equals the destination address in the routing entry.
The network facilities then select from the set the routing entries that have the longest netmask. The length of a netmask is defined as the number of contiguous 1 bits starting from the leftmost bit position in the 32-bit netmask field. In other words, the network facilities select the routing entry that specifies the narrowest range of IP addresses. For example, the host route entry that has a destination/netmask pair of (184.108.40.206, 0xFFFFFFFF), is more specific than the network route entry that has a destination/netmask pair of (220.127.116.11, 0xFFFFFE00); therefore, the network facilities select the host route entry. The default route by default has a destination/netmask pair of (0,0). Therefore, the default route matches all destinations but it is also the least specific. The default route will be selected only if there is not a more specific route.
There may still be multiple routing entries remaining. In that case, the IP packet is routed over the first entry displayed by netstat -r. Such multiple routes include:
A superuser can change entries in the table by using the route command (see route(1M), or by information received in Internet Control Message Protocol (ICMP) redirect messages.
If there are more than one default gateways for a particular net or subnet, each will be used in turn to effect the even distribution of datagrams to the different gateways.
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.