librenms / docker

LibreNMS Docker image
MIT License
691 stars 278 forks source link

Interface not assigned inet6 IPv6 address #196

Open syserr0r opened 3 years ago

syserr0r commented 3 years ago

Behaviour

Steps to reproduce this issue

  1. Ensure docker set-up for IPv6
  2. docker-compose up -d
  3. docker-compose exec librenms ash -c 'ip -6 addr show dev eth0'

Expected behaviour

Actual behaviour

Configuration

/etc/docker/daemon.json

{
  "ipv6": true,
  "fixed-cidr-v6": "2a02:390:XXXX:0:d0c::/80"
}

docker-compose.yml

(As current example from https://github.com/librenms/docker/blob/master/examples/compose/docker-compose.yml)

version: "3.5"

services:
  db:
    image: mariadb:10.5
    container_name: librenms_db
    command:
      - "mysqld"
      - "--innodb-file-per-table=1"
      - "--lower-case-table-names=0"
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_unicode_ci"
    volumes:
      - "./db:/var/lib/mysql"
    environment:
      - "TZ=${TZ}"
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=${MYSQL_DATABASE}"
      - "MYSQL_USER=${MYSQL_USER}"
      - "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
    restart: always

  memcached:
    image: memcached:alpine
    container_name: librenms_memcached
    environment:
      - "TZ=${TZ}"
    restart: always

  redis:
    image: redis:5.0-alpine
    container_name: librenms_redis
    environment:
      - "TZ=${TZ}"
    restart: always

  msmtpd:
    image: crazymax/msmtpd:latest
    container_name: librenms_msmtpd
    env_file:
      - "./msmtpd.env"
    restart: always

  librenms:
    image: librenms/librenms:latest
    container_name: librenms
    hostname: librenms
    cap_add:
      - NET_ADMIN
      - NET_RAW
    ports:
      - target: 8000
        published: 8000
        protocol: tcp
    depends_on:
      - db
      - memcached
      - msmtpd
    volumes:
      - "./librenms:/data"
    env_file:
      - "./librenms.env"
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=60"
      - "REDIS_HOST=redis"
      - "REDIS_PORT=6379"
      - "REDIS_DB=0"
#    sysctls:
#      - "net.ipv6.conf.all.disable_ipv6=0"
#      - "net.ipv6.conf.default.disable_ipv6=0"
#      - "net.ipv6.conf.eth0.disable_ipv6=0"
#      - "net.ipv6.conf.lo.disable_ipv6=0"
    restart: always

  dispatcher:
    image: librenms/librenms:latest
    container_name: librenms_dispatcher
    hostname: librenms-dispatcher
    cap_add:
      - NET_ADMIN
      - NET_RAW
    depends_on:
      - librenms
      - redis
    volumes:
      - "./librenms:/data"
    env_file:
      - "./librenms.env"
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=60"
      - "DISPATCHER_NODE_ID=dispatcher1"
      - "REDIS_HOST=redis"
      - "REDIS_PORT=6379"
      - "REDIS_DB=0"
      - "SIDECAR_DISPATCHER=1"
#    sysctls:
#      - "net.ipv6.conf.all.disable_ipv6=0"
#      - "net.ipv6.conf.default.disable_ipv6=0"
#      - "net.ipv6.conf.eth0.disable_ipv6=0"
#      - "net.ipv6.conf.lo.disable_ipv6=0"
    restart: always

  syslogng:
    image: librenms/librenms:latest
    container_name: librenms_syslogng
    hostname: librenms-syslogng
    cap_add:
      - NET_ADMIN
      - NET_RAW
    depends_on:
      - librenms
    ports:
      - target: 514
        published: 514
        protocol: tcp
      - target: 514
        published: 514
        protocol: udp
    volumes:
      - "./librenms:/data"
    env_file:
      - "./librenms.env"
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=60"
      - "REDIS_HOST=redis"
      - "REDIS_PORT=6379"
      - "REDIS_DB=0"
      - "SIDECAR_SYSLOGNG=1"
    restart: always

.env

MYSQL_DATABASE=librenms
MYSQL_USER=librenms
MYSQL_PASSWORD=long_password_here

SMTP_SERVER=mail.domain.com
SMTP_USERNAME=user@domain.com
SMTP_PASSWORD=long_password_here

TZ=Europe/London
PUID=1000
PGID=1000

librenms.env

MEMORY_LIMIT=256M
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=192.168.1.0/24
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=remote_addr
LISTEN_IPV6=true

LIBRENMS_WEATHERMAP=true
LIBRENMS_WEATHERMAP_SCHEDULE=*/5 * * * *

LIBRENMS_POLLER_THREADS=16
LIBRENMS_POLLER_INTERVAL=5

LIBRENMS_CRON_DISCOVERY_ENABLE=true
LIBRENMS_CRON_DAILY_ENABLE=true
LIBRENMS_CRON_ALERTS_ENABLE=true
LIBRENMS_CRON_BILLING_ENABLE=true
LIBRENMS_CRON_BILLING_CALCULATE_ENABLE=true
LIBRENMS_CRON_CHECK_SERVICES_ENABLE=true
LIBRENMS_CRON_POLLER_ENABLE=true

LIBRENMS_SNMP_COMMUNITY=librenmsdocker
MEMCACHED_HOST=memcached
MEMCACHED_PORT=11211
RRDCACHED_HOST=rrdcached
RRDCACHED_PORT=42217

APP_TRUSTED_PROXIES=192.168.1.5
LIBRENMS_BASE_URL=https://librenms.sitename.domain.com/
ASSET_URL=https://librenms.sitename.domain.com/

msmtpd.env

# https://github.com/crazy-max/docker-msmtpd
SMTP_HOST=mail.domain.com
SMTP_PORT=587
SMTP_TLS=on
SMTP_STARTTLS=on
SMTP_TLS_CHECKCERT=on
SMTP_AUTH=on
SMTP_USER=user@domain.com
SMTP_PASSWORD=long_password_here
SMTP_FROM=librenms@sitename.domain.com

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.7.0)

Server:
 Containers: 9
  Running: 7
  Paused: 0
  Stopped: 2
 Images: 6
 Server Version: 20.10.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.19.0-16-amd64
 Operating System: Debian GNU/Linux 10 (buster)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 1.936GiB
 Name: librenms
 ID: XGJA:XRXU:MALB:6NEO:VSSZ:TTF3:IZIV:H7ZZ:6O7Y:S3RP:BEWA:W4RA
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

Additional info

Adding these lines to the librenms service in docker-compose.yml:

    sysctls:
      - "net.ipv6.conf.all.disable_ipv6=0"

and running the same steps above gives a loopback address but no public address:

227: eth0@if228: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 state UP
    inet6 fe80::42:acff:fe13:6/64 scope link
       valid_lft forever preferred_lft forever

Running the same command on the the crazymax/alpine-s6 image that this is based on works fine:

It appears something is stopping the ipv6 interface config from happening