Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Meatballs1/3f6e7b6a02445dc010bb166cadf427c9 to your computer and use it in GitHub Desktop.
Save Meatballs1/3f6e7b6a02445dc010bb166cadf427c9 to your computer and use it in GitHub Desktop.
networkd-dispatcher wifi/ethernet switchover
##
#/etc/networkd-dispatcher/no-carrier.d/50-ifdown-hooks
##
#!/bin/bash
enable_disable_wifi ()
{
if [ "$IFACE" == "enp0s25" ]; then
echo "$(date) - $IFACE down wifi unblocked"
rfkill unblock wifi
fi
}
enable_disable_wifi
##
#/etc/networkd-dispatcher/routable.d/50-ifup-hooks
##
#!/bin/bash
enable_disable_wifi ()
{
if [ "$IFACE" == "enp0s25" ]; then
echo "$(date) - $IFACE up wifi blocked"
rfkill block wifi
fi
}
enable_disable_wifi
##
# /etc/netplan/00-installer-config.yaml
# enp0s25 has a static DHCP assignment (192.168.0.110)
# wifi manually assigns the same IP
##
# This is the network config written by 'subiquity'
network:
ethernets:
enp0s25:
dhcp4: true
optional: true
version: 2
wifis:
wlp3s0:
optional: true
access-points:
"BSSID":
password: "PASSWORD"
dhcp4: no
addresses:
- 192.168.0.110/24
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses: [192.168.0.1]
@Meatballs1
Copy link
Author

Remember to netplan apply and systemctl enable networkd-dispatcher and systemctl restart networkd-dispatcher to reload the scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment