@@ -11,9 +11,9 @@ Table `filter`:
1111 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
1212 num pkts bytes target prot opt in out source destination
1313 1 0 0 DOCKER-USER 0 -- * * 0.0.0.0/0 0.0.0.0/0
14- 2 0 0 DOCKER-ISOLATION-STAGE-1 0 -- * * 0.0.0.0/0 0.0.0.0/0
15- 3 0 0 ACCEPT 0 -- * docker0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
16- 4 0 0 DOCKER 0 -- * docker0 0.0.0.0/0 0.0.0.0/0
14+ 2 0 0 ACCEPT 0 -- * * 0.0.0.0/0 0.0.0.0/0 match-set docker-ext-bridges-v4 dst ctstate RELATED,ESTABLISHED
15+ 3 0 0 DOCKER-ISOLATION-STAGE-1 0 -- * * 0.0.0.0/0 0.0.0.0/0
16+ 4 0 0 DOCKER 0 -- * * 0.0.0.0/0 0.0.0.0/0 match-set docker-ext-bridges-v4 dst
1717 5 0 0 ACCEPT 0 -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0
1818 6 0 0 ACCEPT 0 -- docker0 docker0 0.0.0.0/0 0.0.0.0/0
1919
@@ -48,9 +48,9 @@ Table `filter`:
4848 -N DOCKER-ISOLATION-STAGE-2
4949 -N DOCKER-USER
5050 -A FORWARD -j DOCKER-USER
51+ -A FORWARD -m set --match-set docker-ext-bridges-v4 dst -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
5152 -A FORWARD -j DOCKER-ISOLATION-STAGE-1
52- -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
53- -A FORWARD -o docker0 -j DOCKER
53+ -A FORWARD -m set --match-set docker-ext-bridges-v4 dst -j DOCKER
5454 -A FORWARD -i docker0 ! -o docker0 -j ACCEPT
5555 -A FORWARD -i docker0 -o docker0 -j ACCEPT
5656 -A DOCKER ! -i docker0 -o docker0 -j DROP
@@ -78,17 +78,19 @@ The FORWARD chain rules are numbered in the output above, they are:
7878 Docker won't add rules to the DOCKER-USER chain, it's only for user-defined rules.
7979 It's (mostly) kept at the top of the by deleting it and re-creating after each
8080 new network is created, while traffic may be running for other networks.
81- 2 . Unconditional jump to DOCKER-ISOLATION-STAGE-1.
82- Set up during network creation by [ setupIPTables] [ 11 ] , which ensures it appears
81+ 2 . Early ACCEPT for any RELATED,ESTABLISHED traffic to a docker bridge. This rule
82+ matches against an ` ipset ` called ` docker-ext-bridges-v4 ` (` v6 ` for IPv6). The
83+ set contains the CIDR address of each docker network, and it is updated as networks
84+ are created and deleted.
85+ So, this rule could be set up during bridge driver initialisation. But, it is
86+ currently set up when a network is created, in [ setupIPTables] [ 11 ] .
87+ 3 . Unconditional jump to DOCKER-ISOLATION-STAGE-1.
88+ Set up during network creation by [ setupIPTables] [ 12 ] , which ensures it appears
8389 after the jump to DOCKER-USER (by deleting it and re-creating, while traffic
8490 may be running for other networks).
85- 3 . ACCEPT RELATED,ESTABLISHED packets into a specific bridge network.
86- Allows responses to outgoing requests, and continuation of incoming requests,
87- without needing to process any further rules.
88- This rule is also added during network creation, but the code to do it
89- is in libnetwork, [ ProgramChain] [ 12 ] .
90- 4 . Jump to DOCKER, for any packet destined for a bridge network. Added when
91- the network is created, in [ ProgramChain] [ 13 ] ("filterChain" is the DOCKER chain).
91+ 4 . Jump to DOCKER, for any packet destined for any bridge network, identified by
92+ matching against the ` docker-ext-bridge-v[46] ` set. Added when the network is
93+ created, in [ setupIPTables] [ 13 ] .
9294 The DOCKER chain implements per-port/protocol filtering for each container.
9395 5 . ACCEPT any packet leaving a network, also set up when the network is created, in
9496 [ setupIPTablesInternal] [ 14 ] .
@@ -97,9 +99,9 @@ The FORWARD chain rules are numbered in the output above, they are:
9799 [ setIcc] [ 15 ] .
98100
99101[ 10 ] : https://github.com/moby/moby/blob/e05848c0025b67a16aaafa8cdff95d5e2c064105/libnetwork/firewall_linux.go#L50
100- [ 11 ] : https://github.com/moby /moby/blob/333cfa640239153477bf635a8131734d0e9d099d /libnetwork/drivers/bridge/setup_ip_tables_linux.go#L201
101- [ 12 ] : https://github.com/moby /moby/blob/e05848c0025b67a16aaafa8cdff95d5e2c064105 /libnetwork/iptables/iptables .go#L270
102- [ 13 ] : https://github.com/moby /moby/blob/e05848c0025b67a16aaafa8cdff95d5e2c064105 /libnetwork/iptables/iptables .go#L251-L255
102+ [ 11 ] : https://github.com/robmry /moby/blob/52c89d467fc5326149e4bbb8903d23589b66ff0d /libnetwork/drivers/bridge/setup_ip_tables_linux.go#L230-L232
103+ [ 12 ] : https://github.com/robmry /moby/blob/52c89d467fc5326149e4bbb8903d23589b66ff0d /libnetwork/drivers/bridge/setup_ip_tables_linux .go#L227-L229
104+ [ 13 ] : https://github.com/robmry /moby/blob/52c89d467fc5326149e4bbb8903d23589b66ff0d /libnetwork/drivers/bridge/setup_ip_tables_linux .go#L223-L226
103105[ 14 ] : https://github.com/moby/moby/blob/333cfa640239153477bf635a8131734d0e9d099d/libnetwork/drivers/bridge/setup_ip_tables_linux.go#L264
104106[ 15 ] : https://github.com/moby/moby/blob/333cfa640239153477bf635a8131734d0e9d099d/libnetwork/drivers/bridge/setup_ip_tables_linux.go#L343
105107
0 commit comments