<coded>


Mullvad Batch Script to randomize IP address

April 9, 2025

Having a secure VPN is always a good thing. With installing Mullvad it comes with a CLI, which let's you do everything you can do in the GUI version. The idea is to also change your IP from time to time even if your on a VPN.

Here is an example Batch Script you can run every e.g. 4-6 hours (up to you) to randomly select from a pool of available servers on Mullvad.

1. Check all available servers/regions

Type this command to get all server locations with their respective language code. For Switzerland you will get "ch" as code.

mullvad relay list

2. Ready Batch Script: Mullvad Security Randomizer

You can also extend the already given server regions by your own in the script. But this 9 already defined regions are sorted from highest security from top to down. All others not listed here, are not recommended depending on privacy by the respective country.

@echo off
setlocal

echo ===============================
echo   MULLVAD SECURITY RANDOMIZER
echo ===============================
echo.
echo Selections are sorted from most secure from top to down
echo.
echo [1] - Switzerland
echo [2] - Romania
echo [3] - Malaysia
echo [4] - Norway
echo [5] - Finland
echo [6] - Estonia
echo [7] - Czech Republic
echo [8] - Croatia
echo [9] - Slovenia
echo.

set /p choice=Please select your new location now: 

if "%choice%"=="1" (
    echo.
    echo Switching location now ...
    mullvad relay set location ch
    goto done
)

if "%choice%"=="2" (
    echo.
    echo Switching location now ...
    mullvad relay set location ro
    goto done
)

if "%choice%"=="3" (
    echo.
    echo Switching location now ...
    mullvad relay set location my
    goto done
)

if "%choice%"=="4" (
    echo.
    echo Switching location now ...
    mullvad relay set location no
    goto done
)

if "%choice%"=="5" (
    echo.
    echo Switching location now ...
    mullvad relay set location fi
    goto done
)

if "%choice%"=="6" (
    echo.
    echo Switching location now ...
    mullvad relay set location ee
    goto done
)

if "%choice%"=="7" (
    echo.
    echo Switching location now ...
    mullvad relay set location cz
    goto done
)

if "%choice%"=="8" (
    echo.
    echo Switching location now ...
    mullvad relay set location hr
    goto done
)

if "%choice%"=="9" (
    echo.
    echo Switching location now ...
    mullvad relay set location si
    goto done
)

echo.
echo Invalid selection!
goto end

:done
echo.
mullvad disconnect
echo Disconnecting ...
timeout /t 3 >nul
echo Reconnecting ...
mullvad connect
timeout /t 3 >nul
mullvad relay get
echo.
echo Connection established!

:end
endlocal
pause

3. Add this Batch to your Windows

You can automate this now by adding the script to your Windows Tasks and execute it from time to time, to switch your Mullvad IP randomly. The script is made so you can select the region by typing 1-9 when it executes. You can of course refactor it to make it select a region fully random. But this gives you more control, also when it comes to connection speed (Ping).

4. Extended Version in AHK v2

https://github.com/rizzn/Mullvad-VPN-Controller
Did you find this useful? Please rate this post: