Skip to content

[BUG] Too slow peer generation #384

@sergeich5

Description

@sergeich5

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Too slow peer generation when attempting to create as many peers as possible (253). Seems like generation depends on previously generated peers and looks like the quadratic complexity of the algorithm

Expected Behavior

No response

Steps To Reproduce

  1. PEERS=253
  2. docker-compose.yml
services:
  wireguard:
    image: lscr.io/linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - SERVERURL=auto #optional
      - SERVERPORT=51820 #optional
      - PEERS=253 #optional
      - PEERDNS=8.8.8.8 #optional
      - INTERNAL_SUBNET=10.13.13.0 #optional
      - ALLOWEDIPS=0.0.0.0/0 #optional
      - LOG_CONFS=false
    volumes:
      - ./config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped
  1. Run docker compose up
  2. Too slow generation

Environment

- OS:
- How docker service was installed:

CPU architecture

x86-64

Docker creation

services:
  wireguard:
    image: lscr.io/linuxserver/wireguard
    container_name: wireguard
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - SERVERURL=auto #optional
      - SERVERPORT=51820 #optional
      - PEERS=253 #optional
      - PEERDNS=8.8.8.8 #optional
      - INTERNAL_SUBNET=10.13.13.0 #optional
      - ALLOWEDIPS=0.0.0.0/0 #optional
      - LOG_CONFS=false
    volumes:
      - ./config:/config
      - /lib/modules:/lib/modules
    ports:
      - 51820:51820/udp
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
    restart: unless-stopped

Container logs

wireguard  | [migrations] no migrations found
wireguard  | ───────────────────────────────────────
wireguard  | 
wireguard  |       ██╗     ███████╗██╗ ██████╗
wireguard  |       ██║     ██╔════╝██║██╔═══██╗
wireguard  |       ██║     ███████╗██║██║   ██║
wireguard  |       ██║     ╚════██║██║██║   ██║
wireguard  |       ███████╗███████║██║╚██████╔╝
wireguard  |       ╚══════╝╚══════╝╚═╝ ╚═════╝
wireguard  | 
wireguard  |    Brought to you by linuxserver.io
wireguard  | ───────────────────────────────────────
wireguard  | 
wireguard  | To support the app dev(s) visit:
wireguard  | WireGuard: https://www.wireguard.com/donations/
wireguard  | 
wireguard  | To support LSIO projects visit:
wireguard  | https://www.linuxserver.io/donate/
wireguard  | 
wireguard  | ───────────────────────────────────────
wireguard  | GID/UID
wireguard  | ───────────────────────────────────────
wireguard  | 
wireguard  | User UID:    1000
wireguard  | User GID:    1000
wireguard  | ───────────────────────────────────────
wireguard  | Linuxserver.io version: 1.0.20210914-r4-ls72
wireguard  | Build-date: 2025-03-27T11:24:03+00:00
wireguard  | ───────────────────────────────────────
wireguard  |     
wireguard  | Uname info: Linux 1cb234ac2c20 6.10.14-linuxkit #1 SMP PREEMPT_DYNAMIC Fri Nov 29 17:24:06 UTC 2024 x86_64 GNU/Linux
wireguard  | **** It seems the wireguard module is already active. Skipping kernel header install and module compilation. ****
wireguard  | **** As the wireguard module is already active you can remove the SYS_MODULE capability from your container run/compose. ****
wireguard  | ****     If your host does not automatically load the iptables module, you may still need the SYS_MODULE capability.     ****
wireguard  | **** Server mode is selected ****
wireguard  | **** SERVERURL var is either not set or is set to "auto", setting external IP to auto detected value of 37.204.48.120 ****
wireguard  | **** External server port is set to 51820. Make sure that port is properly forwarded to port 51820 inside this container ****
wireguard  | **** Internal subnet is set to 10.13.13.0 ****
wireguard  | **** AllowedIPs for peers 0.0.0.0/0 ****
wireguard  | **** Peer DNS servers will be set to 8.8.8.8 ****
wireguard  | **** No wg0.conf found (maybe an initial install), generating 1 server and 253 peer/client confs ****
wireguard  | PEER 1 conf and QR code png saved in /config/peer1
wireguard  | PEER 2 conf and QR code png saved in /config/peer2
wireguard  | PEER 3 conf and QR code png saved in /config/peer3
wireguard  | PEER 4 conf and QR code png saved in /config/peer4
wireguard  | PEER 5 conf and QR code png saved in /config/peer5
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions