How to configure `eth0` to retry `dhclient` when unplugged and replugged?

AJ ONeal coolaj86 at gmail.com
Wed Sep 7 13:16:12 MDT 2011


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