Lxd/lxc container with rtorrent - how to connect with rutorrent?

rtorrent
openvpn
container
lxc
rutorrent

#1

Hey folks,

I need some help with my configuration. I installed QB a few weeks ago and everything works like a charm. Thank you!
The only thing I am missing is the ability to use a vpn for torrenting.
I know I could redirect all rtorrent traffic through tun0 with sophisticated iptable rules. But I don’t want to mess with that. My Server works really well and I don’t want too much downtime or even damage something.
That’s why I came up with the idea to run a container specifically for rtorrent.

This is my setup:

  • dedicated server: Ubuntu 16.04 with QB (Plex, etc)
    - privileged lcd/lxc container: Ubuntu 16.04 with openvpn + rtorrent

My question is: How can I connect rutorrent (QuickBox) with rtorrent (container)?
My goal is to replace QB rtorrent with lxc rtorrent in order to use QB with little to no restraints.

Do you guys think this is possible?


#2

Using iptables to forward rtorrent traffic through vpn is not that hard. It is actually just two lines.
create a cron that executes at boot with:
ip route add default via Gateway_IP table 10
ip rule add from SERVER/CONTAINER_IP table 10

You have the same issues with running rtorrent in a container as you do on a regular server. After all, a container is just a server inside a server … if you follow.

As for your question. you can run the Quickbox install inside the container and forward the ports 80/443 to the container.

iptables -t nat -I PREROUTING -i ETH0(eg only) -p TCP -d SERVER_IP --dport 80 -j DNAT --to-destination CONTAINER_IP:80

Dont ask me to explain this stuff, i just know it works.