本文主要包含双网卡bond,双网卡脚本,双网卡同时上内外网,双网卡,双网卡设置等服务器相关知识,网友希望可以进行参考
本脚本用于实现网卡bonding 可以监控bonding 停止bonding
[root@crushlinux ~]# vi /etc/init.d/bond
#!/bin/bash
# chkconfig: 345 10 90
# description: Activates/Deactives bonding device
# filename: bond.sh
# auth: crushlinux
# date: 2013/09/28
IP=192.168.1.254
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=100
/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将此脚本添加到chkconfig来管理
[root@crushlinux ~]# chmod a+x /etc/init.d/bond [root@crushlinux ~]# chkconfig --add bond [root@crushlinux ~]# chkconfig --list bond [root@crushlinux ~]# service bond start [root@crushlinux ~]# ifconfig
本文出自 “Crushlinux 工作室” 博客,谢绝转载!

