#!/bin/sh
##双网卡绑定脚本,系统为centos
### 网卡绑定模式为HA
###设置网卡参数
BONDIP=192.168.x.x
BORADCAST=192.168.x.x
NETMASK=255.255.255.0
GATEWAY=192.168.x.1
###NORMAL CENTOS CONFIG PATH
BONDCONF=/etc/sysconfig/network-scripts/ifcfg-bond0
ETH0CONF=/etc/sysconfig/network-scripts/ifcfg-eth0
ETH1CONF=/etc/sysconfig/network-scripts/ifcfg-eth1
BACKDIR=/opt/ethconfbak
MODPROBECONF=/etc/modprobe.conf
BOND0(){
echo "
DEVICE=bond0
BOOTPROTO=static
BROADCAST=${BORADCAST}
IPADDR=${BONDIP}
NETMASK=${NETMASK}
GATEWAY=${GATEWAY}
ONBOOT=yes
TYPE=Ethernet
">${BONDCONF}
echo "
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
slave=yes
">${ETH0CONF}
echo "
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
slave=yes
">${ETH1CONF}
}
BACKUPETHCONF(){
if [ ! -d ${BACKDIR} ]
then
mkdir -p ${BACKDIR}
mv ${ETH0CONF} ${BACKUPDIR}
mv ${ETH1CONF} ${BACKUPDIR}
fi
}
main(){
BACKUPETHCONF
BOND0
echo "
alias bond0 bonding
options bond0 miimon=100 mode=1
">>${MODPROBECONF}
echo "
ifenslave bond0 eth0 eth1
">>/etc/rc.local
echo "PLEASE REBOOT SYSTEM!!!"
}
main
阅读(2501) | 评论(0) | 转发(0) |