Last active 1705433148

NetworkManager dispatcher script to restart Wireguard interface on connection change

Revision d87cdbf47e98b75961fcc3007c2161786f742f26

10-wg-reload.sh Raw
1#!/bin/bash
2
3##
4## Reloads Wireguard tunnel when an interface change happens
5## Intended for use with always active full tunnels
6## Place in /etc/NetworkManager/dispatcher.d, change permissions
7## to 755 and enter your interface name to WG_INTERFACE
8## (e.g. WG_INTERFACE='wg0')
9##
10
11WG_INTERFACE=''
12
13if [[ "$1" != "$WG_INTERFACE" ]] && [[ "$2" == "up" ]]; then
14 echo "running $0" | systemd-cat -t nm-dispatcher
15 sleep 2
16 nmcli conn up $WG_INTERFACE
17fi
18
19exit 0