Created
October 27, 2021 02:04
-
-
Save neilbags/02510631e6addfbeafb9d22d09fcb505 to your computer and use it in GitHub Desktop.
/etc/NetworkManager/dispatcher.d/50-wireguard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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