netplug is a nice little daemon that detects ethernet cables being inserted and removed based on kernel netlink events. Unlike ifplugd, it doesn’t use any other tricks or work with wireless devices. However, it is much smaller and encourages kernel driver devs to use netlink events properly- which is good :)

One thing I’ve never liked about ifplugd is that it never seems to work well with the default settings and it currently runs from it’s own init script- which makes it hard to integrate into baselayout automatically. netplug does not suffer from this as I deliberately didn’t write or use the packages init script and it has no configuration so to speak.

Here’s a rough diagram as to how it works

insert kernel module-> hotplug event-> hotplug starts net.eth0-> net.eth0 starts-> netplug launched-> net.eth0 goes inactive netplug gets a link beat-> net.eth0 configures and goes started or inactive depending on result

This means that all the user has to do is create a link from net.lo to net.eth0, which is something I’d like hotplug to do at some point so the user has nothing to configure in a DHCP based network. Well, they have to configure their NIC driver as an external module and trigger it via coldplug, but we’re starting to get to the stage where everything “Just Works” (tm) 8)

Of course, you can disable netplug from running on specific interfaces via the modules variable modules_eth0=( "!netplug" )

If you want to try it out, you’ll need baselayout-1.12.0_pre8 So what are you waiting for? GO TRY IT :P

EDIT: If you have more than one interface regardless of type, you’ll need the below patch otherwise netplugd will shut down

--- netplug     (revision 1468)
+++ netplug     (working copy)
@@-114,9 +114,14 @@
# Returns 0 (true) when successful, non-zero otherwise
netplug_post_stop() {
	${IN_BACKGROUND} && return 0
-       ebegin "Stopping netplug on $1"
+       local iface="$1"
+       local pidfile="/var/run/netplug.${iface}.pid"
+
+       [!-e ${pidfile} ]([)] && return 0
+
+       ebegin "Stopping netplug on ${iface}"
        start-stop-daemon--stop--exec /sbin/netplugd -	    --pidfile "/var/run/netplug.$1.pid"
+	    --pidfile "${pidfile}"
            eend $?
     }