Skip to content

Commit b8288c5

Browse files
authored
Merge pull request #23409 from robmry/moby29_bug_fixes
Networking docs fixes for moby 29
2 parents 59945a6 + 525496d commit b8288c5

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

content/manuals/engine/network/drivers/bridge.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ The following table describes the driver-specific options that you can pass to
118118
|-------------------------------------------------------------------------------------------------|-----------------------------|-----------------------------------------------------------------------------------------------------|
119119
| `com.docker.network.bridge.name` | | Interface name to use when creating the Linux bridge. |
120120
| `com.docker.network.bridge.enable_ip_masquerade` | `true` | Enable IP masquerading. |
121+
| `com.docker.network.host_ipv4`<br/>`com.docker.network.host_ipv6` | | Address to use for source NAT. See [Packet filtering and firewalls](packet-filtering-firewalls.md). |
121122
| `com.docker.network.bridge.gateway_mode_ipv4`<br/>`com.docker.network.bridge.gateway_mode_ipv6` | `nat` | Control external connectivity. See [Packet filtering and firewalls](packet-filtering-firewalls.md). |
122123
| `com.docker.network.bridge.enable_icc` | `true` | Enable or Disable inter-container connectivity. |
123124
| `com.docker.network.bridge.host_binding_ipv4` | all IPv4 and IPv6 addresses | Default IP when binding container ports. |

content/manuals/engine/network/drivers/macvlan.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ Keep the following things in mind:
3232
overlay (to communicate across multiple Docker hosts), these solutions may be
3333
better in the long term.
3434

35+
- Containers attached to a macvlan network cannot communicate with the host
36+
directly, this is a restriction in the Linux kernel. If you need communication
37+
between the host and the containers, you can connect the containers to a
38+
bridge network as well as the macvlan. It is also possible to create a
39+
macvlan interface on the host with the same parent interface, and assign it
40+
an IP address in the Docker network's subnet.
41+
3542
## Options
3643

3744
The following table describes the driver-specific options that you can pass to
@@ -94,15 +101,23 @@ $ docker network create -d macvlan \
94101

95102
### Use an IPvlan instead of Macvlan
96103

97-
In the above example, you are still using a L3 bridge. You can use `ipvlan`
98-
instead, and get an L2 bridge. Specify `-o ipvlan_mode=l2`.
104+
An `ipvlan` network created with option `-o ipvlan_mode=l2` is similar
105+
to a macvlan network. The main difference is that the `ipvlan` driver
106+
doesn't assign a MAC address to each container, the layer-2 network stack
107+
is shared by devices in the ipvlan network. So, containers use the parent
108+
interface's MAC address.
109+
110+
The network will see fewer MAC addresses, and the host's MAC address will be
111+
associated with the IP address of each container.
112+
113+
The choice of network type depends on your environment and requirements.
114+
There are some notes about the trade-offs in the [Linux kernel
115+
documentation](https://docs.kernel.org/networking/ipvlan.html#what-to-choose-macvlan-vs-ipvlan).
99116

100117
```console
101118
$ docker network create -d ipvlan \
102119
--subnet=192.168.210.0/24 \
103-
--subnet=192.168.212.0/24 \
104120
--gateway=192.168.210.254 \
105-
--gateway=192.168.212.254 \
106121
-o ipvlan_mode=l2 -o parent=eth0 ipvlan210
107122
```
108123

content/manuals/engine/network/port-publishing.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,28 @@ For example:
289289
> Changing the default bind address doesn't have any effect on Swarm services.
290290
> Swarm services are always exposed on the `0.0.0.0` network interface.
291291
292+
### Masquerade or SNAT for outgoing packets
293+
294+
NAT is enabled by default for bridge networks, meaning outgoing packets
295+
from containers are masqueraded. The source address of packets leaving
296+
the Docker host is changed to an address on the host interface the packet
297+
is sent on.
298+
299+
Masquerading can be disabled for a user-defined bridge network by using
300+
the `com.docker.network.bridge.enable_ip_masquerade` driver option when
301+
creating the network. For example:
302+
```console
303+
$ docker network create mybridge \
304+
-o com.docker.network.bridge.enable_ip_masquerade=false ...
305+
```
306+
307+
To use a specific source address for outgoing packets for a user-defined
308+
network, instead of letting masquerading select an address, use options
309+
`com.docker.network.host_ipv4` and `com.docker.network.host_ipv6` to
310+
specify the Source NAT (SNAT) address to use. The
311+
`com.docker.network.bridge.enable_ip_masquerade` option must
312+
be `true`, the default, for these options to have any effect.
313+
292314
### Default bridge
293315

294316
To set the default binding for the default bridge network, configure the `"ip"`

0 commit comments

Comments
 (0)