首页 电脑 电脑学堂 查看内容

双网卡bond的脚本

2011-5-26 10:49 657 0

摘要:   通过ifenslave命令可以很快速的建立双网卡的bonding,下面的脚本就是用来实现网卡的bonding,也可以监控bonding,以及停止bonding  注意设置bonding的2个网卡的...
关键词: bonding ifenslave sbin bond0 status 网卡 start NETMASK stop echo

  通过ifenslave命令可以很快速的建立双网卡的bonding,下面的脚本就是用来实现网卡的bonding,也可以监控bonding,以及停止bonding  注意设置bonding的2个网卡的配置文件设置成启动不激活!  #!/bin/bash  # chkconfig: 35 10 90  # description: Activates/Deactives bonding device  # filename: bond.sh  # auth: Jarson  # date: 2009/08/18  IP=192.168.1.1  NETMASK=255.255.255.0  id root &>/dev/null||exit 1  start () {  /sbin/ifenslave bond0 &>/dev/null&&exit 0  /sbin/modprobe bonding mode=1 miimon=50  /sbin/ifconfig bond0 $IP netmask $NETMASK  /sbin/ifenslave bond0 eth0  /sbin/ifenslave bond0 eth1  }  stop () {  /sbin/ifenslave bond0 &>/dev/null||exit 1  /sbin/ifenslave -d bond0 eth0  /sbin/ifenslave -d bond0 eth1  /sbin/modprobe -r bonding  }  status () {  if  /sbin/ifenslave bond0 &>/dev/null  then  echo "Bonding is run"  echo "The ip address is `ifconfig bond0|grep 'inet addr'|awk '{print $2}'|awk -F: '{print $2}'`"  else  echo "Bonding is down"  fi  }  case $1 in  start)start;;  stop)stop;;  status)status;;  *)echo $"Usage: $0 {start|stop|status}"  esac  exit 0  也可以把此脚本拷贝到 /etc/rc.d/init.d目录,然后用 chkconfig --add bond.sh 让其开机自动启动。
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部