From StarOS Community Wiki
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 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 " ->" and " ->". That means that packets aimed at,,, and are routed to, and all other packets aimed at subnet 10.10.10 are sent to

One happy consequence of the general routing rules is that a route with netblock 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 one 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. 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.

Policy routing allows fine-grain control of routing decisions. For example, with source-based routing, the next-hop can depend on a packet's source IP address as well as its destination IP address.