Connecting to a Random Mullvad Wireguard Host
512 words · 3 minutes
If you're using an OS that doesn't support one of Mullvad's apps, you're likely using the Wireguard configuration files instead.
If not, the first step is to visit Mullvad's Wireguard configuration files page and download a ZIP of the configuration files you want to use.
Personally, I downloaded all configuration files across the world and choose my connections using the script below.
Once the files are downloaded, unzip them and move them to your preferred location:
Creating a Script to Connect to a Random Host
Once you have a folder of Wireguard configuration files from Mullvad, you can create a script to randomly connect to any one of the locations.
Start by creating a shell script - mine is called
Within this script, you can paste the following info. Note that I specify
us-* in my script, which means that it will only consider US-based VPN locations. You can alter this or simply change it
* to consider all locations.
#!/bin/sh | | |while ; do # Replace `doas` with `sudo` if your machine uses `sudo`, # or remove `doas` if users don't need to su to run wg-quick ; ; done
Once you've modified the script to your liking, add executable permissions and run the script:
The output should look like the following:
doas (user@host) password: # ... The script will process all of the iptables and wg commands here Created Mullvad wireguard connection with file: /home/user/mullvad/us-nyc-wg-210.conf Printing new IP info: 126.96.36.199 curl/7.87.0
That's all there is to it. You can see your new location and IP via the
curl commands included in the script.
You can also go to the Connection Check | Mullvad page to see if you are fully connected to Mullvad and if any leaks exist.
Disconnecting from the Wireguard Connection
If you forget which connection you're using, you can execute the following command to see where Wireguard is currently connected:
This command will show you the Wireguard interfaces and should output a connection like so:
Once you have this, just disconnect using that files' full path:
I have a TODO item on figuring out how to easily export an environment variable that contains the configuration file's full name, so that I can just execute the following:
# Ideal situation if I can export the $file variable to the environment
If you have an idea on how to do this, send me an email!