Wireguard VPN setup

The delay doesn’t have to be that long (at least in my experience) - “sleep 1” was enough, albeit twice… and with some commands run in between, which probably take 0.1 seconds too. :smile:
The idea is to pick a random tunnel at start, resulting in the following, in rc.local:

sleep 1
RVPN=$(nmcli connection show | awk '/wireguard/ {print $1}' | \
        sort -R | head -n 1)
date +'%Y%m%d %H:%M:%S: '"${RVPN}" >> /tmp/chosen
sleep 1
nmcli connection up "${RVPN}"

This works 100% on my machines.

1 Like