36 lines
1.2 KiB
Bash
36 lines
1.2 KiB
Bash
#!/bin/bash
|
|
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
PRIMARY="enp0s31f6"
|
|
SECONDARY="enp1s0f0"
|
|
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.20.28/27
|
|
nmcli connection modify ${BOND} ipv4.gateway 10.0.20.1
|
|
nmcli connection modify ${BOND} ipv4.dns 10.0.20.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} |