Linux – Why is networkd changing the MAC addresses of the bonded interfaces

bondinglinuxmac addressnetworkingsystemd-networkd

When I add the config files below into /etc/systemd/network and restart systemd-networkd, I find that the MAC addresses of bond0, eth0 and eth2 have all been changed to a single, locally administered address. This breaks DHCP, and doesn't follow the expectation set by the Linux kernel bonding documentation that states that the bond interface will take the MAC address of one of its slaves.

According to the networkd documentation, the issue appears to be this:

MACAddress=

The MAC address to use for the device. For "tun" or "tap" devices, setting MACAddress= in the "[NetDev]" section is not supported. Please specify it in "[Link]" section of the corresponding systemd.network(5) file. If this option is not set, "vlan" devices inherit the MAC address of the physical interface. For other kind of netdevs, if this option is not set, then MAC address is generated based on the interface name and the machine-id(5).

(Emphasis mine.)

How do I prevent this MAC address generation and tell networkd to just use one from the slaves?

Files

10-bond0.netdev

[NetDev]
Name=bond0
Kind=bond

[Bond]
Mode=802.3ad

10-bond0.network

[Match]
Name=bond0

[Network]
DHCP=ipv4

20-eth0.network

[Match]
Name=eth0

[Network]
Bond=bond0

20-eth2.network

[Match]
Name=eth2

[Network]
Bond=bond0

Best Answer

How do I prevent this MAC address generation and tell networkd to just use one from the slaves?

As far as I know this is not possible. In my project I do set it up using another script. According to Debian Systemd docu Systemd-networkd may assign different MAC then the one of physical interface. You can fix it manually adding MACAddress=xx:xx:xx:xx:xx:xx

I know you didn't mention the OS, but still, your symptoms fit to the Debian...