Run a script when an interface goes up and down

Is there a way to be notified and run a script when the pppoe-wan interface goes up and down?

Just place the script at /etc/hotplug.d/iface/ (and have a look at the other scripts there to see what parameters your script is going to receive).

Thank you; that is what I was looking for.

Just an example if needed (change ACTION to ifdown to detect down state):

cat<<'EOF' > /etc/hotplug.d/iface/99-ifup-wan
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
    logger "iface wan up detected..."
    sh -x /etc/
exit 0
1 Like