Skip to content

[BUG] WireGuard Container Fails to Start Due to nftables Error on Older Kernel #394

@qlaffont

Description

@qlaffont

I am encountering an issue where the WireGuard container fails to start due to a nftables error. The container is attempting to use nftables, which is not supported by my host kernel (4.4.302). Despite setting WG_USE_IPTABLES=true, the container still tries to apply nftables rules, resulting in the following error:
netlink: Error: cache initialization failed: Invalid argument

Environment

Host OS: Synology NAS
Kernel Version: 4.4.302+
Docker Version: 24.0.2
WireGuard Image: lscr.io/linuxserver/wireguard:latest

Configuration

docker-compose.yml:

version: "3.6"
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard:latest
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=1
      - net.ipv6.conf.default.disable_ipv6=1
    environment:
      - PUID=1026
      - PGID=101
      - TZ=Europe/Paris
      - WG_USE_IPTABLES=true
    volumes:
      - /volume1/backups/wireguard-vpn-relay/wg_confs:/config
    ports:
      - 63710:51820/udp
      - 51821:5000/tcp
    restart: always

wg0.conf:

PrivateKey = 
Address = 
DNS = 192.168.1.1
PostUp = sysctl -w net.ipv4.ip_forward=1; iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

[Peer]
PublicKey = 
AllowedIPs = 0.0.0.0/0
Endpoint = 
PersistentKeepalive = 25

Expected Behavior

The container should start successfully and use iptables instead of nftables when WG_USE_IPTABLES=true is set.

Actual Behavior

The container fails to start due to a nftables error, even when WG_USE_IPTABLES=true is set.

Additional Information

The host kernel (4.4.302) does not support nftables.
The container is attempting to apply nftables rules, which fails.
Setting WG_USE_IPTABLES=true does not seem to prevent the container from trying to use nftables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions