Mullvad VPN

Overview

The desktop and laptop run the official Mullvad app, which provides a system-wide WireGuard tunnel, a firewall kill switch, and both a GUI and the mullvad CLI talking to the same daemon. The server uses a separate, proxy-only setup instead (reference Invidious).

Modules: modules/features/mullvad.nix and modules/features/qbittorrent.nix

The account number is the only credential. Each logged-in device registers its own key, and one account allows five devices.

First Use

Log in once per machine, then verify the tunnel:

mullvad account login <account-number>
mullvad connect
curl https://am.i.mullvad.net/connected

The WireGuard mesh (10.100.0.0/24) and the local network sit in private ranges that the app would otherwise block. Without this, SSH to the hosts and every name that resolves to a mesh address, such as inv.yhkze.net, fail with Operation not permitted while Mullvad is connected. Allow them, and enable the kill switch so no traffic leaves while the tunnel is down:

mullvad lan set allow
mullvad lockdown-mode set on

Confirm the mesh still works while connected:

ping -c 2 10.100.0.1

Daily Use

The GUI covers everything below. The CLI equivalents:

mullvad connect
mullvad disconnect
mullvad status
mullvad relay set location se got
mullvad relay list

relay set location takes a country code, optionally followed by a city code.

Split tunneling — an application can bypass the VPN while everything else stays inside it. Launch a command outside the tunnel, or exclude a running process:

mullvad-exclude <command>
mullvad split-tunnel add <pid>

Lockdown mode — with it on, disconnecting also cuts all traffic, so a dropped tunnel can never fall back to the home address.

Torrenting

qBittorrent is pinned to the wg0-mullvad interface, which only exists while the app is connected. With the VPN down there is no route for it, so transfers stall instead of leaking the home address. qbittorrent.nix merges the setting into ~/.config/qBittorrent/qBittorrent.conf on every activation, leaving the rest of the file to qBittorrent:

[BitTorrent]
Session\Interface=wg0-mullvad
Session\InterfaceName=wg0-mullvad

Mullvad no longer offers port forwarding, so incoming peer connections cannot reach the machine. Downloads and seeding to peers qBittorrent connects to still work.

Browser

LibreWolf goes through the system-wide tunnel with no extra configuration. To proxy a single browser without connecting the app, set its network proxy to a relay’s SOCKS5 endpoint, reachable only while the app is connected:

SOCKS Host: <relay>.relays.mullvad.net   Port: 1080   SOCKS v5
Proxy DNS when using SOCKS v5: enabled