already automatically enables/disables ethernet based on cable
plug in/out
add wifi disable/enable based on ethernet state by adding hook
to /etc/dhcpcd.exit-hook (or in
/etc/dhcpcd.enter-hook or in
/usr/lib/dhcpcd/dhcpcd-hooks)
see man dhcpcd-run-hooks for the values of
$interface, $reason, etc.
# disable wifi if ethernet connected and enable wifi if ethernet disconnected
wired=eno1
wireless=wlan0
if [ "${interface}" = $wired ]; then
case "${reason}" in NOCARRIER|BOUND)
if $if_up; then # ethernet up means wifi down
iwctl station $wireless disconnect
elif $if_down; then # ethernet down means wifi up
# parse `iwctl known-networks list` and connect to most recent network
last="$(/home/stephenhuan/bin/iwd-last-network)"
iwctl station $wireless connect $last
fi
;;
esac
fi
connection randomly drops for a few seconds, happens
relatively frequently
journalctl -u dhcpcd@eno1.service
May 29 15:17:33 neko dhcpcd[806]: eno1: 00:56:2b:56:19:38(00:00:00:ff:eb:0d) claims 128.61.88.130
May 29 15:17:33 neko dhcpcd[806]: eno1: 00:aa:6e:d4:c0:38(00:00:00:ff:f2:b4) claims 128.61.88.130
May 29 15:17:33 neko dhcpcd[806]: eno1: 10 second defence failed for 128.61.88.130
May 29 15:17:33 neko dhcpcd[806]: eno1: deleting route to 128.61.80.0/20
May 29 15:17:33 neko dhcpcd[806]: eno1: deleting default route via 128.61.80.1
May 29 15:17:34 neko dhcpcd[806]: eno1: rebinding lease of 128.61.88.130
May 29 15:17:34 neko dhcpcd[806]: eno1: probing address 128.61.88.130/20
May 29 15:17:39 neko dhcpcd[806]: eno1: leased 128.61.88.130 for 7200 seconds
May 29 15:17:39 neko dhcpcd[806]: eno1: adding route to 128.61.80.0/20
May 29 15:17:39 neko dhcpcd[806]: eno1: adding default route via 128.61.80.1
The client receives the DHCPACK message with
configuration parameters. The client SHOULD perform a
final check on the parameters (e.g., ARP for allocated
network address), and notes the duration of the lease
specified in the DHCPACK message. At this point, the
client is configured. If the client detects that the
address is already in use (e.g., through the use of
ARP), the client MUST send a DHCPDECLINE message to the
server and restarts the configuration process. The
client SHOULD wait a minimum of ten seconds before
restarting the configuration process to avoid excessive
network traffic in case of looping.
fits with journalctl log:
found ip conflict with ARP, someone else is claiming the
address