previous contents up next

Unix for Advanced Users

13. Unix Networking

13.2. How Hosts Connect Across Subnets

13.2.2. TCP/IP Routing

Now that we understand subnets, let us explore how TCP/IP packets eventually get to their destination when the destination is not on the local subnet.

What are Gateways/Routers?

A gateways or a router is a device which connects two or more different subnets. While a simple Linux box with two ethernet interfaces can be used to route TCP/IP traffic, routers are generally specialized devices which are designed specifically to route packets.

Static vs. Dynamic Routing:

There are two ways routing is usually configured on a Unix box: statically or dynamically. Static routes are set using the route command by the initialization scripts during system boot. The most common configuration uses a default gateway to which all traffic not destined for hosts on the local subnet is directed. It is the function of the default gateway to figure out how to route the packets to their destination.

Dynamic routing under Unix means that the routed daemon is running on the system. routed uses the RIP routing protocol (described below) to do dynamic route discovery.

RIP, the Routing Information Protocol:

While there are a number of different routing protocols currently in use, TCP/IP routing inside a domain (i.e. across LANs) is usually handled by what is known as the "Routing Information Protocol" or RIP. RIP works by using the IP broadcast mechanism on the local subnet to get information on how best to route the traffic to its destination. Here is how RIP works in a typical situation (such as this lab):

  1. Each host is configured with a static default route or gateway (for the lab, this is 129.79.28.254). Everytime you send a TCP/IP packet to a destination outside the 129.79.28 subnet, it is sent to the gateway.
  2. The gateway does dynamic route discovery using RIP. It generates RIP queries using the IP broadcast addresses on the attached subnets. (Assuming that our gateway is connected to subnets 27 and 28, the gateway uses the 129.79.28.255 and 129.79.27.255 addresses for RIP queries.)
  3. A router (or indeed any host on the attached subnets which is running RIP) will answer these RIP broadcasts with its own routing table. Of course, its own routing table contains information on how to get to other subnets along the way.
  4. Using this method, soon all routers on the network know the possible routing paths to any remote destination within the domain. The path RIP chooses for the packets to their destination is based on the least number of network hops (called the hop count or "metric"). The maximum number of hops allowed by RIP is 15.
This describes the method used to route packets within a domain. Other protocols (such as BGP, EGP, etc.) are used today for routing on the internet (i.e. between sites). If you are interested in learning more, an excellent source is the O'Reilly "TCP/IP Network Administration" book.

previous contents up next