How to Set Up Mullvad VPN CLI in Linux

Mullvad is a VPN service with an emphasis on privacy. It supports WireGuard and is easy to set up in Linux.

I prefer to use the CLI as it allows me to map keyboard shortcuts to the commands.

Installation

Debian/Ubuntu:

wget https://mullvad.net/download/app/deb/latest/ -O mullvad-cli.deb
sudo apt install ./mullvad-cli.deb

Arch:

yay -S mullvad-vpn-cli

Configuration

First you must link your Mullvad account using your account number:

mullvad account login

To list relay locations:

mullvad relay list

To chose a relay location:

mullvad relay set location country city hostname

The city and hostname is optional. I have chose Sweden becuase all of the VPN servers are owned by Mullvad.

It is recommended to use WireGuard over OpenVPN as it is faster and more modern.

To verify WireGuard key:

mullvad tunnel wireguard key check

To generate a WireGuard key to replace your current one:

mullvad tunner wireguard key regenerate

To set the tunnel protocol to WireGuard:

mullvad relay set tunnel-protocol wireguard

To reset the tunnel protocol:

mullvad relay set tunnel-protocol any

To set tunnel protocol to OpenVPN:

mullvad relay set tunnel-protocol openvpn

To connect to VPN:

mullvad connect

To disconnect from VPN:

mullvad disconnect