diff options
author | Christian Cleberg <hello@cleberg.net> | 2023-12-02 23:27:35 -0600 |
---|---|---|
committer | Christian Cleberg <hello@cleberg.net> | 2023-12-02 23:27:35 -0600 |
commit | 3d4da5ac6000a4871c5caa80d1e61f2782da3069 (patch) | |
tree | 29f36b50823d22f4c7df0a3db3ede83192ae649f /blog/2023-01-23-random-mullvad-wireguard.org | |
parent | dcf0186e16b6ac8f0e00a3aeb9734421ce548177 (diff) | |
download | cleberg.net-3d4da5ac6000a4871c5caa80d1e61f2782da3069.tar.gz cleberg.net-3d4da5ac6000a4871c5caa80d1e61f2782da3069.tar.bz2 cleberg.net-3d4da5ac6000a4871c5caa80d1e61f2782da3069.zip |
feat: finish converting md to org
Diffstat (limited to 'blog/2023-01-23-random-mullvad-wireguard.org')
-rw-r--r-- | blog/2023-01-23-random-mullvad-wireguard.org | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/blog/2023-01-23-random-mullvad-wireguard.org b/blog/2023-01-23-random-mullvad-wireguard.org index 200b498..c87f05a 100644 --- a/blog/2023-01-23-random-mullvad-wireguard.org +++ b/blog/2023-01-23-random-mullvad-wireguard.org @@ -1,47 +1,49 @@ -+++ -date = 2023-01-23 -title = "Connecting to a Random Mullvad Wireguard Host" -description = "Read to see how I used a shell script to randomly connect to a Mullvad Wireguard host each time I run the script." -+++ +#+title: Connecting to a Random Mullvad Wireguard Host +#+date: 2023-01-23 -## Mullvad Wireguard - -If you're using an OS that does not support one of Mullvad's apps, you're -likely using the Wireguard configuration files instead. +** Mullvad Wireguard +:PROPERTIES: +:CUSTOM_ID: mullvad-wireguard +:END: +If you're using an OS that does not 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](https://mullvad.net/en/account/#/wireguard-config) page and download a -ZIP of the configuration files you want to use. +[[https://mullvad.net/en/account/#/wireguard-config][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 chose my -connections using the script below. +Personally, I downloaded all configuration files across the world and +chose my connections using the script below. -Once the files are downloaded, unzip them and move them to your preferred -location: +Once the files are downloaded, unzip them and move them to your +preferred location: -```sh +#+begin_src sh cd Downloads unzip mullvad_wireguard_linux_all_all.zip mkdir ~/mullvad && mv ~/Downloads/*.conf ~/mullvad/ -``` - -## Creating a Script to Connect to a Random Host +#+end_src -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. +** Creating a Script to Connect to a Random Host +:PROPERTIES: +:CUSTOM_ID: creating-a-script-to-connect-to-a-random-host +:END: +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 `vpn.sh`. +Start by creating a shell script - mine is called =vpn.sh=. -```sh +#+begin_src sh nano ~/vpn.sh -``` +#+end_src -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. +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. -```sh +#+begin_src sh #!/bin/sh ls /home/$USER/mullvad/us-* |sort -R |tail -n 1 |while read file; do @@ -52,19 +54,19 @@ ls /home/$USER/mullvad/us-* |sort -R |tail -n 1 |while read file; do printf "\n\nPrinting new IP info:\n" curl https://am.i.mullvad.net/connected done -``` +#+end_src -Once you've modified the script to your liking, add executable permissions -and run the script: +Once you've modified the script to your liking, add executable +permissions and run the script: -```sh +#+begin_src sh chmod +x ~/vpn.sh ~/vpn.sh -``` +#+end_src The output should look like the following: -```txt +#+begin_src txt doas (user@host) password: # ... The script will process all of the iptables and wg commands here @@ -73,42 +75,45 @@ Created Mullvad wireguard connection with file: /home/user/mullvad/us-nyc-wg-210 Printing new IP info: You are connected to Mullvad (server country-city-wg-num). Your IP address is 12.345.678.99 -``` +#+end_src That's all there is to it. You can see your new location and IP via the -`printf` and `curl` commands included in the script. - -You can also go to the [Connection Check | -Mullvad](https://mullvad.net/en/check/) page to see if you are fully connected -to Mullvad and if any leaks exist. +=printf= and =curl= commands included in the script. - +You can also go to the [[https://mullvad.net/en/check/][Connection Check +| Mullvad]] page to see if you are fully connected to Mullvad and if any +leaks exist. -## Disconnecting from the Wireguard Connection +#+caption: Mullvad Connection Check +[[https://img.cleberg.net/blog/20230123-random-mullvad-wireguard/mullvad_check.png]] -If you forget which connection you're using, you can execute the following -command to see where Wireguard is currently connected: +** Disconnecting from the Wireguard Connection +:PROPERTIES: +:CUSTOM_ID: disconnecting-from-the-wireguard-connection +:END: +If you forget which connection you're using, you can execute the +following command to see where Wireguard is currently connected: -```sh +#+begin_src sh wg show -``` +#+end_src This command will show you the Wireguard interfaces and should output a -connection like so: `interface: us-lax-wg-104`. +connection like so: =interface: us-lax-wg-104=. Once you have this, just disconnect using that files' full path: -```sh +#+begin_src sh wg-quick down /home/user/mullvad/us-lax-wg-104.conf -``` +#+end_src -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: +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: -```sh +#+begin_src sh # Ideal situation if I can export the $file variable to the environment wg-quick down $file -``` +#+end_src If you have an idea on how to do this, email me! |