大家好,欢迎来到IT知识分享网。
系统环境:CentOS 7.4
将两块网卡eth0, eth1绑定成一块网卡bond0实现网口负载平衡和容错能力
bond0信息如下
bond0的IP地址:192.168.100.100/24
bond0的网关:192.168.100.1
bond0的主DNS:202.106.0.20
bond0的从DNS:8.8.8.8
#!/bin/bash
# by: ZDF
#
Bond_IP_ADDR=192.168.100.100
Bond_NET_PREFIX=24
Bond_GAT_EWAY=192.168.100.1
Bond_DNS_1=202.106.0.20
Bond_DNS_2=8.8.8.8
Bond_Level=0
NetDevice_1=eth0
NetDevice_2=eth1
find /etc/sysconfig/network-scripts -iname ifcfg-* -not \( -iname “ifcfg-lo” -o -iname “*.bak” \) -exec mv {} {}.bak \;
if [ $? -ne 0 ];then
exit 3
fi
touch /etc/sysconfig/network-scripts/ifcfg-bond$Bond_Level
cat > /etc/sysconfig/network-scripts/ifcfg-bond$Bond_Level <
NAME=bond$Bond_Level
DEVICE=bond$Bond_Level
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=$Bond_IP_ADDR
PREFIX=$Bond_NET_PREFIX
GATEWAY=$Bond_GAT_EWAY
DNS1=$Bond_DNS_1
DNS2=$Bond_DNS_2
TYPE=Bond
BONDING_MASTER=yes
USERCTL=no
BONDING_OPTS=“miimon=100 mode=$Bond_Level”
EOF
touch /etc/sysconfig/network-scripts/ifcfg-$NetDevice_1
cat > /etc/sysconfig/network-scripts/ifcfg-$NetDevice_1 <
NAME=$NetDevice_1
DEVICE=$NetDevice_1
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond$Bond_Level
SLAVE=yes
USERCTL=no
EOF
touch /etc/sysconfig/network-scripts/ifcfg-$NetDevice_2
cat > /etc/sysconfig/network-scripts/ifcfg-$NetDevice_2 <
NAME=$NetDevice_2
DEVICE=$NetDevice_2
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond$Bond_Level
SLAVE=yes
USERCTL=no
EOF
ifdown $NetDevice_1
ifup $NetDevice_1
ifdown $NetDevice_2
ifup $NetDevice_2
ifup bond$Bond_Level
systemctl restart network.service
echo
echo -e “\033[32;1m$(cat /sys/class/net/bonding_masters)\033[m”
cat /proc/net/bonding/bond$Bond_Level
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/21191.html