Se for no BFW 3.x sim! Ele tem Watchdog e funciona perfeitamente, só tem que fazer algumas alterações para poder funcionar com os ips de pings que a suas operadoras possam pingar. Até pouco tempo atrás eu não tinha a informação de que poderia colocar PING='8.8.8.8' no brazilfw.cfg para corrigir isso, por isso venho apresentar a solução que eu uso, alterando o arquivo do watchdog.
1) Crie um arquivo dentro de /etc/brazilfw/custom, chamado route-monitor.
2) Dentro dele cole isto:
- Código: Selecionar todos
#!/bin/sh
# Copyright (C) 2012 Washington Rodrigues <woshman@brazilfw.com.br>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. /etc/brazilfw/brazilfw.cfg
. /lib/system-functions
export APP_NAME="route-monitor"
[ -z "$PING_IPS" ] && PING_IPS="8.8.8.8,208.67.222.222"
[ -z "$PING_WAIT" ] && PING_WAIT="5"
[ -z "$CHECK_INTERVAL" ] && CHECK_INTERVAL="60"
ROUTECHANGE="/var/run/route.change"
ROUTEFILE="/proc/net/route"
CHK_CONN="/var/state/check_connection.lst"
SMFILE="/var/run/smartroute.reload"
EXTIPFILE="/var/state/externaladdr.inet"
NETRELOAD="/tmp/network.reload"
EXTIPFILE="/var/state/externaladdr.inet"
IPROUTE="ip route replace default table main proto static "
ping_remote() {
[ -z "$1" ] && exit
if [ ! -e "$CHK_CONN" ]; then
for IP in $(split "$PING_IPS" ","); do
echo "$IP" >> $CHK_CONN
done
fi
[ ! -e "$CHK_CONN" ] && exit
CHK_LIST=$(cat $CHK_CONN)
CCOUNT=1
NET_STATUS=1
for SRV in $CHK_LIST; do
ping $SRV -I $1 -c1 -w$PING_WAIT >/dev/null 2>&1
RESP=$?
if [ "$RESP" = 0 -a "$CCOUNT" -gt 1 ]; then
sed -i "$CCOUNT"'d;1i\'$SRV $CHK_CONN
fi
if [ "$RESP" = 0 ]; then
NET_STATUS=0
break
fi
CCOUNT=$((CCOUNT+1))
done
echo $NET_STATUS
}
ping_gateway() {
ping $1 -I $2 -c1 -w$PING_WAIT >/dev/null 2>&1
echo $?
}
rm -fr $CHK_CONN >/dev/null 2>&1
while :; do
CHK_ROUTE="$(awk '$4~/003/{print $3}' $ROUTEFILE)"
if [ -z "$CHK_ROUTE" ]; then
ROUTEVAR="$IPROUTE $(find /tmp -type f -name \*.inet -exec grep -il "LINK_CONNECTION='internet'" {} \; | \
while read FILENAME; do
. $FILENAME
if [ "$LINK_TYPE" = "pppoe" -o "$LINK_TYPE" = "ppp" ]; then
INTERFACE_PHYSICAL="$INTERFACE_PPP"
else
. /tmp/$PHYSICAL_ALIAS.phy
[ -e "/tmp/$PHYSICAL_ALIAS.veth" ] && . /tmp/$PHYSICAL_ALIAS.veth
fi
[ "$LOADBALANCE" != "no" ] && echo -n "nexthop via $GATEWAY dev $INTERFACE_PHYSICAL weight $WEIGHT "
sed -i s/STATUS.*/STATUS=\'up\'/g $FILENAME >/dev/null 2>&1
log_connection "$(basename $FILENAME .inet): $LINK_TYPE connection up"
done)"
$ROUTEVAR >/dev/null 2>&1
echo "" > $ROUTECHANGE
else
ROUTEVAR="$IPROUTE $(find /tmp -type f -name \*.inet -exec grep -il "LINK_CONNECTION='internet'" {} \; | \
while read FILENAME; do
. $FILENAME
if [ "$LINK_TYPE" = "pppoe" -o "$LINK_TYPE" = "ppp" ]; then
[ "$LOADBALANCE" != "no" ] && echo -n "nexthop via $GATEWAY dev $INTERFACE_PPP weight $WEIGHT "
else
. /tmp/$PHYSICAL_ALIAS.phy
[ -e "/tmp/$PHYSICAL_ALIAS.veth" ] && . /tmp/$PHYSICAL_ALIAS.veth
if [ "$(ping_gateway "$GATEWAY" "$IPADDR")" = 0 ]; then
NEW_STATUS="wait"
if [ "$(ping_remote "$IPADDR")" = 0 ]; then
[ "$LOADBALANCE" != "no" ] && echo -n "nexthop via $GATEWAY dev $INTERFACE_PHYSICAL weight $WEIGHT "
NEW_STATUS="up"
fi
else
NEW_STATUS="down"
fi
[ "$NEW_STATUS" != "up" -a "$LINK_PERSISTENT" = "yes" -a "$LOADBALANCE" != "no" ] && echo -n "nexthop via $GATEWAY dev $INTERFACE_PHYSICAL weight $WEIGHT "
if [ "$STATUS" != "$NEW_STATUS" ]; then
log_connection "$(basename $FILENAME .inet): $LINK_TYPE connection $NEW_STATUS"
$(echo "sed -i s/STATUS.*/STATUS='$NEW_STATUS'/g $FILENAME")
echo "" > $ROUTECHANGE
fi
fi
done)"
fi
if [ -e "$ROUTECHANGE" ]; then
rm -fr $ROUTECHANGE >/dev/null 2>&1
$ROUTEVAR >/dev/null 2>&1
echo "$(find /tmp -type f -name \*.inet -exec grep -il "LINK_CONNECTION='internet'" {} \; | while read FILENAME; do
EXTIP="0.0.0.0"
. $FILENAME
[ "$STATUS" = "up" ] && [ "$(is_internalip $IPADDR)" != "true" ] && EXTIP=$IPADDR || EXTIP=$(get_wan_ip $IPADDR)
echo "$(basename $FILENAME .inet):$EXTIP"
done)" > $EXTIPFILE
/etc/init.d/ipupdate reload >/dev/null 2>&1
/etc/rc.d/rc.accept >/dev/null 2>&1
/etc/rc.d/rc.forward >/dev/null 2>&1
/usr/local/sbin/route-mark >/dev/null 2>&1
/etc/rc.d/rc.vpn-client >/dev/null 2>&1
fi
if [ -e "$SMFILE" ]; then
rm -fr $SMFILE >/dev/null 2>&1
/etc/rc.d/rc.route >/dev/null 2>&1
fi
if [ -e "$NETRELOAD" ]; then
rm -fr $NETRELOAD >/dev/null 2>&1
/etc/rc.d/rc.inet
fi
[ -e "/tmp/time.syncfail" ] && /etc/rc.d/rc.time >/dev/null 2>&1 &
[ -e "/var/run/squid.reload" ] && /etc/init.d/squid reload >/dev/null 2>&1 &
sleep $CHECK_INTERVAL
done
Onde está
[ -z "$PING_IPS" ] && PING_IPS="8.8.8.8,208.67.222.222", ou seja, onde se encontram os ips de ping, mude para ips que vc tenha certeza de que podem ser pingados pela sua operadora, os ips padrões que vem no BFW são alguns ips da Embratel que nem todas as operadores conseguem pingar, justamente por causa de briga de operadoras (sim isso realmente existe e é mais comum do que vcs pensam), por isso precisamos adequar os ips aos que possam ser pingados.
3) No Script de Inicialização do BFW ou rc.local, cole isso:
- Código: Selecionar todos
#Resolve Problema do Router Monitor
chmod 777 /etc/brazilfw/custom/route-monitor
rm /usr/local/sbin/route-monitor
cp /etc/brazilfw/custom/route-monitor /usr/local/sbin/
/etc/rc.d/rc.inet
/etc/rc.d/rc.route
Aqui diz basicamente para cada vez que inicializar o BFW substituir o arquivo route-monitor pelo que criamos no diretório custom, damos privilégios de execução e reiniciamos as interfaces de rede e a tabela de rotas.
Pronto, este é o método que eu uso para isso, é mais trabalhoso, é mais complicado mas, funciona perfeitamente!
Espero ter ajudado!