obey-robots.txt
21 April 2019, 04:52
Navigatie
Onderwerp bekijken
Alle vragen m.b.t. de instellingen van de Hardware kun je hier stellen.
 Onderwerp afdrukken

Check-and-fix watchdog-script for ZIPB-enabled Copperjets

dennisvo
I think I have created a monkey-proof check-and-fix watchdog-script for the Allied Copperjet 1616-2P modems that are provided by Alice. This script is created for people who use their modems in ZIPB-configuration (semi-bridge) that want their modem rebooted and/or fixed automatically. Of course you can alter the script for non-ZIPB configurations too. Please read on.

Let me start by giving credits to the person who inspired me in the first place: thanks frater! (http://www.dd-wrt...4af58b7eb9)

The main purpose of this script is to reboot your modem if it isn't working anymore and to check and fix your ZIPB-settings. Hereby managing that your router always gets the correct external IP-address from the DHCP-server on your Copperjet. As you might know Copperjets have a strange bug where they loose ZIPB-settings after a reboot. This script fixes this too.

I did some succesful tests using this script, but the proof is in eating the pudding. Please beware: no warranties are given. Use at your own risk.

My script runs from a JFFS-enabled DD-WRT configured router (tested om v2.3SP2), but it should be able to run on other routers / *nix-machines too (the scripts might need a few tweaks then though).

Let's start off with the main script:

(please replace <your external ip> and <routername> with the correct names. The routername can be found via the webinterface under ZIPB-settings)

On your DD-WRT router create a file checkmodem.sh:

Download broncode  Code
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin
wanip=<your external ip>
routerip=`ifconfig vlan1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
result=`ping -c 1 172.19.3.1 | grep -c from`
if [ $result == 0 ]; then
 echo `date` 'No modem.. restart WAN' | tee -a /jffs/zipB.log
 stopservice wan
 startservice wan
else
 if [ ! -f /tmp/fail_count ]; then
  echo "" >/tmp/fail_count
 fi
 result=`grep -c x /tmp/fail_count`
 if [ $result -ge 3 ]; then
   echo `date` 'After $result tries the modem is not functioning... will reboot'  | tee -a /jffs/zipB.log
   (sleep 1; echo -e "admin\r"; sleep 1; echo -e "bb@l1cE322\r"; sleep 1; echo -e "system restart\r") | telnet 172.19.3.1
   echo "" > /tmp/fail_count
 else
  result=`ping -c 1 $wanip | grep -c from`
  if [ $result == 0 ]; then
   echo "x" >>/tmp/fail_count
   echo `date` 'Modem not functioning... rewrite ZipB' | tee -a /jffs/zipB.log
   (sleep 1; echo -e "admin\r"; sleep 1; echo -e "bb@l1cE322\r"; sleep 1; echo -e "zipb set public device <routername>\r"; sleep 1; echo -e "user logout\r") | telnet 172.19.3.1
   stopservice wan
   startservice wan
  else
   if [ "$routerip" != "$wanip" ]; then
     echo `date` 'WAN IP not equal to external IP. ZIPB not configured... rewrite ZipB' | tee -a /jffs/zipB.log
     (sleep 1; echo -e "admin\r"; sleep 1; echo -e "bb@l1cE322\r"; sleep 1; echo -e "zipb set public device <routername>\r"; sleep 1; echo -e "user logout\r") | telnet 172.19.3.1
     stopservice wan
     startservice wan
   else
     logger -t 'ModemCheck' 'Modem alright'
#     echo `/bin/date` 'All OK' | tee -a /jffs/zipB.log
     echo -n "" > /tmp/fail_count
   fi
  fi
 fi
fi



Place this script in /jffs, and create a crontab file by executing the following command:

Download broncode  Code
echo '* * * * * root /jffs/checkmodem.sh' > /jffs/check_modem_cron



Now place the following script (checkmodemincron.wanup) in /jffs/etc/config/

Download broncode  Code
#!/bin/sh
cp /jffs/check_modem_cron /tmp/cron.d/check_modem
/sbin/stopservice cron
/sbin/startservice cron




This script copies the cronfile check_modem in /tmp/cron.d after every reboot, right after the WAN has come up. The /tmp folder on the router is being emptied on every reboot. This script copies the crontab file to the /tmp folder after every reboot. The JFFS-folder is being used for permanent storage.

Now reboot and off you should be. You can check if it works by uncommenting the 'All OK' line in the checkmodem.sh script. This should generate 'All OK' messages every minute in /jffs/zipB.log.

Please leave a message whether this works out for you or not.

Best regards,

Dennis.
 
BMP
Dennis,

Thanks for the script,

I made it sticky so it wil always be on top.

Regards BMP Smile
Gewijzigd door BMP op 28 januari 2010, 18:57
Wie ben ik om aan mijzelf te twijfelen
 
Yes
Hi Dennis,

real nice script! B)

I only wonder if it would be wise to not only check the modems own ip address.
My experience is that sometimes although the modem responds to a ping request still the internet might not be reachable.
That situation also needs a modem reboot then.

If the check is adjusted in such a way that an internet address is checked instead of the modems address, that will also cope with both the modem or the internet not being available.

My main test looks like this:

Download broncode  Code
#!/bin/sh
if ping -c 3 www.google.nl > /dev/null
then
   echo Internet connectivity ok at `date`
else
   if ping -c 3 alice.nl > /dev/null
   then
      sleep 0
   else
      echo Internet not reachable at `date`
      . /usr/local/bin/restartcopperjet.sh
   fi
fi




Cheers ;)

-------------------------------------------------------
The answer is Yes! The question is the question?
 
Spring naar forum:
 Nieuw onderwerp  Beantwoorden
Gebruik BBcode of HTML om naar; 'Check-and-fix watchdog-script for ZIPB-enabled Copperjets', te verwijzen!
BBcode:
HTML:
Vergelijkbare onderwerpen
Onderwerpen Forum antwoorden Laatste bericht
Copperjet 1616 -> ZIPB -> Linksys WRT54G -> LN 401 IPcam Eigen netwerk 3 29 januari 2011, 01:03
Copperjet 1616 -> ZIPB -> Linksys WRT54G v5.1 met DD-WRT Eigen netwerk 6 26 november 2009, 10:05
Geen verbinding zonder ZIPB Eigen netwerk 3 22 oktober 2009, 17:50
ZIPB niet betrouwbaar! Bridge? Algemeen 6 10 juli 2009, 18:40
Krijg met ZipB geen Extern IP Adres Algemeen 7 05 juni 2009, 22:41
Goedenacht bezoeker
Shoutbox
U moet ingelogd zijn om een bericht te plaatsen.

Er zijn geen berichten gepost.
Inloggen / Registreren
Gebruikersnaam

Wachtwoord



Wachtwoord vergeten?
Verzoek nieuw wachtwoord.
Laatst geziene leden
Ledenenquête
Welk modem heb je in gebruik voor je Alice internetverbinding?

Alice Copperjet
Ledenenquête: Welk modem heb je in gebruik voor je Alice internetverbinding? Alice Copperjet 85% [104 stemmen]
85% [104 stemmen]

Alice AVM
Ledenenquête: Welk modem heb je in gebruik voor je Alice internetverbinding? Alice AVM 8% [10 stemmen]
8% [10 stemmen]

Overige modems
Ledenenquête: Welk modem heb je in gebruik voor je Alice internetverbinding? Overige modems 7% [9 stemmen]
7% [9 stemmen]

Stemmen: 123
U dient in te loggen om te stemmen.
Gestart: 05 aug 2010

Enquête-archief