using UDEV to detect network link events (plug, unplug)?

AJ ONeal coolaj86 at gmail.com
Wed Sep 7 13:19:04 MDT 2011


I was able to get netplug working, but it wasn't already installed.
If I could get this working with udev, that would be marginally better.

However, I ran `udevd --debug` I didn't see any events fire when the cable
was unplugged or plugged back in.

Does udev only monitor the addition and removal of a device, but not events
that fire on the device?

Any thoughts on that?


AJ ONeal


On Wed, Sep 7, 2011 at 1:16 PM, AJ ONeal <coolaj86 at gmail.com> wrote:

> Looks like netplug will do the trick! Thanks so much!
>
>     sudo apt-get install netplug
>
>
>     cat /etc/netplug/netplugd.conf
>     eth*
>
>
>     cat /etc/netplug/netplug
>     #!/bin/sh
>     PATH=/usr/bin:/bin:/usr/sbin:/sbin
>     export PATH
>
>     dev="$1"
>     action="$2"
>
>     case "$action" in
>     in)
>         echo "$dev : $action : plugged in" >> /tmp/netplug.log
>         ;;
>     out)
>         echo "$dev : $action : unplugged" >> /tmp/netplug.log
>         ;;
>     probe)
>         echo "$dev : $action : probed" >> /tmp/netplug.log
>         ;;
>     *)
>         echo "$dev : $action : I feel violated" >> /tmp/netplug.log
>         exit 1
>         ;;
>     esac
>
>     /etc/init.d/netplug stop
>     /etc/init.d/netplug start
>
>     cat /tmp/netplug.log
>
> AJ ONeal
>
>
> On Wed, Sep 7, 2011 at 11:47 AM, Richard Holden <rholdeniii at gmail.com>wrote:
>
>> On Wed, Sep 7, 2011 at 11:20 AM, AJ ONeal <coolaj86 at gmail.com> wrote:
>>
>> > I'm working on a linux gadget.
>> >
>> > I want it to get DHCP if I plug in the network cable after it has booted
>> up
>> > already or if the network cable unplugged and replugged.
>> >
>> >
>> > However, I've got a feeling deep down in my little toe that tells me
>> that
>> > there's a better way to deal with hotplug events for the ethernet cable.
>> >
>> > Do any of you know what way that is?
>> >
>> >
>> > AJ ONeal
>> >
>> >
>> A quick Google search turned up netplugd, I don't have access to my Linux
>> box right now so I don't know how modern it is but it looks like exactly
>> what you want.
>>
>> http://linux.die.net/man/8/netplugd
>>
>> -Richard Holden
>>
>> /*
>> PLUG: http://plug.org, #utah on irc.freenode.net
>> Unsubscribe: http://plug.org/mailman/options/plug
>> Don't fear the penguin.
>> */
>>
>
>


More information about the PLUG mailing list