Please read the original article - Por favor, lea el artículo original -- How To: Load Balancing & Failover With Dual/ Multi WAN / ADSL / Cable Connections on Linux How To: Load Balancing y La reconexión con doble / Multi WAN / ADSL / Cable Conexiones en Linux . It contains detailed information with a sample script. Contiene información detallada con una muestra script. Viliam Kočinský modified my script to send email when routing table changes. Viliam Kočinský modificado mi script para enviar correo electrónico cuando se tabla de enrutamiento cambios. Also he is starting the script as a service from /etc/init.d. También está comenzando la escritura como un servicio de / etc / init.d. Read below for his enhancements: Lea a continuación para su equipamiento:


I’m using your gwping script. Estoy utilizando su gwping script. Realy usefull. Es muy simple. I added posibility to send email, when routing table change: He añadido posibilidad de enviar mensajes de correo electrónico, cuando el cambio tabla de enrutamiento:

# cat /usr/local/sbin/gwping # Cat / usr / local / sbin / gwping
…….

EMAILFROM="root@myserver.example.com" EMAILFROM = "root@myserver.example.com"
EMAILTO="someone@example.com" EMAILTO = "someone@example.com"
….. … ..

if [[ $CLS1 -eq 0 || $CLS2 -eq 0 ]]; then if [[$ CLS1-eq 0 | | $ CLS2-eq 0]]; entonces
if [[ $LLS1 -eq 1 && $LLS2 -eq 0 ]]; then if [[$ LLS1-eq 1 & & $ LLS2-eq 0]]; entonces
echo Switching to $NAME2 Cambiar a echo $ NAME2
ip route replace default scope global via $GW2 dev $EXTIF2 ip route sustituir por defecto alcance global a través de $ GW2 dev $ EXTIF2
LSROUTE=$(ip route show) LSROUTE = $ (ip route show)
echo "$LSROUTE" | mail -s "GWPING - Routing table changed. Line $NAME1 is down." echo "$ LSROUTE" | mail-s "GWPING - tabla de enrutamiento cambiado. Line $ NAME1 es abajo." -r $EMAILFROM $EMAILTO - r $ EMAILFROM $ EMAILTO
elif [[ $LLS1 -eq 0 && $LLS2 -eq 1 ]]; then elif [[$ LLS1-eq 0 & & $ LLS2-eq 1]]; entonces
echo Switching to $NAME1 Cambiar a echo $ NAME1
ip route replace default scope global via $GW1 dev $EXTIF1 ip route sustituir por defecto alcance global a través de $ GW1 dev $ EXTIF1
LSROUTE=$(ip route show) LSROUTE = $ (ip route show)
echo "$LSROUTE" | mail -s "GWPING - Routing table changed. Line $NAME2 is down." echo "$ LSROUTE" | mail-s "GWPING - tabla de enrutamiento cambiado. Line $ NAME2 es abajo." -r $EMAILFROM $EMAILTO - r $ EMAILFROM $ EMAILTO
elif [[ $LLS1 -eq 0 && $LLS2 -eq 0 ]]; then elif [[$ LLS1-eq 0 & & $ LLS2-eq 0]]; entonces
echo Restoring default load balancing El restablecimiento de echo por defecto balanceo de carga
#ip route replace default scope global via $GW1 dev $EXTIF1 # ip route sustituir por defecto alcance global a través de $ GW1 dev $ EXTIF1
ip route replace default scope global nexthop via $GW1 dev $EXTIF1 weight $W1 nexthop via $GW2 dev $EXTIF2 weight $W2 ip route sustituir por defecto alcance global a través de nexthop $ GW1 dev $ EXTIF1 peso W1 $ nexthop via $ GW2 dev $ $ EXTIF2 peso W2
LSROUTE=$(ip route show) LSROUTE = $ (ip route show)
echo "$LSROUTE" | mail -s "GWPING - Routing table changed. Both lines are up." echo "$ LSROUTE" | mail-s "GWPING - tabla de enrutamiento cambiado. Ambas líneas son". -r $EMAILFROM $EMAILTO - r $ EMAILFROM $ EMAILTO
fi Fi
fi Fi
sleep $SLEEPTIME el sueño de dólares SLEEPTIME
done hecho

Also I’m starting this script as service from /etc/init.d También estoy empezando este script como servicio de / etc / init.d

# cat /etc/init.d/gwping # Cat / etc / init.d / gwping
#!/bin/sh #! / bin / sh
# Author: Viliam Kocinsky # Autor: Viliam Kocinsky

### BEGIN INIT INFO # # # BEGIN INIT INFO
# Short-Description: Monitor Internet access connection links and modify kernel route if some link go down. # Short-Descripción: Monitor de acceso a Internet y enlaces de conexión del núcleo modificar la ruta si algún vínculo ir hacia abajo.
# Description: This is startup script for gwping script, that manage internet connection failover (if you have at least 2 providers). # Descripción: Este script es para gwping script, que gestionan los fallos de conexión a internet (si tiene al menos 2 proveedores).
# That is, it reguraly ping one IP address # Es decir, ping reguraly una dirección IP
# on internet through certain provider (but trying all) . # A Internet a través de determinados proveedores (pero tratando todos). If ping doesn’t come back, than it addjust kernel route table. Si esto no se vuelve, de lo que addjust núcleo ruta mesa.
# See inside script for details. # Ver el interior de script para obtener más detalles. This script is from the website: Este script es de la página web:
# http://blog.taragana.com/index.php/archive/how-to-load-balancing-failover-with-dual-multi-wan-adsl-cable-connections-on-linux/ # Http://blog.taragana.com/index.php/archive/how-to-load-balancing-failover-with-dual-multi-wan-adsl-cable-connections-on-linux/
#
### END INIT INFO # # # END INIT INFO

command="$1" comando = "$ 1"

case "$command" in caso "$" en
start)
echo "Starting gwping." echo "A partir gwping".
/usr/local/sbin/gwping & / usr / local / sbin / gwping &
echo $! echo $! > /usr/local/share/gwping_pid > / Usr / local / share / gwping_pid
;;
stop)
echo "Stoping gwping." echo "stoping gwping".
kill -9 $(cat /usr/local/share/gwping_pid) && rm /usr/local/share/gwping_pid kill -9 $ (cat / usr / local / share / gwping_pid) & & rm / usr / local / share / gwping_pid
;;
*)
echo "Usage /etc/init.d/gwping start|stop" echo "Uso / etc / init.d / gwping empezar | parar"
;;
esac ESAC