4

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
Isvara
  • 215
  • 2
  • 13

2 Answers2

0

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...

Ydenda
  • 3
  • 1
0

Here is sample interface and bond file config, MACADDR may solve your issue.

#Redhat/Centos

#  cat /etc/sysconfig/network-scripts/ifcfg-eno1
DEVICE=eno1
NAME=eno1
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

# cat /etc/sysconfig/network-scripts/ifcfg-eno2
DEVICE=eno2
NAME=eno2
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
NAME=bond0
TYPE=Bond
MACADDR=a0:36:9f:0f:b1:70         #Assigning fixed mac address
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=no
BONDING_OPTS="mode=active-backup primary=eno1 miimon=100"

Or for Ubuntu

#eth0 interace file

auto eth0
iface eth0 inet manual
bond-master bond0
bond-primary eth0

#eth1 interace file

auto eth1
iface eth1 inet manual
bond-master bond0

#bond file

auto bond0
iface bond0 inet static
hwaddress ether xx:xx:xx:xx:xx:xx         #fixed mac address
address x.x.x.x                           #Your can remove these lines if it's dhcp
netmask x.x.x.x
gateway x.x.x.x
bond-mode active-backup
bond-miimon 100
bond-slaves none
asktyagi
  • 2,860
  • 2
  • 8
  • 25
  • If this were my home PC's I'd be OK with putting a fixed mac address in there, and this works fine, FWIW - works with netplan too. But for the kind of deployments I'm working on this is not the world's best plan. Just about as bad as putting a static arp entry on the switch its attached to. I was hoping for some explanation of the more esoteric options in the netdev stuff – Peter Turner Sep 14 '22 at 03:48