Scripts:执行双网卡绑定 - 主打产品 - 南充市顺庆区小房子和树婚礼策划部
当前位置:首页 > 主打产品 >

Scripts:执行双网卡绑定

编辑:南充市顺庆区小房子和树婚礼策划部时间:2017-09-06 09:28:41阅读次数:2
Scripts:执行双网卡绑定 在批量部署大量服务器,采集软件,比如几款刀片服务器的时候,处理网卡绑定的过程是比较繁琐的,而且一不小心就会操作失误,为此将操作过程组成shell,站群,方便、高效、不出错。
#!/bin/bash #------------------------------------------------------------------------------- # Name: netbond # Filename : netbond.sh # Local: # What: 用于双网卡绑定 # HowTo : sh ./netbond.sh ethN ethN bondN ipaddr netmask gateway # Version : v1.0 2013.9.3 # Release : 2013-9-3 # Author : Gtlions # Copyright : Copyright (c) Gtlions 2013 <gtlions.l@gmail.com> # Licence : <Gtlions's licence> #------------------------------------------------------------------------------- if [ x$5 = x ]; then echo "Input Error!" echo "Usage: sh ./netbond.sh ethN ethN bondN ipaddr netmask gateway" exit 1 fi SCRIPTFILE=$0 ETHN1=$1 ETHN2=$2 BONDN=$3 IPADDR=$4 NETMASK=$5 GATEWAY=$6 ETHN1FILE=/etc/sysconfig/network-scripts/ifcfg-$ETHN1 ETHN2FILE=/etc/sysconfig/network-scripts/ifcfg-$ETHN2 BONDFILE=/etc/sysconfig/network-scripts/ifcfg-$BONDN ETHN1BAK=ifcfg-$ETHN1.bak ETHN2BAK=ifcfg-$ETHN2.bak if [ ! -f $ETHN1FILE ]; then echo "Error!Not exist $ETHN1FILE" exit 1 fi if [ ! -f $ETHN2FILE ]; then echo "Error!Not exist $ETHN2FILE" exit 1 fi if [ -f $BONDFILE ]; then echo "Error!Exist $BONDFILE" exit 1 fi echo "Set Info: $ETHN1 AND $ETHN2 will bond to $BONDN : $IPADDR,$NETMASK,$GATEWAY" echo "Go On?[Y/N]" read GOON GOON1=`echo $GOON |tr 'a-z' 'A-Z'|cut -c1` if [ $GOON1 = "Y" ]; then cp $ETHN1FILE ETHN1BAK cp $ETHN2FILE ETHN2BAK if [ -f ETHN1BAK ] && [ -f ETHN2BAK ] ; then echo -e "DEVICE=$BONDN\nONBOOT=yes\nTYPE=Ethernet\nUSERCTL=yes\nBOOTPROTO=static\nIPADDR=$IPADDR\nNETMASK=$NETMASK\nGATEWAY=$GATEWAY">$BONDFILE chmod 644 $BONDFILE echo -e "DEVICE=$ETHN1\nONBOOT=yes\nBOOTPROTO=none\nTYPE=Ethernet\nUSERCTL=yes\nMASTER=$BONDN\nSLAVE=yes">$ETHN1FILE echo -e "DEVICE=$ETHN2\nONBOOT=yes\nBOOTPROTO=none\nTYPE=Ethernet\nUSERCTL=yes\nMASTER=$BONDN\nSLAVE=yes">$ETHN2FILE cat /etc/modprobe.conf |grep "$BONDN">null RESULT=$? if [ $RESULT -eq 1 ] ; then echo -e "alias $BONDN bonding\noption $BONDN miimon=100 mode=1">>/etc/modprobe.conf fi cat /etc/rc.d/rc.local|grep "$BONDN">null RESULT=$? if [ $RESULT -eq 1 ] ; then echo -e "ifenslave $BONDN $ETHN1 $ETHN2">>/etc/rc.d/rc.local fi echo "Done!Pls reboot system!" fi else echo "Cancel!" fi

企业建站2800元起,携手武汉肥猫科技,做一个有见地的颜值派!更多优惠请戳:仙桃网站建设 http://xiantao.45qun.com

上一篇:Resellerclub优惠券引擎 下一篇:最后一页

相关阅读