Why Use MACVLAN?
- Direct Layer 2 connectivity with your physical network
- Unique MAC addresses for each container
- Support for legacy applications requiring their own IP on the LAN
Before you begin, ensure the parent interface (
eth0 in these examples) is active and not part of another bridge. You may need to bring it up with ip link set eth0 up.1. Creating a MACVLAN Network
Use themacvlan driver when creating a Docker network:
-d macvlan
Selects the MACVLAN driver.--subnet/--gateway
Defines the IP range and default gateway on the physical LAN.-o parent=eth0
Binds Docker’s MACVLAN to the host interfaceeth0.my_macvlan_net
Your custom network name.
2. MACVLAN Modes
MACVLAN supports two primary modes for segmenting and isolating traffic:Your physical switch must support 802.1Q tagging, and the parent interface must be configured as a trunk port to carry multiple VLANs.