When/where to set network bond (active-backup) interface priorities on boot?

This is a follow-up to linux bonding active-backup mode set priority for multiple interfaces? I’m too new to post a comment there.

I’ve confirmed that ip link set dev <x> type bond_slave prio <y> works as expected. How can I execute these commands at the appropriate time on boot? There is no underlying configuration for prio. It can only be set after the interface is enslaved.

For those who have never used this feature, it looks like this:

config

auto bond0
iface bond0 inet static
    # gateway 172.16.0.1
    address 172.16.0.2
    netmask 255.255.255.0
    bond-slaves eno8 eno7 eno6 eno5 
    bond-mode active-backup
    bond-miimon 1000
    bond-downdelay 3000
    bond-updelay 3000

boot

bond0: (slave eno8): Enslaving as a backup interface with a down link
bond0: (slave eno7): Enslaving as a backup interface with a down link
bond0: (slave eno6): Enslaving as a backup interface with a down link
bond0: (slave eno5): Enslaving as a backup interface with a down link
bond0: (slave eno7): link status up, enabling it in 0 ms
bond0: (slave eno7): link status definitely up, 10000 Mbps full duplex
bond0: (slave eno7): making interface the new active one
bond0: active interface up!

I’m using this for auto-configuration rather than redundancy. That’s why my time parameters are so large. The change doesn’t need to happen instantly. I can’t use a simple primary, because I want to give preference to both eno7 and eno8 which are 10GB.

Asked By: David

||

Your config snippet looks like classic Debian-style /etc/network/interfaces. You might find this in distributions related to Debia, like Ubuntu, Mint, Kali and others. Distributions that are not related to Debian can have a completely different network configuration file syntax. This is one of the reasons why you should always specify the name and version of the distribution you’re using when posting a Linux question.

If my guess is correct and this is for Debian or related distribution, use the up keyword and the ip command:

auto bond0
iface bond0 inet static
    # gateway 172.16.0.1
    address 172.16.0.2
    netmask 255.255.255.0
    bond-slaves eno8 eno7 eno6 eno5 
    bond-mode active-backup
    bond-miimon 1000
    bond-downdelay 3000
    bond-updelay 3000
    up /usr/bin/ip link set dev eno7 type bond_slave prio <y>
    up /usr/bin/ip link set dev eno8 type bond_slave prio <y> # repeat as necessary
Answered By: telcoM
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.