Skip to content

Commit 2090e5b

Browse files
authored
Updates for moby 28.0.1 (#22086)
## Description - Describe new iptables chain `DOCKER-FORWARD`, which splits Docker's rules out of the main `FORWARD` chain where they were being antisocial - related to moby/moby#49518 - Update notes about IP Forwarding and the default DROP policy - Only engine < 28.0.0 allows remote access to ports published to the localhost address ## Related issues or tickets ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review --------- Signed-off-by: Rob Murray <[email protected]>
1 parent 4264011 commit 2090e5b

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

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

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,22 @@ following custom `iptables` chains:
3232

3333
* `DOCKER-USER`
3434
* A placeholder for user-defined rules that will be processed before rules
35-
in the `DOCKER` chain.
35+
in the `DOCKER-FORWARD` and `DOCKER` chains.
36+
* `DOCKER-FORWARD`
37+
* The first stage of processing for Docker's networks. Rules that pass packets
38+
that are not related to established connections to the other Docker chains,
39+
as well as rules to accept packets that are part of established connections.
3640
* `DOCKER`
3741
* Rules that determine whether a packet that is not part of an established
3842
connection should be accepted, based on the port forwarding configuration
3943
of running containers.
4044
* `DOCKER-ISOLATION-STAGE-1` and `DOCKER-ISOLATION-STAGE-2`
4145
* Rules to isolate Docker networks from each other.
46+
* `DOCKER-INGRESS`
47+
* Rules related to Swarm networking.
4248

43-
In the `FORWARD` chain, Docker adds rules that pass packets that are not related
44-
to established connections to these custom chains, as well as rules to accept
45-
packets that are part of established connections.
49+
In the `FORWARD` chain, Docker adds rules that unconditionally jump to the
50+
`DOCKER-USER`, `DOCKER-FORWARD` and `DOCKER-INGRESS` chains.
4651

4752
In the `nat` table, Docker creates chain `DOCKER` and adds rules to implement
4853
masquerading and port-mapping.
@@ -53,6 +58,8 @@ Packets that get accepted or rejected by rules in these custom chains will not
5358
be seen by user-defined rules appended to the `FORWARD` chain. So, to add
5459
additional rules to filter these packets, use the `DOCKER-USER` chain.
5560

61+
Rules appended to the `FORWARD` chain will be processed after Docker's rules.
62+
5663
### Match the original IP and ports for requests
5764

5865
When packets arrive to the `DOCKER-USER` chain, they have already passed through
@@ -261,9 +268,9 @@ configure the daemon to use the loopback address (`127.0.0.1`) instead.
261268

262269
> [!WARNING]
263270
>
264-
> Hosts within the same L2 segment (for example, hosts connected to the same
265-
> network switch) can reach ports published to localhost.
266-
> For more information, see
271+
> In releases older than 28.0.0, hosts within the same L2 segment (for example,
272+
> hosts connected to the same network switch) can reach ports published to
273+
> localhost. For more information, see
267274
> [moby/moby#45610](https://github.com/moby/moby/issues/45610)
268275
269276
To configure this setting for user-defined bridge networks, use
@@ -301,16 +308,36 @@ Alternatively, you can use the `dockerd --ip` flag when starting the daemon.
301308

302309
## Docker on a router
303310

304-
Docker sets the policy for the `FORWARD` chain to `DROP`. This will prevent
305-
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`.
315+
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.
306319

307-
If you want your system to function as a router, you must add explicit
308-
`ACCEPT` rules to the `DOCKER-USER` chain. For example:
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:
309326

310327
```console
311328
$ iptables -I DOCKER-USER -i src_if -o dst_if -j ACCEPT
312329
```
313330

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+
314341
## Prevent Docker from manipulating iptables
315342

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

0 commit comments

Comments
 (0)