el_pedr0
Occasional Visitor
Automating ProtonVPN Port Forwarding with qBittorrent (WireGuard + Asuswrt-Merlin)
Objective
This guide explains how to automatically update qBittorrent’s listening port with the current port forwarded by ProtonVPN when using WireGuard on Asuswrt-Merlin.
Why? ProtonVPN rotates your forwarded port regularly when NAT-PMP is enabled. If qBittorrent isn’t updated, you’ll might lose incoming connections.
We’ll:
- Run ProtonVPN WireGuard on an Asuswrt-Merlin router
- Run qBittorrent on an Ubuntu host (could be bare metal, LXC, VM, etc.)
- Use a Bash script + systemd service to keep qBittorrent’s port in sync with ProtonVPN
- Store credentials safely and keep logs clean
Caution
I tested with UDP, I haven't confirmed if it works with TCP.
Prerequisites
- ProtonVPN Plus or Unlimited subscription (port forwarding requires it)
- Asus router running Asuswrt-Merlin firmware with WireGuard client configured
- ProtonVPN WireGuard profile set to:
- NAT-PMP enabled
- VPN Accelerator optional
- Reference: ProtonVPN port forwarding docs
- Ubuntu (or Debian-based) host running qbittorrent-nox or qBittorrent desktop
- A user called qbittorrent which will run and own the script (alter the relevant steps below if you use a different username)
- natpmpc installed on the Ubuntu host:
-
Code:
sudo apt update && sudo apt install natpmpc curl
-
- Access to qBittorrent’s WebUI (e.g. http://127.0.0.1:8080)
Step 1 – Test NAT-PMP with ProtonVPN
On your torrent host, run:
Code:
natpmpc -a 1 0 tcp 60 -g 10.2.0.1
- 10.2.0.1 is the default ProtonVPN WireGuard gateway (check your WG config if different).
- Output should include a mapped TCP port.
If this works, you’re good to automate.
Step 2 – Config File
Create a config file at /etc/qbportupdater.conf:
Code:
# qBittorrent updater config
QBIT_USER='admin'
QBIT_PASS='yourpassword'
QBIT_HOST='127.0.0.1:8080'
GATEWAY='10.2.0.1'
Notes:
- Wrap the password in single quotes to avoid issues with special characters (!, #, %).
- Keep this file owned by qbittorrent user and permissions 600:
-
Code:
sudo chown qbittorrent:qbittorrent /etc/qbportupdater.conf sudo chmod 600 /etc/qbportupdater.conf
-
Last edited: