Routing

From StarOS Community Wiki
Revision as of 23:09, 8 April 2007 by Handyman (talk | contribs) (Introduction to routing tables)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Each IP packet has both a source and a destination IP address. Routing is the act of forwarding a packet from router to router so as to eventually deliver it to its destination. The Routing 101 entry has a nice description of how this plays out.

Within a router, the routing process is controlled by a routing table, which is an ordered list of individual routes. An individual route describes a netblock and a next-hop IP address. The netblock describes a range of IP addresses using a base IP address and a netmask, as with 10.10.1.0/24. The next-hop address is the IP address of a directly connected router. The meaning of a route is that a packet whose destination address is within the given netblock should be forwarded to the given IP address.

The routes are ordered by the set-inclusion relationship among the netblocks. That is, if the netbock in one route is a subset of the netblock in another, then the smaller one is listed first. This ordering is calculated and enforced automatically by the router. Luckily, if two netblocks have any overlap at all, then one is a subset of the other, so that it is fairly easy for the router to determine the appropriate order. For netblocks with no overlap, their relative order in the table is immaterial.

The routing table is scanned in order, and the first match wins. This means that more specific routes take precedence over more general ones. For example, suppose there are two routes "10.10.10.4/30 -> 1.2.3.4" and "10.10.10.0/24 -> 5.6.7.8". That means that packets aimed at 10.10.10.4, 10.10.10.5, 10.10.10.6, and 10.10.10.7 are routed to 1.2.3.4, and all other packets aimed at subnet 10.10.10 are sent to 5.6.7.8.

One happy consequence of the general routing rules is that a route with netblock 0.0.0.0/0 will match every packet, and it will always be last in the routing table. This means that it will be used as a last resort when no other route matches. For this reason, this route is called the default route.

StarOS shows the routing table under the "advanced->system reports" tab.

Routes get inserted into routing tables in a variety of ways. If you enter it explicitly by hand, it is called a static route. If some software adds it in response to environmental conditions, it is called a dynamic route. For example, routers add dynamic routes for each subnet defined on some interface. For such a "connected" route, the notion of next-hop is immaterial

Using a dynamic routing protocol like RIP, OSPF, BGP, or OLSR, routers can interact among themselves to learn routes. Thus, instead of manually configuring static routes, you can let a dynamic routing protocol disseminate information about the connected routes that exist within each router.