moby: Docker IPv6 (ip6tables) support breaks unrelated bridges

Description

On a system running Docker 27.1.2 alongside with KVM/libvirt with it’s own separate bridge, I’ve observed that IPv6 stopped working in virtual machines. It turns out that all IPv6 multicast packets don’t make it through the bridge.

Ultimately, disabling filtering helped:

sysctl -w net.bridge.bridge-nf-call-ip6tables=0

I then was able to pinpoint Docker to be responsible. It seems that Docker adds a default DROP rule in the FORWARDING chain:

# ip6tables -L
...
Chain FORWARD (policy DROP)
...

When not starting Docker (or with ip6tables disabled), the default value of ACCEPT makes IPv6 in virtual machines just work fine.

I’ve also noticed that the IPv4 FORWARD chain uses default ACCEPT.

Is the DROP for the IPv6 FORWARD chain intentional/required?

Reproduce

  1. Check ip6tables -L and observe the default for FORWARD rule is ACCEPT
  2. Start docker with --ip6tables true
  3. Check ip6tables -L and observe new default for FORWARD rule.

Expected behavior

No response

docker version

Client:
 Version:           27.1.2
 API version:       1.46
 Go version:        go1.23.0
 Git commit:        d01f264bcc
 Built:             Sun Aug 18 14:43:14 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          27.1.2
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.23.0
  Git commit:       f9522e5e96
  Built:            Sun Aug 18 14:43:14 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.20
  GitCommit:        8fc6bcff51318944179630522a095cc9dbf9f353.m
 runc:
  Version:          1.1.13
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    27.1.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.16.2
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.29.2
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 135
  Running: 1
  Paused: 0
  Stopped: 134
 Images: 371
 Server Version: 27.1.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: journald
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353.m
 runc version: 
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.42-1-lts
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 32
 Total Memory: 62.01GiB
 Name: allenwind
 ID: 4YKC:JPTF:AI6R:AV34:KFP6:PR3Y:J72G:OEHE:3ZH2:OM3Y:6M52:HUFJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: agners
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Oops, I forgot I had the following override, which was overwritten: ExecStartPost=/usr/sbin/ip6tables -P FORWARD ACCEPT

What is the proper way to fix this issue with the updated verison of docker?

Hi @jpiszcz - I don’t think there was a change in this area between 27.3 and 27.4, unless running with userland-proxy disabled. So, the workaround should be the same … your ExecStartPost should still work - did putting it back fix things?

With "ip6tables": true, the ip6tables filter-FORWARD policy would always have been set to DROP … my understanding is that it became a problem when we enabled ip6tables by default in 27.0 - for anyone previously running with "ip6tables": false, who also had VMs/bridges that depended on IPv6 filter-FORWARD policy ACCEPT.

In upcoming release 28.0 (probably January), we’ve removed the dependency on the filter-FORWARD chain’s default policy for both IPv4 and IPv6, docker’s own rules now make sure unwanted packets are dropped. There will be a new daemon option --ip-forward-no-drop (or "ip-forward-no-drop": true in daemon.json) to stop dockerd from updating the filter-FORWARD policy to DROP, even when it enables IP forwarding … it has to be opt-in rather than the default, because not setting the policy could be a security issue.

I may be overstretching this issue now, but I’ve just discovered that container<->container communication is blocked by DOCKER-ISOLATION-STAGE-2 when using --gateway_mode_ipv6=routed even when ports are explicitly published for a given container. I’d have that down as a bug. My use-case is that I have containers with well-known addresses in DNS (humour me here) and some services communicate with others running in containers on the same host for various things; let’s take Prometheus scrapes for example. My Prometheus server cannot scrape various containers on their well-known addresses because they don’t happen to be in the same Docker network… What’s even more wild is that because of the routing, if these existed on separate hosts it would work. Now afaik this problem didn’t exist in Docker v26.x (for IPv4 or IPv6, even) which I’ve been running for a while although I’m not quite sure what changed. Maybe Docker isn’t intended to be used like this 🤔

Ah, yes - thank you @frebib … with mode routed we had external access in mind, particularly for people who want to do IPv6 without any NAT. But it is weird that containers on neighbouring networks don’t get access. It needs more thought - would you mind raising this one as a separate issue?