Hack 79. Magically Empower Your Network Cable


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.
|