Setting up subnets and routing

Understanding the routing table

Every UnixWare system running TCP/IP has a network routing table which is stored in the operating system kernel. This table consists of a series of entries, and each entry consists of multiple fields.

The fields of interest to this discussion are:

The following sections show examples of how the routing table is used for direct and indirect routing.

Direct routing example

The following procedure shows how packets are routed to a system connected directly to the local network. See ``Example internetwork'', for an illustration of the networks described in this example.

  1. The IP layer of the machine thames receives a packet addressed to the machine seine at the IP address 172.16.1.4.

  2. thames consults its kernel routing table which may look like the following:

    Destination Netmask Gateway Interface
    172.16.2.0 255.255.255.0 volga net0
    172.16.1.0 255.255.255.0 local net0
    Default Not applicable volga net0

     -------------------------------------------------------------
    | Destination |  Netmask       |  Gateway     |  Interface   |
    |-------------|----------------|--------------|--------------|
    | 172.16.2.0  |  255.255.255.0 |  volga       |  net0        |
    |-------------|----------------|--------------|--------------|
    | 172.16.1.0  |  255.255.255.0 |  local       |  net0        |
    |-------------|----------------|--------------|--------------|
    | Default     |  Not applicable|  volga       |  net0        |
    |-------------|----------------|--------------|--------------|
    

  3. thames applies each netmask to the destination IP address 172.16.1.4 until it finds a match with the destination address. That is, the four places of the IP address are aligned over the four places of the netmask and the IP address is pushed through the netmask as through a filter. The number strings 255 allow the IP address number to pass through unchanged. The zeros in the mask convert the IP address string to zero.

    In this example, the netmask 255.255.255.0 applied to the IP address 172.16.1.4 results in the network address 172.16.1.0. As you can see, the result matches the second destination in the routing table. (If no match is found, thames uses the default entry.)

  4. Having found a destination match, thames uses the gateway and interface fields of the entry. thames addresses the packet for the gateway. In this case the gateway is local, meaning the local network, so the ultimate destination address is used. thames transmits the packet through the specified interface. In this case, the interface is to an Ethernet, so thames does a lookup in the ARP table to translate the IP address for seine to an Ethernet address for seine. thames transmits the packet on the Ethernet, and it is received by seine.

Indirect routing example

The following procedure shows how packets are routed to a system not connected directly to the local network. See ``Example internetwork'', for an illustration of the networks described in this example.

  1. The IP layer of the machine thames receives a packet addressed to the machine paris at the IP address 172.16.2.3

  2. thames consults its kernel routing table, which may look like the following:

    Destination Netmask Gateway Interface
    172.16.2.0 255.255.255.0 volga net0
    172.16.1.0 255.255.255.0 local net0
    default Not applicable volga net0

     -------------------------------------------------------------
    | Destination |  Netmask       |  Gateway     |  Interface   |
    |-------------|----------------|--------------|--------------|
    | 172.16.2.0  |  255.255.255.0 |  volga       |  net0        |
    |-------------|----------------|--------------|--------------|
    | 172.16.1.0  |  255.255.255.0 |  local       |  net0        |
    |-------------|----------------|--------------|--------------|
    | default     |  Not applicable|  volga       |  net0        |
    |-------------|----------------|--------------|--------------|
    

  3. As described in the previous example, thames applies each netmask to the IP address 172.16.2.3 until it finds a match with the destination address. Having found a destination match, thames uses the gateway and interface fields of the entry. thames addresses the packet for the gateway. In this case, the gateway is the machine volga.

  4. thames transmits the packet through the specified interface. In this case, the interface is to an Ethernet, so thames does a lookup in the ARP table to translate the IP address for volga to an Ethernet address for volga. thames transmits the packet on the Ethernet, and it is received by volga.

  5. When volga receives the packet, it reads the ultimate destination IP address. Finding that the address is not its own, and because volga is configured as a router, it consults its kernel routing table as thames did above. volga finds that the ultimate destination address can be reached via the local gateway and sends the packet out the local Ethernet interface addressed to the ultimate destination IP address.

  6. paris receives the packet.

Routing table updates

As illustrated by ``Direct routing example'', and ``Indirect routing example'', the successful routing of IP packets depends on the contents of the kernel routing table. Entries in the kernel routing table are created, removed, and changed:

A special STREAMS driver handles all updates to and lookups in the kernel routing table. This driver and the messages used to communicate with the driver are described in route(7tcp). All SCO TCP/IP commands and routing daemons that need to update or access data in the kernel routing table use this driver. More information is provided in the discussion of the routing daemons (see ``Routing daemons'').
© 1999 The Santa Cruz Operation, Inc. All rights reserved.
UnixWare 7 Release 7.1.1 - 5 November 1999