Konubinix' opinionated web of thoughts

Linux Kernel Routing

Fleeting

linux kernel routing

routing tables

Linux kernel 2.2 and 2.4 support multiple routing tables

http://linux-ip.net/html/routing-tables.html

multiple routing table system provides a flexible infrastructure on top of which to implement policy routing

http://linux-ip.net/html/routing-tables.html

Each routing table still operates in the traditional and expected fashion

http://linux-ip.net/html/routing-tables.html

The two routing tables normally employed are table 255, the local routing table, and table 254, the main routing table.

http://linux-ip.net/html/routing-tables.html

The ip route and ip rule commands have built in support for the special tables main and local. Any other routing tables can be referred to by number or an administratively maintained mapping file, /etc/iproute2/rt_tables.

http://linux-ip.net/html/routing-tables.html

Aside from the local routing table, which is maintained by the kernel, and the main routing table which is partially maintained by the kernel, all routing tables are controlled by the administrator or routing software. All routes on a machine can be changed or removed.

http://linux-ip.net/html/routing-tables.html

two auto managed default tables, main and local

two commonly used routing tables (the local and main routing tables), the kernel supports up to 252 additional routing tables

http://linux-ip.net/html/routing-tables.html

local table shows broadcast addresses and locally hosted IP

Normally, the local routing table should not be manipulated, but it is available for viewing

http://linux-ip.net/html/routing-tables.html

The first common use is the specification of broadcast address, necessary only for link layers which support broadcast addressing. The second common type of entry in a local routing table is a route to a locally hosted IP.

http://linux-ip.net/html/routing-tables.html

main table to deal with new interfaces

The main routing table is the routing table most people think of when considering a linux routing table.

http://linux-ip.net/html/routing-tables.html

Similarly to the local table, the main table is populated automatically by the kernel when new interfaces are brought up with IP addresses.

http://linux-ip.net/html/routing-tables.html

route selection

pseudo code

Example 4.4. Routing Selection Algorithm in Pseudo-codeif packet.routeCacheLookupKey in routeCache : route = routeCache[ packet.routeCacheLookupKey ] else for rule in rpdb : if packet.rpdbLookupKey in rule : routeTable = rule[ lookupTable ] if packet.routeLookupKey in routeTable : route = route_table[ packet.routeLookup_key ]

http://linux-ip.net/html/routing-selection.html

routing policy database

routing policy database (RPDB) controls the order in which the kernel searches through the routing tables

http://linux-ip.net/html/routing-rpdb.html

kernel iterates over each rule in turn until the packet to be routed matches a rule. When this happens the kernel follows the instructions in that rule

http://linux-ip.net/html/routing-rpdb.html

Typically, this causes the kernel to perform a route lookup in a specified routing table.

http://linux-ip.net/html/routing-rpdb.html

If a matching route is found in the routing table, the kernel uses that route. If no such route is found, the kernel returns to traverse the RPDB again, until every option has been exhausted

http://linux-ip.net/html/routing-rpdb.html

Notes linking here