this post was submitted on 29 Sep 2025
32 points (92.1% liked)

Selfhosted

53179 readers
1259 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
32
Need help with VPN (lemmy.dbzer0.com)
submitted 2 months ago* (last edited 1 month ago) by imetators@lemmy.dbzer0.com to c/selfhosted@lemmy.world
 

I currenly reside in a country with strict piracy rules but also have access to the internet in a country where piracy is not enforced. I want to setup a VPN and route qBittorrent's traffic through it. The idea is to do something like this:

I am fresh to selfhosting and most of the time have no clue how to achieve what I want. So far I have tried Tailscale but I think it won't work how I want it to. If it helps, I have domain name registered. Can anybody point me to the right direction?

Update (if anyone is seeking answers):

I went with tailscale which I have already set up before on the rpi3. Somehow, no matter what I try, wireguard or pivpn would not work. Maybe I have hands growing out of my ass or something, no idea.

What did work is Dante. I setup socks5 on pi through tailscale0 and it worked wonders. Qbittorent did connect and detected IP of rpi3. The best part is that opposed to wireguard, dedicated port does not have to be open in order for Dante to work. I see it as a win win! Now I'm hyped to go back to my homeland and install pi there.

top 17 comments
sorted by: hot top controversial new old
[–] abominable_panda@lemmy.world 9 points 2 months ago* (last edited 2 months ago) (1 children)

Raspberry Pi:

  1. Install wireguard (as a server)
  2. Set up a peer/client config
  3. Open wireguard port on the router

MiniPC:

  1. Install wireguard (as a client)
  2. Add server config and connect to server
  3. Verify connection
  4. Ensure connect on boot

Points to note:

  • Configure them both locally and ensure you have a connection before you move the pi to another country

  • If you're behind a CGNAT on one network, that'll change some things. That network will have to be the client. (If both are behind CGNAT, you're out of luck and cant use this - will have to be tailscale or other method)

  • If using a domain name make sure its always pointing to your ip (in case it's not static)

  • I think if you set allowed ip as 0.0.0.0/0 on the client it'll route all traffic.

Edit:

Saw your comment about just having qbt use the vpn. Check this guide out

[–] imetators@lemmy.dbzer0.com 4 points 2 months ago

I will look into WireGuard! Thank you!

[–] wesker@lemmy.sdf.org 5 points 2 months ago* (last edited 2 months ago) (1 children)

Why can't you just use a VPN service, locally? It's essentially the same thing, except you don't have to host the exit node in country B yourself.

Tailscale is wireguard behind the scenes. I would think it should be able to work as you describe, you would again just set your machine in country B as the exit node.

None of this should require a domain name.

[–] imetators@lemmy.dbzer0.com 2 points 2 months ago

I have to pay for a VPN service. If I can skip paying by hosting it myself, I'd go the distance. It has been fun selfhosting services so far. I want to go deeper.

[–] Atherel@lemmy.dbzer0.com 5 points 2 months ago (2 children)

Wireguard on the pi was already mentioned.

If you use docker containers, you could use Gluetun to route its traffic through the VPN. Without containers, on Linux you can use firejail to restrict qBittrorrent to the vpn interface. On windows... no idea, sry.

[–] imetators@lemmy.dbzer0.com 2 points 2 months ago

MiniPC runs Mint. I will check firejail. Thank you!

[–] wesker@lemmy.sdf.org 1 points 1 month ago* (last edited 1 month ago) (1 children)

Doesn't firejail only allow sandboxing to an actual eth or wifi interface, and not a wireguard one? I've tried this before with firejail, and hit this wall.

[–] Atherel@lemmy.dbzer0.com 1 points 1 month ago

Damn you're right, it doesn't work out of the box like I expected. Have to admit that I never used it this way around. But it should work with --netns (network name spaces) which Wireguard uses: https://www.wireguard.com/netns/

Afaik it should work if you move Wireguard to it's own namespace and than start qBittorrent with the new namespace (should even be doable without firejail).

@imetators @lemmy.dbzer0.com sorry for chasing you down that rabbit-hole, it sounded easier in my head

[–] Borger@lemmy.blahaj.zone 4 points 2 months ago (1 children)

You can absolutely use Tailscale; your host in the unrestricted country needs to be set up as an exit node (CLI argument in Linux, or a menu option in the system tray in Windows.)

Then, your local machine needs to be set up to use that remote machine as its exit node. (tailscale up --exit-node=remote-tailnet-ip-here)

[–] imetators@lemmy.dbzer0.com 2 points 2 months ago (1 children)

I am thinking to do this but only one thing bothers me. I want only qBittorrent to be using VPN, not the rest of the machine. Is there a way to set only qBittorrent with Tailscale?

[–] Borger@lemmy.blahaj.zone 1 points 2 months ago

Ah, sorry I hadn't appreciated you were after split tunnelling... You can do this with Tailscale for services where you're connecting to a fixed IP/FQDN, which I think rules out torrenting/P2P unfortunately.

The only way I've seen to pass a specific app's traffic through Tailscale appears to be an Android exclusive feature.

If I'm wrong someone please correct me!

[–] plantsmakemehappy@lemmy.world 4 points 2 months ago

A second option for docker is the hotio image for qbit. Has VPN support built in so you can just throw it your wg0 conf to use.

[–] zer0bitz@lemmy.world 3 points 1 month ago

Check out I2P. No need for this setup.

[–] dudenas@piefed.social 3 points 2 months ago

I cannot resist enjoyng the idea that there could be countries where piracy is enforced :)

[–] nitrolife@rekabu.ru 1 points 2 months ago

You can use socks server for download toorrents. Best choise insert socks traffic to wireguard connection and use sockd for outgoing and clean wireguard + port forwarding for incoming connections.

And you can use i2p network for download torrents in that networks. qBittorrent support it in experimental mode.

[–] MajesticTechie@feddit.uk 1 points 2 months ago

run installer curl -L https://install.pivpn.io/ | bash

  • configure wireguard
  • setup non root user
  • Set a port

Create a user with pivpn add

Example:

root@funhaus:~# pivpn add
Enter a Name for the Client: user.name

The conf file can also be found in /home/user.name/configs

Copy the conf to your machine. Install WireGuard and use that conf.

In qbitorrent you should make sure the application is set to use the VPN network, otherwise it'll use both. Go to Settings > Advanced > Set Wireguard from "Network Interface"

[–] quant@leminal.space 1 points 1 month ago

Check if that raspberry pi is behind CGNAT. In that case you'll need something else to tunnel through, like Tailscale that was mentioned elsewhere.