Re: dhcpcd to put down eth interface if unused
Roy Marples
Wed Nov 04 17:29:27 2020
Hi Martin
On 04/11/2020 16:10, Martin Bengsch wrote:
Hello everybody,
is it possible to use dhcpcd to put down an ethernet interface when it is unplugged and bring it back online, when it is connected. With "up" and "down" I mean the stated that result for example from "sudo ip link set eth0 down" and "sudo ip link set eth0 up".
I tried using "nolink" and "noup" for the interface, however, it didn't helped.
Does someone know how to achieve this behaviour? Thank you very much! :)
Unsure why you would want that behaviour, but with dhcpcd many things are
possible :)
Please note that putting an interface down may affect the abiltity of the
reported carrier state to function.
Anyway, you can put this in /etc/dhcpcd.exit-hook
case "$reason" in
CARRIER) ip link set $interface up;;
NOCARRIER) ip link set $interface down;;
esac
Roy
Archive administrator: postmaster@marples.name