PFSENSE NAO RENOVA IP WAN AUTOMATICAMENTE
-
Pessoal, eu vi este mesmo tópico no fórum em inglês: https://forum.pfsense.org/index.php/topic,17243.msg89348.html#msg89348, porém estou com um problema neste script.
Segui o procedimento mas acabou que estou perdendo conexão direto e após completar o script de verificações ele reinicia meu pfsense. Acredito que o tempo limite do ping para o google.com ou 8.8.8.8 esteja curto, fazendo com que o script entenda que deve reinciar a interface e depois reiniciar o firewall.
Alguém sabe me ajudar a entender o script? Está de acordo para uso com o provedor NET??
#!/bin/sh
#=====================================================================
pingtest.sh, v1.0.1
Created 2009 by Bennett Lee
Released to public domain
(1) Attempts to ping several hosts to test connectivity. After
# first successful ping, script exits.
(2) If all pings fail, resets interface and retries all pings.
(3) If all pings fail again after reset, then reboots pfSense.
History
1.0.1 Added delay to ensure interface resets (thx ktims).
1.0.0 Initial release.
#=====================================================================
#=====================================================================
USER SETTINGS
Set multiple ping targets separated by space. Include numeric IPs
(e.g., remote office, ISP gateway, etc.) for DNS issues which
reboot will not correct.
ALLDEST="google.com yahoo.com 24.93.40.36 24.93.40.37"
Interface to reset, usually your WAN
BOUNCE=re0
Log file
LOGFILE=/root/pingtest.log
#=====================================================================COUNT=1
while [ $COUNT -le 2 ]
dofor DEST in $ALLDEST
do
#echodate +%Y%m%d.%H%M%S
"Pinging $DEST" >> $LOGFILE
ping -c1 $DEST >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
#echodate +%Y%m%d.%H%M%S
"Ping $DEST OK." >> $LOGFILE
exit 0
fi
doneif [ $COUNT -le 1 ]
then
echodate +%Y%m%d.%H%M%S
"All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
/sbin/ifconfig $BOUNCE downGive interface time to reset before bringing back up
**sleep 10
/sbin/ifconfig $BOUNCE upGive WAN time to establish connection
sleep 60**
else
echodate +%Y%m%d.%H%M%S
"All pings failed twice. Rebooting…" >> $LOGFILE
/sbin/shutdown -r now >> $LOGFILE
exit 1
fiCOUNT=
expr $COUNT + 1
done -
ele esta pingando para 4 enderecos: google.com yahoo.com 24.93.40.36 24.93.40.37 e usando a placa re0, isso esta de acordo com a sua estrutura? sua placa é essa mesmo? o que o arquivo de log diz?
-
ele esta pingando para 4 enderecos: google.com yahoo.com 24.93.40.36 24.93.40.37 e usando a placa re0, isso esta de acordo com a sua estrutura? sua placa é essa mesmo? o que o arquivo de log diz?
Testei todos os endereços, inclusive mudei para somente o ip do google (8.8.8.8). A placa WAN é esta mesma re0. No log "/root/pingtest.log" ele mostra apenas a mensagem descrita no script indicando o que está fazendo… All pings failed twice. Rebooting...
Tem outro arquivo de log? Minha conexão tem perdas, mas são mínimas, tipo 1 salto.
Desde já agradeço a ajuda.
-
substitua os comandos de down, up e reboot por variaveis de log e para ver se o script esta sendo executado corretamente, e teste na mao..
-
substitua os comandos de down, up e reboot por variaveis de log e para ver se o script esta sendo executado corretamente, e teste na mao..
Lucas, como eu faço isso? Não entendo muito de programação. Ficaria assim?(desculpa minha ignorância rs)
#!/bin/sh
#=====================================================================
pingtest.sh, v1.0.1
Created 2009 by Bennett Lee
Released to public domain
(1) Attempts to ping several hosts to test connectivity. After
# first successful ping, script exits.
(2) If all pings fail, resets interface and retries all pings.
(3) If all pings fail again after reset, then reboots pfSense.
History
1.0.1 Added delay to ensure interface resets (thx ktims).
1.0.0 Initial release.
#=====================================================================
#=====================================================================
USER SETTINGS
Set multiple ping targets separated by space. Include numeric IPs
(e.g., remote office, ISP gateway, etc.) for DNS issues which
reboot will not correct.
ALLDEST="google.com yahoo.com 24.93.40.36 24.93.40.37"
Interface to reset, usually your WAN
BOUNCE=re0
Log file
LOGFILE=/root/pingtest.log
UP=/root/log_up.log
DOWN=/root/log_down.log
REBOOT=/root/log_reboot.log
#=====================================================================COUNT=1
while [ $COUNT -le 2 ]
dofor DEST in $ALLDEST
do
#echodate +%Y%m%d.%H%M%S
"Pinging $DEST" >> $LOGFILE
ping -c1 $DEST >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
#echodate +%Y%m%d.%H%M%S
"Ping $DEST OK." >> $LOGFILE
exit 0
fi
doneif [ $COUNT -le 1 ]
then
echodate +%Y%m%d.%H%M%S
"All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
/sbin/ifconfig $BOUNCE >> $DOWNGive interface time to reset before bringing back up
sleep 10
/sbin/ifconfig $BOUNCE >> $UPGive WAN time to establish connection
sleep 60
else
echodate +%Y%m%d.%H%M%S
"All pings failed twice. Rebooting…" >> $LOGFILE
/sbin/shutdown -r now >> $LOGFILE
exit 1
fiCOUNT=
expr $COUNT + 1
done -
faca o seguinte, execute o codigo abaixo do jeito que esta, depois altere a variavel ALLDEST="8.8.8.8" para ALLDEST="1.1.1.1" e execute denovo, apos isso poste aqui o log
obs: nao se preocupe que nao ira reiniciar seu server
#!/bin/sh
#=====================================================================
pingtest.sh, v1.0.1
Created 2009 by Bennett Lee
Released to public domain
(1) Attempts to ping several hosts to test connectivity. After
# first successful ping, script exits.
(2) If all pings fail, resets interface and retries all pings.
(3) If all pings fail again after reset, then reboots pfSense.
History
1.0.1 Added delay to ensure interface resets (thx ktims).
1.0.0 Initial release.
#=====================================================================
#=====================================================================
USER SETTINGS
Set multiple ping targets separated by space. Include numeric IPs
(e.g., remote office, ISP gateway, etc.) for DNS issues which
reboot will not correct.
ALLDEST="8.8.8.8"
Interface to reset, usually your WAN
BOUNCE=re0
Log file
LOGFILE=/root/pingtest.log
#=====================================================================COUNT=0
while [ $COUNT -le 1 ]
do
for DEST in $ALLDEST
do
echodate +%Y%m%d.%H%M%S
"Pinging $DEST" >> $LOGFILE
ping -c1 $DEST >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echodate +%Y%m%d.%H%M%S
"Ping $DEST OK." >> $LOGFILE
exit 0
fi
done
if [ $COUNT -le 0 ]
then
echodate +%Y%m%d.%H%M%S
"All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
#/sbin/ifconfig $BOUNCE down
# Give interface time to reset before bringing back up
sleep 10
echodate +%Y%m%d.%H%M%S
"Passou sleep 10 $BOUNCE." >> $LOGFILE
#/sbin/ifconfig $BOUNCE up
# Give WAN time to establish connection
sleep 60
echodate +%Y%m%d.%H%M%S
"Passou sleep 60 $BOUNCE." >> $LOGFILE
else
echodate +%Y%m%d.%H%M%S
"All pings failed twice. Rebooting…" >> $LOGFILE
#/sbin/shutdown -r now >> $LOGFILE
exit 1
fi
COUNT=expr $COUNT + 1
done