Skip to content

Commit 1302418

Browse files
committed
Update notes about IP Forwarding and the default DROP policy
Signed-off-by: Rob Murray <[email protected]>
1 parent 4c517e9 commit 1302418

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

content/manuals/engine/network/packet-filtering-firewalls.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,36 @@ Alternatively, you can use the `dockerd --ip` flag when starting the daemon.
308308

309309
## Docker on a router
310310

311-
Docker sets the policy for the `FORWARD` chain to `DROP`. This will prevent
312-
your Docker host from acting as a router.
311+
On Linux, Docker needs "IP Forwarding" enabled on the host. So, it enables
312+
the `sysctl` settings `net.ipv4.ip_forward` and `net.ipv6.conf.all.forwarding`
313+
it they are not already enabled when it starts. When it does that, it also
314+
sets the policy of the iptables `FORWARD` chain to `DROP`.
313315

314-
If you want your system to function as a router, you must add explicit
315-
`ACCEPT` rules to the `DOCKER-USER` chain. For example:
316+
If Docker sets the policy for the `FORWARD` chain to `DROP`. This will prevent
317+
your Docker host from acting as a router, it is the recommended setting when
318+
IP Forwarding is enabled.
319+
320+
To stop Docker from setting the `FORWARD` chain's policy to `DROP`, include
321+
`"ip-forward-no-drop": true` in `/etc/docker/daemon.json`, or add option
322+
`--ip-forward-no-drop` to the `dockerd` command line.
323+
324+
Alternatively, you may add `ACCEPT` rules to the `DOCKER-USER` chain for the
325+
packets you want to forward. For example:
316326

317327
```console
318328
$ iptables -I DOCKER-USER -i src_if -o dst_if -j ACCEPT
319329
```
320330

331+
> [!WARNING]
332+
>
333+
> In releases older than 28.0.0, Docker always set the default policy of the
334+
> IPv6 `FORWARD` chain to `DROP`. In release 28.0.0 and newer, it will only
335+
> set that policy if it enables IPv6 forwarding itself. This has always been
336+
> the behaviour for IPv4 forwarding.
337+
>
338+
> If IPv6 forwarding is enabled on your host before Docker starts, check your
339+
> host's configuration to make sure it is still secure.
340+
321341
## Prevent Docker from manipulating iptables
322342

323343
It is possible to set the `iptables` or `ip6tables` keys to `false` in

0 commit comments

Comments
 (0)