Lynx
Senior Member
I have just identified that:
does not renew upon a physical WAN cable disconnect and reconnect. See here:
See this OpenWrt patch (and related discussion):
What is the best way to deal with this, i.e. to force the expected renew upon eth0 down/up?
Would it be to write a script based on:
That way eth0 down/up could be detected and the necessary signal sent to udhcpc? I think this would be more efficient than polling every 0.5 seconds or so. Like this:
I propose this script to deal with this problem 'maintain-wan-lease':
Does that make sense?
If so, where would be the best place to put this script? Could anyone suggest a script form to send the necessary signal? Presumably this should be on 'eth0' goes 'up'? Or first detect 'down' then detect 'up' and then send KILL signal to force udhcpc into action?
Code:
7252 admin 3492 S /sbin/udhcpc -i eth0 -p /var/run/udhcpc0.pid -s /tmp/udhcpc -t1 -T5 -A0 -O33 -O249
How to deconfigure/reconfigure eth interface when cable is connected/disconnected with Busybox
I'm running Alpine Linux, which is based on Busybox and musl, on Raspberry Pi. When I run ifup eth0, it also starts udhcpc in the background for that interface. That means that if the ethernet cabl...
unix.stackexchange.com
[OpenWrt-Devel] [PATCH] add ifplugd
www.mail-archive.com
I have done my own testing and found that wanduck.c is very slow to detect a physical cable disconnect. It must be disconnected for > 5 seconds to restart wan. I tried setting wandog_interval to '1' from its default '5', but it made no difference.ifplugd is a Linux daemon which will automatically configure your ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected.
What is the best way to deal with this, i.e. to force the expected renew upon eth0 down/up?
Would it be to write a script based on:
Code:
ip monitor route dev eth0 | while read event; do
case "$event" in
'Deleted default'*)
...
;;
'local '*)
...
;;
...)
...
;;
...
esac
done
ip monitor : responding to events
I want to run a script in response to certain network events and to do this I am monitoring network routes using ip monitor route dev enp3s0 ip monitor waits for events and prints them as they ...
unix.stackexchange.com
Code:
ip monitor link dev eth0 | while read event; do echo $event; done
11: eth0: <NO-CARRIER,BROADCAST,MULTICAST,ALLMULTI,UP> mtu 1500 qdisc pfifo_fast state DOWN group default
link/ether f0:2f:74:92:41:68 brd ff:ff:ff:ff:ff:ff
11: eth0: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default
link/ether f0:2f:74:92:41:68 brd ff:ff:ff:ff:ff:ff
Code:
#!/bin/bash
renew_wan_lease=0
ip monitor link dev eth0 | while read event; do
logger "maintain-wan-lease detected eth0 event: "$event
case $event in
*'NO-CARRIER'* )
if [ $renew_wan_lease -eq 0 ]; then
logger "maintain-wan-lease detected eth0 state change to: 'NO-CARRIER', so forcing udhcpc to release wan lease."
killall -SIGUSR2 udhcpc
renew_wan_lease=1
fi
;;
*'LOWER_UP'* )
if [ $renew_wan_lease -eq 1 ]; then
logger "maintain-wan-lease detected eth0 state change from: 'NO-CARRIER' to: 'LOWER_UP', so forcing udhcpc to renew wan lease."
killall -SIGUSR1 udhcpc
renew_wan_lease=0
fi
;;
esac
done
If so, where would be the best place to put this script? Could anyone suggest a script form to send the necessary signal? Presumably this should be on 'eth0' goes 'up'? Or first detect 'down' then detect 'up' and then send KILL signal to force udhcpc into action?
Last edited: