The wikis are now using the new authentication system.
If you did not migrate your account yet, visit https://idp-portal-info.suse.com/

Bonding

移動先: 案内, 検索


WARNING!!!

This page is old and should not be used for current versions of SUSE Linux. Please see the following pages for more up-to-date information:

http://support.novell.com/techcenter/sdb/en/2004/09/tami_sles9_bonding_setup.html
http://www.novell.com/coolsolutions/feature/17605.html

Load balance and failover with two network adapters

  • First you have to configure the same ip address on both network interfaces:
yast lan
  • You have to announce the new bond device to the kernel:
echo "alias bond0 bonding" >> /etc/modprobe.conf.local
  • Then you should reboot your system:
reboot
  • Create a new startup script calling /etc/init.d/bond:
cd /etc/init.d
touch bond
chmod 755 bond
vi bond
  • Paste the following into this bond file:
#! /bin/sh
# Copyright (c) 2002-2006 bpm consult ag, CH-Birsfelden. All rights reserved.
#               <support@bpm.ch>
#
### BEGIN INIT INFO
# Provides:          bond
# Required-Start:    $network
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:
# Short-Description: bonding
# Description:       load balancing between two or more ethernet interfaces
# Version:           1.0.2  08.02.2006
### END INIT INFO
#
# init.d/bond
 
logfile="/var/log/bond.log"
ifs=""
ifcounter=0
for if in `ifconfig | cut -c1-5 | grep "^eth"`
do
  ifs="$ifs $if"
  ifcounter=`expr $ifcounter + 1`
done
if [ $ifcounter -le 1 ]
then
   echo "not enough interfaces for bonding"
   exit 1
fi
. /etc/rc.status
rc_reset
case "$1" in
  start)   # start bonding:
           echo -n "create bond interface "
           date > $logfile
           ip=`ifconfig eth0 | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1`
           bc=`ifconfig eth0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1`
           nm=`ifconfig eth0 | grep "inet addr" | cut -d":" -f4 | cut -d" " -f1`
           gw=`netstat -rn | grep ^0 | cut -c17-32`
           ifconfig bond0 $ip netmask $nm broadcast $bc >> $logfile 2>> $logfile
           rc_status -v
           echo -n "start bonding "
           ifenslave bond0 $ifs >> $logfile 2>> $logfile
           route add -net default gw $gw bond0
           rc_status -v
           ;;
  stop)    # stop bonding:
           echo -n "remove bond interface "
           date > $logfile
           ifconfig bond0 down >> $logfile 2>> $logfile
           rc_status -v
           echo -n "reactivate ethernet interfaces "
           for if in $ifs
           do
             ifconfig $if up >> $logfile 2>> $logfile
           done
           rc_status -v
           ;;
  status)  # check bonding:
           if [ `ifconfig | grep "^bond0" | wc -l` -eq 1 ]
           then
             echo "bond interface is loaded"
             mac=`ifconfig | grep "^bond0" | cut -c39-`
             for if in $ifs
             do
               if [ `ifconfig | grep "^$if" | cut -c39-` == $mac ]
               then
                 echo "$if used in bond0"
               fi
             done
           else
             echo "bonding is disabled"
           fi
           ;;
  *)       # invalid option:
           echo "error: invalid argument"
           echo "usage: $0 {start|stop|status}"
           exit 1
           ;;
esac
rc_exit
  • This will bind all interfaces on the machine to bond0. To bind specific interfaces remove the following:
for if in `ifconfig | cut -c1-5 | grep "^eth"`
do
  ifs="$ifs $if"
  ifcounter=`expr $ifcounter + 1`
done

and change:

ifs=""

to

ifs="{the interfaces you wish to bond}"

and

ifcounter=0

to

ifcounter={the number of interfaces to be bound} 

If your interfaces to be bound to bond0 do not include eth0 then these lines need to be edited also:

ip=`ifconfig eth0 | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1`
bc=`ifconfig eth0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1`
nm=`ifconfig eth0 | grep "inet addr" | cut -d":" -f4 | cut -d" " -f1`

Just change eth0 to the first interface to be bound in your list of $ifs.

  • Finally you can start the network bonding:
./bond start
create bond interface                                             done
start bonding                                                     done
./bond status
bond interface is loaded
eth0 used in bond0
eth1 used in bond0
  • To start it automatically at system start, use the following command:
insserv -d bond