MACVLAN vs IPVLAN: Linux Network Drivers

In the Linux operating system, both macvlan and ipvlan are kernel drivers designed to bind multiple virtual network interfaces to a single physical interface, commonly used in containerized environments like Docker and Kubernetes. The primary distinction between the two lies in how they address and route network traffic: macvlan operates primarily at Layer 2 by assigning a unique MAC address to every virtual interface, whereas ipvlan operates at Layer 3 or Layer 2 by having all virtual interfaces share the physical parent interface's MAC address and differentiating traffic by IP address.

MAC Address Allocation and Layer Operations

The macvlan driver creates distinct virtual network endpoints that each possess their own unique MAC address. When connected to an external switch, each macvlan interface appears as an independent physical device plugged into that port.

In contrast, ipvlan shares the physical interface's MAC address across all created sub-interfaces. Because every virtual interface shares the same Layer 2 hardware address, packets sent to and from these interfaces rely on IP address matching to reach the correct destination.

Switch Limitations and Port Security

Because macvlan exposes multiple MAC addresses through a single physical interface, it can cause problems in enterprise environments where network switches enforce port security. Many network switches limit the number of MAC addresses allowed per port to prevent MAC flooding attacks; exceeding this limit can cause the port to be disabled. Additionally, hypervisors and public cloud environments (such as AWS and Azure) often drop packets with unknown MAC addresses, preventing macvlan from functioning properly without promiscuous mode.

ipvlan resolves this issue entirely. Because all traffic leaving the physical host uses a single, legitimate MAC address, upstream switches and cloud hypervisors do not detect multiple endpoints. This eliminates the risk of triggering MAC table exhaustion or port security violations.

Operational Modes

Both drivers provide distinct operational modes to control how virtual interfaces communicate:

Wireless Network Compatibility

A notable technical limitation of macvlan is its incompatibility with standard wireless (Wi-Fi) interfaces. The IEEE 802.11 standard typically restricts client devices to a single MAC address per association. As a result, Wi-Fi frames carrying multiple MAC addresses generated by macvlan are rejected by the wireless access point.

Because ipvlan reuses the parent interface's existing MAC address, it functions seamlessly over Wi-Fi connections, making it the preferred choice for virtual networking on wireless-connected Linux systems.