Page 1 of 1

frequent disconnections and openvpn

Posted: Sat May 31, 2025 4:37 pm
by joshualibrarian
So, I've got deluge running in a docker container on my headless server. I've also got openvpn running on that server, routing all traffic through a VPN. However, my internet seems to experience many sort of... micro-disconnects, which I presume is because I am on a StarLink dish, and they often switch satellites.

However, during these periods, openvpn stops working and network traffic gets through directly, which exposes my torrent client. So to deal with this, I've added `docker stop deluge` into my `/etc/openvpn/down` script, which runs when it goes down. However, trying to take it back up in the `/etc/openvpn/up` script doesn't seem to work.

This means that my deluge container comes down almost daily and has to be manually put back up. How can I limit my deluge container to only use my `tun0` network device only? Perhaps this would be better in a docker or openvpn forum, but I figured you all might know best here to proceed.

My `compose.yml` file:

Code: Select all

---
services:
  deluge:
    image: lscr.io/linuxserver/deluge:latest
    container_name: deluge
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - DELUGE_LOGLEVEL=error #optional
    volumes:
      - /var/lib/deluge/config:/config
      - /media/media/download:/downloads
      - /media/media/download:/media/media/download
      - /media/media/shows:/media/media/shows
      - /media/media/movies:/media/media/movies
    ports:
      - 8112:8112
      - 6881:6881
      - 6881:6881/udp
      - 58846:58846
    restart: unless-stopped
My vpn config file:

Code: Select all

client
remote 24.143.155.111 443
dev tun 
proto tcp
auth-user-pass /etc/openvpn/user.txt


resolv-retry infinite 
redirect-gateway def1
persist-key
persist-tun
nobind
cipher AES-256-CBC
auth SHA256
ping 5
ping-exit 60
ping-timer-rem
script-security 2
remote-cert-tls server
route-delay 5
verb 4

up /etc/openvpn/up
down /etc/openvpn/down

ca ca.crt

cert client.crt

key client.key
Thank you!

Re: frequent disconnections and openvpn

Posted: Fri Jun 06, 2025 3:02 pm
by shinger
Hello Joshua,

I believe the issues lies with OpenVPN. The VPN service that you are using if you have the possibility to use wireguard instead, i would strongly advice you to use that instead.

In the past i used NordVPN subscription using their OpenVPN service. Every now and then i would also lose the connection to the VPN server. So just like you, you had to create a script to put it back up.

The case of you wanting to use a specific interface. Yes this is indeed possible. Got to the settings of deluged. There you would see Incoming Interface and Outgoing Interface. Try to experiment with that. That way you will tell it to just ignore other interface and only accept traffice or go on the interface through those interfaces.

If you use "sudo ss -tulpn | column -t" you will see the ipaddress (or 0.0.0.0), but also the interface and port that it is listening to. Here is how it looks like with my ss output.

Code: Select all

<USER>@<SYSTEM>:~# ss -tulpn | column -t | grep deluged
udp    UNCONN  0       0       <REMOVED IPADDRESS>%enP4p65s0:10719              0.0.0.0:*     users:(("deluged",pid=811,fd=15))                                                               
udp    UNCONN  0       0       127.0.0.1%lo:10719                         0.0.0.0:*     users:(("deluged",pid=811,fd=13))                                                               
udp    UNCONN  0       0       <REMOVED IPPADDRESS>:60872                        0.0.0.0:*     users:(("deluged",pid=811,fd=18))                                                               
udp    UNCONN  0       0       0.0.0.0:6771                               0.0.0.0:*     users:(("deluged",pid=811,fd=16))                                                               
udp    UNCONN  0       0       0.0.0.0:6771                               0.0.0.0:*     users:(("deluged",pid=811,fd=17))                                                               
tcp    LISTEN  0       3000    <REMOVED IPPADDRESS>%enP4p65s0:10719              0.0.0.0:*     users:(("deluged",pid=811,fd=14))                                                               
tcp    LISTEN  0       3000    127.0.0.1%lo:10719                         0.0.0.0:*     users:(("deluged",pid=811,fd=12))                                                               
tcp    LISTEN  0       50      0.0.0.0:58846                              0.0.0.0:*     users:(("deluged",pid=811,fd=21))
The enP4p65s0 is the interface that i explicitly told deluged to use.