Subversion Repositories ALCASAR

Rev

Rev 937 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 937 Rev 938
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-load_balancing.sh 937 2012-07-05 22:39:11Z franck $
2
# $Id: alcasar-load_balancing.sh 938 2012-07-05 22:40:33Z franck $
3
 
3
 
4
# alcasar-load_balancing.sh
4
# alcasar-load_balancing.sh
5
# by BOUIJOUX Franck (3abTux) <3abtux@free.fr>
5
# by BOUIJOUX Franck (3abTux) <3abtux@free.fr>
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 14... Line 14...
14
WEIGHT2=1
14
WEIGHT2=1
15
#WEIGHT3=3
15
#WEIGHT3=3
16
 
16
 
17
# Définition des interfaces :
17
# Définition des interfaces :
18
DEV1=${1-eth0}  # defaut eth0
18
DEV1=${1-eth0}  # defaut eth0
19
DEV2=${2-eth0}  # defaut eth0 mais peut être autre chose :-)
19
DEV2=${2-eth0:1}  # defaut eth0 mais peut être autre chose :-)
20
#DEV3=${3-eth0}  # defaut eth0 mais peut être autre chose :-)
20
#DEV3=${3-eth0:2}  # defaut eth0 mais peut être autre chose :-)
21
 
21
 
22
# Trouver les adresses pour chaque interface
22
# Trouver les adresses pour chaque interface
23
IP1=`ifconfig $DEV1 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
23
IP1=`ifconfig $DEV1 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
24
IP2=`ifconfig $DEV2 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
24
IP2=`ifconfig $DEV2 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
25
#IP3=`ifconfig $DEV3 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
25
#IP3=`ifconfig $DEV3 | grep inet | awk '{ print $2 }' | awk -F: '{ print $2 }'`
Line 59... Line 59...
59
ip rule add from $IP1 table rt_dev1
59
ip rule add from $IP1 table rt_dev1
60
ip rule add from $IP2 table rt_dev2
60
ip rule add from $IP2 table rt_dev2
61
#ip rule add from $IP3 table rt_dev3
61
#ip rule add from $IP3 table rt_dev3
62
 
62
 
63
# Effacer la route par défaut existante
63
# Effacer la route par défaut existante
-
 
64
ip route del default
64
if [ ! -z "`ip route show table main | grep 'nexthop'`" ] ; then
65
if [ ! -z "`ip route show table main | grep 'nexthop'`" ] ; then
65
        ip route del default scope global
66
        ip route del default scope global
66
fi
67
fi
67
 
68
 
68
# Alterne les liens basés sur chaque route
69
# Alterne les liens basés sur chaque route