Skip to content
Blog

Choosing Between Macvlan and IPvlan

Macvlan gives every container its own MAC address; ipvlan shares the parent interface's MAC. Compare switch, cloud, and DHCP implications — and pick the right driver.

Published on • November 19, 2026

AI Assistant

Your switch port policy allows one MAC. Your cloud provider silently drops macvlan traffic. Your legacy app insists it’s a real host on the LAN. Macvlan and ipvlan both put containers directly on the physical network — bypassing the Linux bridge entirely — but they disagree on the one thing the wire actually sees: MAC addresses. Everything else in this decision follows from that.

Two drivers, one parent interface

Both drivers attach container interfaces to a parent NIC on the host (-o parent=eth0), so traffic leaves the machine without NAT and without a bridge. The difference is the address model:

  • macvlan assigns each container its own MAC address. To the switch, every container is a distinct physical device.
  • ipvlan shares the parent interface’s MAC address for all containers. The switch sees one device; only IP addresses differ.

The macvlan docs put it plainly: ipvlan “doesn’t assign a MAC address to each container, the layer-2 network stack is shared by devices in the ipvlan network. So, containers use the parent interface’s MAC address.”

You can watch the difference directly. Two macvlan containers got distinct hardware addresses:

docker run -dit --name mv1 --network demo-macvlan alpine ash
docker run -dit --name mv2 --network demo-macvlan alpine ash
docker exec mv1 cat /sys/class/net/eth0/address   # d6:90:e7:3e:17:cf
docker exec mv2 cat /sys/class/net/eth0/address   # 42:2e:b1:a2:b6:a2

An ipvlan container on the same host reported the parent’s own MAC — identical to eth0 on the host:

docker exec ipvl3 cat /sys/class/net/eth0/address  # 3e:98:fa:77:4f:7a
docker run --rm --network host alpine cat /sys/class/net/eth0/address  # 3e:98:fa:77:4f:7a

What that costs you on the wire

Concernmacvlanipvlan
MAC per containerYes — one per endpointNo — shared parent MAC
Switch CAM/MAL tableGrows with container countStays at one entry per port
Promiscuous modeRequired — NIC must accept multiple MACsNot required
Port security / “one MAC per port” policiesBreaks themWorks with them
Cloud providersMost block macvlanTypically works
Broadcast/multicast (L2)Passed throughPassed through
Broadcast/multicast (L3 mode)N/ADropped by design
Host ↔ container reachabilityBlocked by kernelBlocked by design

The kernel’s own macvlan-vs-ipvlan guidance gives three situations where ipvlan is the answer: the switch allows only one MAC per port, the number of virtual devices would push the NIC into promiscuous mode with degraded performance, or the slave sits in a hostile namespace where L2 could be misused.

Docker’s macvlan page adds the operational warnings: you can degrade the network through IP address exhaustion or “VLAN spread” — too many unique MACs on one segment — and your equipment must handle promiscuous mode. It also states bluntly that most cloud providers block macvlan networking, and that the driver is Linux-only (not Docker Desktop, not Windows Engine, not rootless), needing kernel 3.9+ (4.0+ recommended). ipvlan wants kernel 4.2+; earlier versions are described as “buggy.”

DHCP, 802.1x, and port security

The docs don’t spell out 802.1x behavior, but the model decides it. With macvlan, each container is a separate MAC — so per-container DHCP leases work naturally, MAC-authenticated 802.1x switches see (and must authorize) every endpoint, and MAC-flooding protection will eventually trip. With ipvlan, the switch only ever learns the parent’s MAC: port security is trivially satisfied, and DHCP still functions in L2 mode (broadcasts pass), though the server sees one client MAC. If your network team polices MAC counts, that’s the whole conversation.

Modes and failure modes

macvlan’s driver option macvlan_mode defaults to bridge (also vepa, passthru, private). Point parent at a plain interface or an 802.1Q sub-interface like eth0.50 — Docker creates the sub-interface on the fly:

docker network create -d macvlan \
  --subnet=192.168.50.0/24 --gateway=192.168.50.1 \
  -o parent=eth0.50 macvlan50

ipvlan’s ipvlan_mode defaults to l2 (also l3, l3s). The modes change traffic semantics fundamentally:

  • ipvlan L2 behaves like a switched network: broadcast and multicast flow, subnets need an external router to talk to each other, and containers cannot ping the host’s own interface — Linux filters it for isolation.
  • ipvlan L3 turns the host into a router: no broadcast or multicast at all (which is why it’s pitched at massive scale — no bridging loops, no BPDU storms), different subnets sharing the parent can reach each other, and the container’s default route is just default dev eth0 because there’s no gateway to ARP for. Upstream networks need routes pointing back at the host. l3s adds iptables/conntrack symmetry, at “slightly less performance” per the kernel docs.

Two gotchas worth remembering: one ipvlan network per parent interface — a second create against the same parent fails with network di-13f24208432a is already using parent interface eth0 (the kernel fixes the mode per master device), and neither driver reaches the host. For macvlan the docs suggest attaching containers to a bridge network as well, or creating a macvlan interface on the host itself with an IP in the Docker subnet.

Both are kernel-native and both skip the bridge, so raw throughput is close. Where overhead appears: macvlan puts the NIC in promiscuous mode and scales MAC pressure onto the switch; ipvlan L3 processes broadcast-free routing in the host stack, and l3s adds conntracking.

Decision table

ScenarioDriver
Containers must appear as real LAN hosts (DHCP leases, LAN-side services)macvlan
Managed switch with one-MAC-per-port policyipvlan
Cloud VPC that blocks macvlanipvlan
Thousands of endpoints; CAM table pressure is a concernipvlan
Need broadcast/multicast (mDNS discovery, legacy protocols)macvlan, or ipvlan in l2
Host must route between container subnetsipvlan with ipvlan_mode=l3
Maximum isolation from a hostile container namespaceipvlan
Docker Desktop or rootless modemacvlan: documented as unsupported; try ipvlan, or stay on bridge
Cross-host cluster with no physical-network integrationoverlay instead

The bottom line

Pick macvlan when the network must believe each container is a separate physical device and your infrastructure tolerates it; pick ipvlan when the network policy, cloud environment, or scale says “one MAC per port.” Both are cheap to test — create the network, attach two containers, compare cat /sys/class/net/eth0/address against the parent, and ping. If macvlan traffic vanishes into the ether, you now know exactly why, and ipvlan is the same command with a different -d.

Further reading