#!/bin/sh . ./check_function.sh declare -i a=0 declare -i b=2 IF_CONFIG="/etc/sysconfig/network-devices" grep bond0 /etc/rc.d/rc.local &> /dev/null if [ $? -eq 0 ];then echo "bond0 exist..." else ip=`ifconfig eth0 | grep inet | cut -d ':' -f 2 | cut -d ' ' -f 1` mask=`ifconfig eth0|grep Mask|cut -d ':' -f 4|cut -d ' ' -f 1` GATEWAY=`route -n|grep ^0.0.0.0|awk '{print $2}'` if [ -z ${ip} ];then ip="10.19.21.101" GATEWAY="10.19.21.254" mask="255.255.255.0" fi cat >> /etc/rc.d/rc.local < /sys/class/net/bond0/bonding/miimon echo 100 > /sys/class/net/bond0/bonding/miimon #echo 100 > /sys/class/net/bond0/bonding/arp_interval #echo 6 > /sys/class/net/bond0/bonding/mode echo 1 > /sys/class/net/bond0/bonding/mode #echo 3 > /sys/class/net/bond0/bonding/arp_validate #echo +gw > /sys/class/net/bond0/bonding/arp_ip_target /sbin/ifconfig bond0 ${ip} netmask ${mask} up echo +eth${a} > /sys/class/net/bond0/bonding/slaves echo +eth${b} > /sys/class/net/bond0/bonding/slaves /sbin/ifconfig eth${a} up /sbin/ifconfig eth${b} up /sbin/ifconfig bond0 down /sbin/ifconfig eth${a} down /sbin/ifconfig eth${b} down /sbin/ifconfig bond0 up /sbin/ifconfig eth${a} up /sbin/ifconfig eth${b} up # route information route add default gw ${GATEWAY} # route add -net netmask gw EOF for i in $a $b do ifconfig -a | grep eth${i} > /dev/null if [ $? != 0 ];then sed -i "/eth${i}/s/^/# &/g" /etc/rc.d/rc.local fi if [ -f $IF_CONFIG/ifcfg-eth${i} ];then mkdir -p $IF_CONFIG/interface_bak mv $IF_CONFIG/ifcfg-eth${i} $IF_CONFIG/interface_bak fi done fi