Skip to content

Instantly share code, notes, and snippets.

@neilbags
Created October 27, 2021 02:04
Show Gist options
  • Save neilbags/02510631e6addfbeafb9d22d09fcb505 to your computer and use it in GitHub Desktop.
Save neilbags/02510631e6addfbeafb9d22d09fcb505 to your computer and use it in GitHub Desktop.
/etc/NetworkManager/dispatcher.d/50-wireguard
#!/bin/sh -e
WLAN_DEV=wlan0
HOME_GATEWAY=192.168.2.1
WG_NAME=wg-home
if [ "$2" = "connectivity-change" ]; then
exit 0;
fi
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
if [ "$2" = "up" ] && [ "$DEVICE_IFACE" = "$WLAN_DEV" ]; then
/usr/bin/wg-quick down $WG_NAME || true
if [ "$IP4_GATEWAY" != "$HOME_GATEWAY" ]; then
/usr/bin/wg-quick up $WG_NAME || true
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment