10.8.2 Triggering network configuration – hotplug
For hot-plug support install the hotplug
package.
Networking hardware can be hot plugged either at boot time or after a card
(e.g., a PCMCIA card) is inserted into the machine or after a utility such as
discover
runs and loads necessary driver modules.
When the kernel detects new hardware it initializes the driver for the hardware
and then runs the hotplug
program to configure it. Later if the
hardware is removed then the kernel runs hotplug
again with
different environment variable settings. In Debian, when hotplug
is called it runs scripts in /etc/hotplug/
and
/etc/hotplug.d/
. See hotplug(8)
for details.
Newly inserted network hardware is configured by the script
/etc/hotplug/net.agent
. [
62] Suppose your PCMCIA network card has been inserted
resulting in interface eth0 becoming available for use.
/etc/hotplug/net.agent
does the following [63] :
ifup eth0=hotplug
Unless you have added a logical interface definition or mapping named
hotplug to /etc/network/interfaces
, this command will
do nothing. To make it so that the command will configure eth0,
add the following stanza to /etc/network/interfaces
:
mapping hotplug
script echo
As explained in
High level network configuration using
ifupdown
logical interface definitions, Section 10.6.2 this
will map the command shown above so that it is equivalent to the following:
ifup eth0=eth0
(Do not include a mapping stanza like this if you are using
ifplugd
or waproamd
instances started by
hotplug
to control the interface.)
If you want only eth0 and no other interfaces to be brought up on
hot plug then use grep
instead of echo
as follows:
mapping hotplug
script grep
map eth0
See
Automatic network configuration using
ifupdown
, Section 10.6.3 and /usr/share/doc/hotplug/README.Debian
for more tips.