10.8 Triggering network configuration
We have seen how interfaces can be configured or reconfigured. This needs to
be done at appropriate times.
Traditionally the network was configured during the boot sequence via the
/etc/rcS.d/S40networking
initscript and was rarely reconfigured.
Services that depended on networking were started later in the boot sequence.
On shutdown or reboot the initscripts were run in the opposite order.
Currently, however, there is a trend in GNU and Linux toward supporting
hardware and circumstances that change dynamically. First support was added
for hot swappable PCMCIA cards; more recently the hotplug
mechanism has been added so that many more peripherals can be swapped in and
out while the computer is running. This includes networking hardware. Note
that services that depend on hardware that is hot swapped must only be started
after the hardware is inserted and must be stopped when the hardware is
removed. This means that such services must be removed from the control of the
System V init system and put under the control of ifupdown
instead.
For example, suppose service foo controlled by initscript
/etc/init.d/foo
depends on dynamically reconfigured network
interface eth0.
-
First remove foo from the control of the init system. If you are
using the sysv-rc
init system then do the following. [61]
# rm /etc/rc[2345].d/S??foo
-
Then put foo under the control of ifupdown
by adding
up and down options to the eth0 stanza
in /etc/network/interfaces
which contain calls to the
foo initscript:
iface eth0 inet dhcp
up /etc/init.d/foo start
down /etc/init.d/foo stop