Looking for simple ifplugd example script
ibid.ag at gmail.com
ibid.ag at gmail.com
Thu Feb 20 22:05:11 UTC 2014
On Thu, Feb 20, 2014 at 04:14:12PM +0000, Bryan Evenson wrote:
> I am using busybox-1.20.2 on an embedded Debian Linux machine, and I have configured Busybox to include ifplugd. I would like ifplugd to do the following:
> 1. When the Ethernet cable is plugged in, attempt DHCP on eth0
> 2. If DHCP fails, use a set static IP address
> 3. When the Ethernet cable is unplugged, unconfigure eth0
> At this point, ifplugd is not running. After some poking around,
> I see that there is no default daemon script for ifplugd included
> with Busybox. I'm assuming a script to do the above isn't that
> difficult, but I can't seem to find any examples on how to do this.
> Does anyone have a simple example that I can go by? I did see the
> example in the Busybox source under examples/var_service/ifplugd_if,
> but I couldn't make any sense of what that script did and how to make use of it.
DISCLAIMER: I haven't tried any of this, it's based on my reading of the
I'm not sure what init system it's aimed at (runit?), but here's what I
can make out:
examples/var_service/ifplugd_if/run: starts ifplugd with ifplugd_handler
as the script.
examples/var_service/ifplugd_if/ifplugd_handler: ifplugd script; called
$SCRIPT <if0> up
$SCRIPT <if0> down
A script for that would be something like:
case $2 in
dhclient $1 || ifconfig $1 $IP
ifconfig $1 down
You may need a good bit more magic in there, and may want to change
the commands used.
And you'd start it with something like this commandline:
ifplugd -IfM -t 5 -i eth0 -r /lib/busybox/ifplugd_script
> On a related note, I have eth0 setup in /etc/network/interfaces as:
> auto eth0
> iface eth0 inet dhcp
> If I want to use a static IP address if DHCP fails, do I need to add
> something to /etc/network/interfaces, or is that something that would belong in the ifplugd script?
I'm not sure what's the proper approach. I see notes that a static IP can be
configured via the DHCP client...
More information about the busybox