Skip to content

Bug: MTU auto-discovery finds MTU too high causing DNS timeouts #3108

@jtechbyte

Description

@jtechbyte

Is this urgent?

None

Host OS

Ubuntu 24.04.3 LTS

CPU arch

x86_64

VPN service provider

NordVPN

What are you using to run the container

docker-compose

What is the version of Gluetun

latest

What's the problem 🤔

When running Gluetun with WireGuard in userspace, the MTU auto-discovery feature always sets tun0 to 1440, ignoring the WIREGUARD_MTU environment variable. This causes DNS timeouts and breaks any container using network_mode: service:gluetun. Even setting WIREGUARD_MTU has no effect.

A manual workaround is to reset the MTU after startup:

docker exec -it gluetun sh -c "ip link set tun0 mtu 1360"

This fixes DNS and restores network functionality.

fully automatic workaround is to run Gluetun in userspace mode with a small command wrapper that sets the MTU after tun0 comes up. For example:

environment:

  • WIREGUARD_IMPLEMENTATION=userspace
    volumes:
  • ./wireguard:/gluetun/wireguard
    entrypoint: /gluetun-entrypoint
    command: []

This ensures tun0 always uses MTU 1360, fixing DNS and network functionality for containers using network_mode: service:gluetun, and persists across restarts without manual commands.

Share your logs (at least 10 lines)

2026-01-23T17:03:07Z INFO [routing] default route found: interface eth0, gateway 172.21.0.1, assigned IP 172.21.0.2 and family v4
2026-01-23T17:03:07Z INFO [dns] using plaintext DNS at address 1.1.1.1
2026-01-23T17:03:07Z INFO [healthcheck] listening on 127.0.0.1:9999
2026-01-23T17:03:07Z INFO [firewall] allowing VPN connection...
2026-01-23T17:03:07Z INFO [wireguard] Using available kernelspace implementation
2026-01-23T17:03:07Z INFO [wireguard] Connecting to 185.172.52.134:51820
2026-01-23T17:03:07Z INFO [wireguard] Wireguard setup is complete
2026-01-23T17:03:29Z ERROR [vpn] getting public IP address information: fetching information: all fetchers failed: ipinfo: Get "https://ipinfo.io/": dial tcp: lookup ipinfo.io on 127.0.0.1:53: i/o timeout
2026-01-23T17:03:29Z ERROR [vpn] ifconfig.co: Get "https://ifconfig.co/json": dial tcp: lookup ifconfig.co on 127.0.0.1:53: i/o timeout
2026-01-23T17:03:29Z ERROR [vpn] ip2location: Get "https://api.ip2location.io/": dial tcp: lookup api.ip2location.io on 127.0.0.1:53: i/o timeout

Share your configuration

---

services:
  gluetun:
    image: qmcgaw/gluetun:latest
    container_name: gluetun
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    ports:
      - "9000:9000" # comet
    environment:
      - VPN_SERVICE_PROVIDER=custom
      - VPN_TYPE=wireguard
      - WIREGUARD_CONF_FILE=wg0.conf
      - FIREWALL=off
      - WIREGUARD_IMPLEMENTATION=userspace
    volumes:
      - ./wireguard:/gluetun/wireguard
    entrypoint: /bin/sh
    command: -c "/gluetun-entrypoint & while ! ip link show tun0 >/dev/null 2>&1; do sleep 1; done; ip link set tun0 mtu 1360; wait"

  postgres:
    image: postgres:17.7
    container_name: comet_postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres_user
      POSTGRES_PASSWORD: <REDACTED>
      POSTGRES_DB: cometdb
    volumes:
      - comet_postgres_data:/var/lib/postgresql/data

  comet:
    container_name: comet
    image: ghcr.io/g0ldyy/comet:latest
    network_mode: service:gluetun
    restart: unless-stopped
    depends_on:
      - gluetun
      - postgres
    env_file:
      - .env
    volumes:
      - ./data/comet:/app/data
    healthcheck:
      test: wget -qO- http://127.0.0.1:9000/health
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s

volumes:
  comet_postgres_data:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions