- Grab all your wireguard configs from Mullvad and dump them in a folder. For this test, this folder is
~/wireguard/
. - Add the following function to generate a list of all servers you have configs for
lswg () {
ls ~/wireguard/ | cut -d '-' -f 2 | sed 's/\.conf//'
}
- Ping each server 10 times to determine latency.
lswg | xargs -I {} ping -c 10 {}-wireguard.mullvad.net | tee mullvadwgstats
- Programmatically determine the fastest servers with some epic bash-fu
grep transmitted mullvadwgstats | awk '{print $10}' | sed 's/ms//' | sort -n | head -n1 | xargs -I {} grep -C1 {} mullvadwgstats
The result from the last command will be something like this:
--- cz1-wireguard.mullvad.net ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9002ms
rtt min/avg/max/mdev = 167.181/186.360/272.822/32.254 ms
--
--- se4-wireguard.mullvad.net ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9002ms
rtt min/avg/max/mdev = 162.903/164.410/168.176/1.525 ms
- First we get a list of all available servers using the local copy of wireguard configs
- Then we ping each server 10 times to establish a baseline for each. This output is also written to a file which will be used later.
- grep for the
transmitted
word which lets us grab the stats line, use 'awk' to get the final ping time, remove thems
suffix, sort it, grab the first item, then use that to find the server name from the origianl stats file.