I've set up a Raspberry Pi torrent server with Deluge & SABnzbd. It's all working well including Apache reverse proxy and an SSL certificate to reach it from outside my network.

To increase my privacy I want to let the torrents go over VPN via OpenVPN. I found a guide to set this up, it basically involves creating another user on the RPi that runs the Deluge & SABnzbd services and forcing all traffic of this user over the OpenVPN IP. (Guide, I already have a VPN provider that offers .openvpn connection files)

The problem I'm having is that the guide is using iptables to configure the firewall (and having the traffic go over the OpenVPN). I'm using ufw myself.

I can't find anything in the man pages of ufw so I want to ask here, is it possible to use iptables mangle & nat commands in ufw or do I need to switch my setup over from ufw to iptables?

iptables commands:

iptables -t mangle -A OUTPUT -m owner --uid-owner bittorrent -j MARK --set-mark 3
iptables -t nat -A POSTROUTING -o $1 -j SNAT --to-source $4

And the commands to disable them:

iptables -t mangle -D OUTPUT -m owner --uid-owner bittorrent -j MARK --set-mark 3
iptables -t nat -D POSTROUTING -o $1 -j SNAT --to-source $4

In both, bittorrent is the created user on the RPi.

My current ufw config, would this be easily converted to iptables if ufw doesn't support mangle & nat?:

ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 1194/udp //openvpn server
ufw allow 58846/tcp //deluge thinclient


  • I'm talking about the person in the guide. I'm using ufw and he's using iptables. Sorry for the confusion – jzegers Aug 2 '19 at 3:09
  • Just did, thanks. Hopefully my problem is clear now. – jzegers Aug 2 '19 at 3:17

So I'm just an idiot...

ufw is a frontend for iptables, iptables comes pre-installed on the Raspberry Pi and works perfectly fine together with ufw.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.