My vpn provider (mullvad) will send me as many wireguard confs as I want, one for each of their servers. I can restrict it to region/city if I want, or pick and choose. In order to just randomly select one I added a copy command to the wg-quick service for the 'mullvad' interface.
First, copy all the configs to a good location. I chose to just dump them in /etc/wireguard. Next copy one of them to <interface-name-of_choice>.conf. Up the interface once with wg-quick:
sudo systemctl start <interface-name-of_choice>@interfaceName
Next find the created service file. Mine is
/etc/systemd/system/multi-user.target.wants/wg-quick@interfaceName.service
Add an ExecStartPre
to the [Service]
section that does something like this:
ExecStartPre=/usr/bin/fish -c "cp (ls /etc/wireguard/us-sjc-wg-* | shuf -n 1) /etc/wireguard/mullvad.conf"
And yes this is me playing with Lemmy for the first time but still trying to be relevant.