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:
destination host or network IP address
network mask (netmask)
next hop (gateway); the next router which knows how to reach the
destination
identity of network interface through which a packet will be sent to
reach the gateway
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.
The IP layer of the machine thames receives a
packet addressed to the machine
seine at the IP address 172.16.1.4.
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
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.)
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.
The IP layer of the machine thames receives a
packet addressed to
the machine paris at the IP address 172.16.2.3
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
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.
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.
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.
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:
automatically when running the Network Configuration Manager
to configure or remove a network interface.
When configuring a network interface you are prompted for
an IP address and netmask.
This information is used to create a routing table entry with the
network attached to the interface as the destination field in the
routing table.
Through this process, the machine always knows about the networks
to which it is directly connected.
manually through use of the
route(1Mtcp)
command.
Through this command, the kernel routing table can contain
entries for networks to which the machine is not directly connected.
On small, static networks, manual maintenance of the kernel routing
table with the route command is reasonable, requiring less
computer overhead than using routing daemons.
dynamically by routing daemons running on the machine.
A routing daemon communicates via routing protocols with the routing
daemons on other
machines to learn about the existence of routes other than those
to which the machine is directly connected.
The routing daemon adds entries for these networks to the kernel routing
table automatically.
On large or changing networks, the use of routing daemons reduces
administrative overhead.