How are the routing tables populated on a Debian system? I understand that the ip route
family of commands can be used to manually manipulate the routing tables, but how are the routing tables initially populated on system start, and under what circumstances are the routing tables updated?
When working with a Debian system, the routing tables are automatically populated whenever network interfaces are brought up or down. See
man interfaces
,man ifup
, andman ip
for a detailed description.Essentially,
ifup
reads configuration bits from/etc/network/interfaces
and then for statically defined interfaces usesip route add
to create the appropriate routes. For interfaces configured to use DHCP,ifup
requests the configuration bits from the DHCP server and then usesip route add
to create those routes as well. When an interface is taken down,ifdown
deletes the routes that would have been added based on the current configuration. So be aware that when the configuration changes, the routes deleted byifdown
might not be the same as the routes originally added byifup
.In
/etc/network/interfaces
, thepre-up
,post-up
,pre-down
, andpost-down
hooks are available to manually manipulate the routing tables (or to run commands for other purposes).The scripts in
/etc/network/if-*.d/*
provide additional hooks for more complex tasks.