How to configure dynamically your ethernet device when a cable is plugged or unplugged ?
Ifplugd is a solution. It provides a daemon which configures your ethernet device when a cable is plugged and de-configures it when a cable is pulled out.
For Debian, to install it :
root@localhost:~# apt-get install ifplugd
Initially, to configure it, the use of /etc/ifplugd/ifplugd.conf file is deprecated. Instead, add your ethernet device, eth0 (often the default name) into the /etc/default/ifplugd file:
Make sure that the /etc/network/interfaces file looks like this :
root@localhost:~# cat /etc/network/interfaces
iface lo inet loopback
iface eth0 inet dhcp
Make sure you have removed the stanza “auto eth0” below otherwise ifplugd will not work properly.
Look at your syslog’s file for messages sent by ifplugd :
ifplugd 0.28 initializing.
ifplugd(eth0): Using interface eth0/6C:F0:49:17:1E:2E with driver <r8169> (version: 2.3LK-NAPI)
ifplugd(eth0): Using detection mode: SIOCETHTOOL
ifplugd(eth0): Initialization complete, link beat detected.
ifplugd(eth0): Executing ‘/etc/ifplugd/ifplugd.action eth0 up’.
ifplugd(eth0): client: /sbin/ifup: interface eth0 already configured
ifplugd(eth0): Program executed successfully.
More information about ifplugd : http://0pointer.de/lennart/projects/ifplugd/