Linux Bond自动化配置脚本-第一版
使用方法:
1、使用XFTP或scp导入到需要配置Bond的服务器上。
2、根据实际情况修改网卡配置。
3、授权
chmod +x bond2.sh
4、执行
./bond2.sh
5、检查结果
#!/bin/bash
#adminIP=192.168.101.1
#adminGATE=192.168.101.254
#storeIP=
#storeGATE=
ETH1=eno1
ETH2=eno2
ETH3=eno3
ETH4=eno4
ETH5=eno5
ETH6=eno6
modprobe bonding
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=static
USERCTL=no
ONBOOT=yes
IPADDR=
#IPADDR=$adminIP
PREFIX=24
GATEWAY=
#GATEWAY=$adminGATE
BONDING_OPTS="mode=1 miimon=100"
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-bond1
DEVICE=bond1
TYPE=Bond
NAME=bond1
BONDING_MASTER=yes
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-bond2
DEVICE=bond2
TYPE=Bond
NAME=bond2
BONDING_MASTER=yes
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=
#IPADDR=$adminIP
PREFIX=24
GATEWAY=
#GATEWAY=$adminGATE
BONDING_OPTS="mode=1 miimon=100"
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH1
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH2
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH3
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH3
ONBOOT=yes
MASTER=bond1
SLAVE=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH4
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH4
ONBOOT=yes
MASTER=bond1
SLAVE=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH5
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH5
ONBOOT=yes
MASTER=bond2
SLAVE=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH6
TYPE=Ethernet
BOOTPROTO=none
DEVICE=$ETH6
ONBOOT=yes
MASTER=bond2
SLAVE=yes
EOF
systemctl restart network
ping $GATE -c 1