bubuntux / nordvpn

NordVpn Docker Client
GNU Affero General Public License v3.0
743 stars 195 forks source link

Reconnecting every ~4.5 hours (v3.10.0-1) #204

Closed lv10wizard closed 3 years ago

lv10wizard commented 3 years ago

Describe the bug

The container reconnects every ~4h 30m (sometimes immediately after $RECONNECT seconds).

https://api.nordvpn.com/v1/helpers/ips/insights (wrongly?) returns "protected":false after some time.

On my Windows machine connected to United States #8867 via the NordVPN app, curl https://api.nordvpn.com/v1/helpers/ips/insights returns "protected":false even though the nordvpn site says: Your Status: Protected at the top.

curl ifconfig.me returns 23.81.176.114 (the IP of United States #8867 reported by the NordVPN app).

To Reproduce without docker CLI

Run for >5h and check the logs for reconnections.

docker-compose.yml:

version: "3"

services:
    vpn:
        image: bubuntux/nordvpn:3.10.0-1
        restart: unless-stopped
        cap_add:
            - NET_ADMIN
            - SYS_MODULE # For NordLynx (wireguard)
        sysctls:
            - net.ipv4.conf.all.rp_filter=2 # NordLynx
        devices:
            - /dev/net/tun
        environment:
            - USER=${NORD_USER} # From .env
            - PASS=${NORD_PASS} # ^^^^^^^^^
            - TECHNOLOGY=NordLynx
            - NETWORK=192.168.1.0/24

Expected behavior

The container should automatically reconnect only if there is some connection issue, not on an interval.

Logs

The vpn container has been up about 4 days. docker logs --tail=1000 vpn | grep 'Uptime:'

 Uptime: 4 hours 25 minutes 51 seconds
 Uptime: 4 hours 20 minutes 57 seconds
 Uptime: 5 minutes
 Uptime: 5 minutes
 Uptime: 5 minutes 1 second
 Uptime: 4 hours 20 minutes 56 seconds
 Uptime: 5 minutes 1 second
 Uptime: 5 minutes 1 second
 Uptime: 4 hours 40 minutes 45 seconds
 Uptime: 4 hours 35 minutes 59 seconds
 Uptime: 4 hours 20 minutes 48 seconds
 Uptime: 4 hours 21 minutes 23 seconds
 Uptime: 5 minutes
 Uptime: 4 hours 21 minutes 7 seconds
 Uptime: 5 minutes 1 second
 Uptime: 5 minutes 2 seconds
 Uptime: 4 hours 41 minutes 3 seconds
 Uptime: 4 hours 41 minutes 7 seconds
 Uptime: 4 hours 23 minutes 57 seconds
 Uptime: 5 minutes 2 seconds
 Uptime: 4 hours 21 minutes 14 seconds
 Uptime: 4 hours 20 minutes 52 seconds
 Uptime: 5 minutes
 Uptime: 3 minutes 16 seconds
 Uptime: 4 hours 40 minutes 47 seconds
 Uptime: 4 hours 31 minutes 5 seconds
 Uptime: 5 minutes
 Uptime: 4 hours 20 minutes 43 seconds
 Uptime: 4 hours 21 minutes 8 seconds
 Uptime: 4 hours 30 minutes 54 seconds
 Uptime: 4 hours 40 minutes 49 seconds
 Uptime: 4 hours 41 minutes
 Uptime: 5 minutes 2 seconds
 Uptime: 5 minutes
 Uptime: 4 hours 22 minutes 54 seconds
bubuntux commented 3 years ago

This is actually a feature and not a bug, i swear,

even if the daemon report that the connection is stable, it actually stalls and every request times out, so I put a mechanism in place to reconnects if a requests to nordvpn API takes longer than 30 seconds, this checks is made ever 5min and can be changed using env variables, Review the readme,

this also happens to me every ~ 4.20h it reconnects, but the container keeps running fine and all the containers in the network are protected at all times.

bubuntux commented 3 years ago

The real issue is at nordvpn side as far i can tell, the connection just stalls after a while,.there is not much we can do about it.

bubuntux commented 3 years ago

You could modify the reconnect interval using the env variable to something like a week or so, and after 5 hours get inside of the container and check the status of the daemon/network. Nordvpn daemon seems ok, but all the connections don't respond, we need to reconnect to make it work again.