Hack 79. Magically Empower Your Network Cable 
Configure your Ethernet devices simply by
plugging in or unplugging the cable.
This hack is actually a utility called
ifplugd, a daemon that watches your Ethernet
connection to see if it is live or disconnected. Plug the wire into
the network, and ifplugd configures the
interface. Unplug the wire, and ifplugd disables
the interface. Plug the wire back in, and it reconfigures the
interface, even if it needs to use DHCP to get an IP address.
It's a perfect utility for laptops that frequently
change their network connections, but it can come in handy for
workstations, too.
The ifplugd utility simply
checks your network interface(s) to
see if they have a link beat, which indicates a live connection to a
network. When a link beat appears, ifplugd
configures the interface (eth0, for example) as
being up and ready to use. When the link beat disappears (you
disconnect the cable), ifplugd brings the
interface down.
Most distributions package ifplugd in such a way
that it uses the default method for bringing down the interface if
there is no connection, and then it uses the default method for
bringing up the interface when ifplugd detects a
connection. In other words, on a Debian system with the interface
eth0, it uses the default methods of
ifdown eth0 and ifup eth0 for
disconnect and reconnect, respectively. It simply obeys how you
originally configured eth0 to work.
You don't usually need to use
ifplugd if you are using a laptop with a PC
Card/PCMCIA network adapter and static IP address, for two reasons.
The PCMCIA driver generally configures the device automatically
anyway, and ifplugd is rarely able to detect a
link beat through a PCMCIA device.
 |
ifplugd is known to have problems with some USB
network adapters (wireless or otherwise), especially when the driver
is available only from a third party and is not part of the default
Linux kernel. This is a driver issue related to the
kernel's ability to activate and deactivate the USB
device. This cannot be fixed by new versions of
ifplugd; it is something the kernel driver must
handle. If you have not yet purchased a USB network adapter, research
the latest kernel versions to find out which ones are best supported.
If you already have your USB network adapter, report problems to the
manufacturer. Some companies are surprisingly accommodating and eager
to fix problems such as these.
|
|
 |