Add new comment

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Submitted by joeytrungale (registered user) on Sat, 2008-12-20 02:13.
copy and paste to bond_setup.sh, sh ./bond_setup.sh

<code>

#!/bin/bash

# Quick and dirty script to setup bonding on Slackware-12.2
# 12/20/2008 Joey Trungale <joey@trungale.net>

MODULE=e1000e
NIC0=eth1
NIC1=eth2

set -e

echo
echo "Compiling ifenslave..."
cd /usr/src/linux/Documentation/networking
gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
strip ifenslave

echo "Installing ifenslave..."
cp ifenslave /sbin/ifenslave

echo "Creating rc.bond script..."
cd /etc/rc.d
touch rc.bond
chmod 755 rc.bond

cat <<EOF> rc.bond
#!/bin/sh

case "\$1" in
  'start')
    echo "start bond0"
    #modprobe bonding mode=balance-alb miimon=100
    modprobe bonding mode=balance-rr miimon=100
    modprobe $MODULE
    ifconfig bond0 up
    ifenslave bond0 $NIC0
    ifenslave bond0 $NIC1
    #TODO need to be changed
    #ifconfig bond0 hw ether 00:16:3e:aa:aa:aa
  ;;
  'stop')
    ifconfig bond0 down
    rmmod bonding
    rmmod $MODULE
  ;;
  *)
    echo "Usage: \$0 {start|stop}"
  ;;
esac
EOF

echo "Patching rc.M to start rc.bond on startup..."
patch -s -p0 rc.M <<EOF
--- rc.M    2008-12-20 08:37:48.000000000 -0600
+++ rc.M.new    2008-12-20 08:38:47.000000000 -0600
@@ -82,6 +82,11 @@
   fi
 fi
 
+# If script rc.bond is executable then start it
+if [ -x /etc/rc.d/rc.bond ]; then
+  . /etc/rc.d/rc.bond start
+fi
+
 # Initialize the networking hardware.
 if [ -x /etc/rc.d/rc.inet1 ]; then
   . /etc/rc.d/rc.inet1
EOF

cat <<EOF

Dont forget to add the following to /etc/rc.d/rc.inet1.conf:

IFNAME[4]="bond0"
IPADDR[4]="XXX.XX.XX.XX"
NETMASK[4]="255.255.255.0"
USE_DHCP[4]=""
DHCP_HOSTNAME[4]=""

Also, you may wish to choose a different method of bonding,
modify the 'mode=' option in rc.bond to one of the settings
from /usr/src/linux/Documentation/networking/bonding.txt.

Enjoy!
EOF
</code>

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.

Reply

*
*
The content of this field is kept private and will not be shown publicly.


*

  • Images can be added to this post.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <div>
  • Lines and paragraphs break automatically.