Macvlan & IPvlan Drivers (Assigning Physical LAN IPs to Containers)
Give containers real LAN IPs with macvlan/ipvlan when they must look like VMs on the network.
In plain words
Use macvlan when legacy discovery or monitoring must see containers as LAN peers; use IPvlan to reduce MAC-table pressure when the network architecture allows it.
Think of it like…
Macvlan hands every container a separate shopfront sign on the same street; IPvlan gives them numbered counters behind one street sign.
Where you’ve seen it
In practice, docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50 is the concrete move for this job: give containers real LAN IPs with macvlan/ipvlan when they must look like VMs on the network. The release is not accepted until ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately confirms the result.
Words you’ll hear
- macvlan
- The implementation control in
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50for give containers real LAN IPs with macvlan/ipvlan when they must look like VMs on the network. - ipvlan
- The result to observe with
ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately, rather than infer from a successful command alone. - LAN IPs
- The production boundary exposed when making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.
Visual diagram
Theory & deep dive
macvlan control path
The concrete mechanism is docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50. The observable result is ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately; if those disagree, inspect the runtime evidence before changing unrelated settings.
Give containers real LAN IPs with macvlan/ipvlan when they must look like VMs on the network. Keep macvlan, ipvlan and LAN IPs in the same deployment record so the intent and the observed state cannot drift apart.
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50
ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately, not with command success alone.LAN IPs failure boundary
Containers on macvlan cannot ordinarily reach the host parent address because of bridge-hairpin behavior, and an 802.1q/tagged network, DHCP server or switch MAC limit can invalidate the setup. IP addresses must not collide with LAN DHCP ranges. The narrow failure to design for is making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.
Accept this compromise explicitly: Macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management. The controlled check-ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately-also identifies the point where a different design is safer.
Exercise this failure safely: making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Containers on macvlan cannot ordinarily reach the host parent address because of bridge-hairpin behavior, and an 802.1q/tagged network, DHCP server or switch MAC limit can invalidate the setup. IP addresses must not collide with LAN DHCP ranges.
- Intent
- macvlan
When to use it & trade-offs
What it is
Macvlan gives each container a distinct MAC address on a physical network so it looks like another LAN device; IPvlan shares a parent MAC and can isolate by L2 or L3. Both require a parent interface, subnet/IPAM planning and host L2/L3 routing awareness.
Why it matters: Containers on macvlan cannot ordinarily reach the host parent address because of bridge-hairpin behavior, and an 802.1q/tagged network, DHCP server or switch MAC limit can invalidate the setup. IP addresses must not collide with LAN DHCP ranges.
When to reach for it
- The fit is strongest for this job: give containers real LAN IPs with macvlan/ipvlan when they must look like VMs on the network. Pair it with
ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separatelyin the runbook. - Production macvlan changes should make ipvlan observable through
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50, rather than trusting the runtime default. - Keep a rollback example for the case where making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.
When to avoid or be careful
- Do not accept command success while the system can still fail by making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.
- Avoid erasing LAN IPs protection merely to dodge this cost: “Macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management”.
- Do not replace the evidence path-
ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately-with a screenshot or a mutable tag.
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50: practical choices
Strengths: Macvlan gives each container a distinct MAC address on a physical network so it looks like another LAN device; IPvlan shares a parent MAC and can isolate by L2 or L3. Both require a parent interface, subnet/IPAM planning and host L2/L3 routing awareness.
Watch out: Macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management.
Strengths: It can begin with docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50 and fewer surrounding controls.
Watch out: It silently accepts making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default, which makes the result hard to reproduce after promotion.
Strengths: Containers on macvlan cannot ordinarily reach the host parent address because of bridge-hairpin behavior, and an 802.1q/tagged network, DHCP server or switch MAC limit can invalidate the setup. IP addresses must not collide with LAN DHCP ranges.
Watch out: The platform adds an ownership and debugging layer; retain ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately as the direct check.
Interview signals & numbers to know
When this topic comes up
- docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50
- ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately
- Failure signature: making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default
- Trade-off: Macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management.
Benchmarks & rules of thumb
- 1 parent interface
- required by the driver network
- 192.168.50.0/24
- example container-only subnet
- 48-bit MAC
- macvlan allocates a visible one per endpoint
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50as proof and skippingping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately. - Making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default
- Optimizing macvlan without accepting that macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management.
Likely interviewer follow-ups
- Why does
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50address macvlan here rather than through application code? - How would you distinguish healthy ipvlan from the failure “making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default” using
ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately? - When would this trade-off-“Macvlan maximizes L2 compatibility; IPvlan scales MAC usage better, but both couple containers to LAN topology and IP management”-justify a different LAN IPs design?
docker network create -d macvlan --subnet=192.168.50.0/24 --gateway=192.168.50.1 -o parent=eth0.50 lan50-and one proof-ping a LAN service and use ip link plus ARP/neigh inspection on the parent host; document the host-to-container route test separately. Then name the boundary: making the macvlan range overlap DHCP, or assuming a container can reach the host over the parent interface by default.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Macvlan & IPvlan Drivers (Assigning Physical LAN IPs to Containers) with generative AI interview Q&A and hands-on practice.