#!/bin/bash PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin PRIMARY="eno1" SECONDARY="eno4" BOND="bond0" BOND_SLAVE0="${BOND}-slave0" BOND_SLAVE1="${BOND}-slave1" # Delete the old connections nmcli connection delete ${BOND} nmcli connection delete ${PRIMARY} nmcli connection delete ${SECONDARY} nmcli connection delete ${BOND_SLAVE0} nmcli connection delete ${BOND_SLAVE1} # Create the bond nmcli connection add type team con-name ${BOND} ifname ${BOND} config '{"runner":{"name":"activebackup"},"ports":{"'${PRIMARY}'":{"prio":100}}}' nmcli connection modify ${BOND} ipv4.addresses 10.0.10.11/26 nmcli connection modify ${BOND} ipv4.gateway 10.0.10.1 nmcli connection modify ${BOND} ipv4.dns 10.0.10.1 nmcli connection modify ${BOND} ipv4.method manual nmcli connection modify ${BOND} connection.autoconnect yes # Add the slaves to the bond nmcli connection add type team-slave con-name ${BOND_SLAVE0} ifname ${PRIMARY} master ${BOND} nmcli connection add type team-slave con-name ${BOND_SLAVE1} ifname ${SECONDARY} master ${BOND} # Activate the devices nmcli device connect ${BOND} nmcli device connect ${PRIMARY} nmcli device connect ${SECONDARY} # Restart the bond0 connections nmcli connection down ${BOND} && nmcli connection up ${BOND} # make sure network drives are mounted after the network has come up sleep 5 mount -a