PDA

View Full Version : [SOLVED] How do maintain a constant mac address on bonded NICs?



MakOwner
April 28th, 2012, 10:38 PM
I know there are some differences between configuration of simple bonded pairs (mode 0) in 12.04 from 10.04.

In 10.04 this consistenlty create bond0 with the mac address from eth0.
with 12.04, the mac address used appears to be random - sometimes it's the address from eth0, sometimes it's the address from eth1.

I have tried using the hwaddress parameter - in the bond0 section it just
causes networking to fail. It's ignored in the eth0 or eth1 section.




auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet dhcp
slaves eth0 eth1

# LACP confuration
bond_mode 0
bond_miimon 100

Vishal Agarwal
April 29th, 2012, 12:38 PM
Will something help checking /etc/udev/rules.d/ net file !

MakOwner
April 29th, 2012, 10:44 PM
Will something help checking /etc/udev/rules.d/ net file !

I tried editing /etc/udev/rules.d/70-persistent-net.rules
After reboot I end up with an additional device with the original MAC address defined - and the second and third devices are not active.




# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.4/0000:05:00.0 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:72:fc:0f:8a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.5/0000:06:00.0 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:72:fc:0f:8a", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.5/0000:06:00.0 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:72:fc:0f:8b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

MakOwner
May 4th, 2012, 06:22 AM
I have had three reboots that came up with a consistent MAC address with this configuration.
No guarantee that this will work consistently, but its the best I have found so far.
Don't know if it;s the hwaddress parameter or the longer bond-miimon settings.
I know the positioning of the hwaddress paramter is sensitive - make sure you put it between the face line and the rest of the parameters.




################################################
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0


auto bond0
iface bond0 inet dhcp
hwaddress xx:xx:xx:xx:xx:xx
bond-slaves eth0 eth1
bond-mode 0
bond-miimon 1000

barlshint
May 29th, 2012, 10:55 AM
After trying MakOwner's solution to no avail, I think I solved it for my case.

At bootup I noticed in dmesg that eth1 was coming up before eth0, probably due to some unpredictable hardware timing. To make things worse, I saw that the link states for eth0 and eth1 would sometimes go up a few seconds after bond0 went up. Perhaps the bond was polling for the link status of eth0 and eth1, cycling through each until one came up. Whichever was chosen first depended on timing.

My solution was to add a pre-up sleep command to eth1. This effectively delays it long enough to guarantee that eth0 is selected first.

Here is my configuration:


auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
# delay ifup to allow eth0 to come up first in the bond
pre-up sleep 4
bond-master bond0

auto bond0
iface bond0 inet dhcp
bond-mode active-backup
bond-miimon 100
bond-slaves eth0 eth1