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
mullvad.nix enables services.mullvad-vpn,
relaxes reverse-path filtering to loose because Mullvad
routes by firewall mark, and persists the account and device key
(/etc/mullvad-vpn, ~/.config/Mullvad VPN) so a
reboot does not require a new loginqbittorrent.nix installs qBittorrent bound to the
wg0-mullvad interfaceThe account number is the only credential. Each logged-in device registers its own key, and one account allows five devices.
Log in once per machine, then verify the tunnel:
mullvad account login <account-number>
mullvad connect
curl https://am.i.mullvad.net/connectedThe 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 onConfirm the mesh still works while connected:
ping -c 2 10.100.0.1The GUI covers everything below. The CLI equivalents:
mullvad connect
mullvad disconnect
mullvad status
mullvad relay set location se got
mullvad relay listrelay 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.
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-mullvadMullvad no longer offers port forwarding, so incoming peer connections cannot reach the machine. Downloads and seeding to peers qBittorrent connects to still work.
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