Files
homelab-scripts/GauntPlexBond.sh
2019-12-25 13:19:21 -05:00

37 lines
803 B
Bash

#!/bin/bash
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin
INTERFACES=$(ip link | grep "state UP" | awk '{ if($2 != "bond0:" && $2 != "idrac:") print substr($2,1,length($2)-1)}')
for n in $INTERFACES; do
# Make sure both the interfaces are setup as slaves
cat > /etc/sysconfig/network-scripts/ifcfg-$n <<EOL
NAME="$n"
DEVICE="$n"
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
EOL
if [ "$n" != "eno1" ]; then
# makse sure to setup bond0 with th enp65s0 as the primary for 10gb
cat > /etc/sysconfig/network-scripts/ifcfg-bond0 <<EOL
DEVICE=bond0
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=10.0.10.11
NETMASK=255.255.255.192
GATEWAY=10.0.10.1
DNS1=10.0.10.1
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="primary=$n mode=1 miimon=100"
EOL
fi
done
# restart the network
systemctl restart network