Linksys Tomato Firmware v1.27.8747: DSL Modem Reboot Script Help Required

Discussion in 'Tomato Firmware' started by Aquafire, Sep 22, 2010.

  1. Aquafire

    Aquafire LI Guru Member


    Although not directly related to tomato. But since it involves the use of Tomatio, I am asking the question over here.

    I am running Aztech DSL600E DSL Modem with IP (in bridge mode) with the following firmware information :

    Linux RouterTech.AR7RD 2.4.17_mvl21-malta-mips_fp_le #1 Wed Jul 23 00:24:31 BST 2008 mips unknown

    It is connected to the WAN port of a Linksys WRTSL54GS IP running Tomato Firmware v1.27.8747 ND USB vpn3.6 which is acting as the gateway / DHCP for the rest of the network. I can access the modem interface just by writing its IP address in the web browser.

    It is happening quite often these days that my internet service locks up for no reason at random intervals and modem thus hangs. Sometimes it disconnects and never connects again (the connection light keeps blinking). The remedy to such problems are usually a cold boot (turning off and on the modem) or doing a software reset using the Web interface of the Modem Firmware [System --> Reboot Router --> Yes Reboot Now (Button)].

    Since I am not usually at home to monitor this, I need to write a script in the Linksys router interface that if it detects the disconnection to internet it should reboot the modem and wait for "x" amount of time before checking and ensuring that connectivity has been restored.

    It maybe something like which I have already tried, which is, keep checking the ping connectivity to any website ( for example) every "x" amount of time, if the ping response is not received (maybe within y" amount of time), then run any given script and wait for it to come back. The script I wrote earlier is

    I am checking the ping response from "" and based on it, controlling the Linksys GPIO PIN 5 (as a test example ) and printing the modem hang up failure frequency in a text file for later reference. I call this script as which is called by a cron job after every minute.

    Now instead of controlling on/off with GPIO 5, I dont know how to call the "Reboot Router (button)" in the router ( interface. In the firmware directory of the router (accessed via telnet), I can see the following files (or maybe CGI scripts, i dont know much about it)

    I guess the restart and reboot button would execute any of these scripts from the DSL Modem web interface.

    So based on the collective experience of the folks here, can some please guide me how to access these scripts from within tomato interface to Turn OFF and ON (Cold Boot) or at least do the Reboot Router (Soft Boot) of the DSL modem to remedy the situation.

    I hope i was barely able to make myself clear. Thanks for reading and replying.
  2. Toastman

    Toastman Super Moderator Staff Member Member

    I can't help you with any way to force the modem to reboot. Question - is it an ADSL2+ connection that is giving you this problem?

    Just to share the info that I had a similar problem. My ADSL2+ sync would be lost, and the modem did not reconnect - it would sit there with the light blinking until it was rebooted manually. Rebooting the router did not help, the ADSL sync was lost so there was nothing the router could do - it was a modem fault.

    I tried many, many modems (both dedicated modems and router/modems) and I found only two models that worked properly in ADSL2+ mode, and would reconnect every time. Basically, there appears to be something wrong with the firmware in many ADSL2+ modems. All modems I tried worked fine on normal ADSL up to 8Mbps.
  3. occamsrazor

    occamsrazor Network Guru Member

    ...and the two winners are? :)
  4. Toastman

    Toastman Super Moderator Staff Member Member

    Not likely to help you much I'm afraid. One is a Hatari Wireless HWAA101 router/modem and the other is a Huawei MT880 router/modem - both have been given away here by ISP's and probably no longer available. Other modems using the same chipsets did not function correctly - I guess the firmware was different. You just need to keep trying - borrow from your friends, take on approval from shops etc. until you find a winner.

    The Huawei modem also download at 17.3 Mbps - all others ever tested reached 16Mbps (my ISP's stated bandwidth). So I take my hat off to Huawei.

    Actually, I'm looking for more Huawei MT880's, if anyone has one spare in their junkbox, PM me.
  5. mstombs

    mstombs Network Guru Member

    How do you measure your ADSL download Toastman?

    Mine currently is [​IMG] or [​IMG]

    with modem stats

    Modem Status
    Connection Status 	  	Connected
    Ds Rate (Kbps) 	  	16422
    Us Rate (Kbps) 	  	1020
    DS Margin 	  	6
    US Margin 	  	8
    DS Line Attenuation 	  	19
    US Line Attenuation 	  	10
    Trained Modulation 	  	ADSL_2plus 
    LOS Errors  	   	0
    Peak Cell Rate 	  	2405 cells per sec
    CRC Rx Fast 	  	0
    CRC Tx Fast 	  	0
    CRC Rx Interleaved 	  	74
    CRC Tx Interleaved 	  	0
    Path Mode 	  	Interleaved
    Modem System Uptime: 118 hours 22 minutes, but last re-connected only 9 hours ago

    on an old Linksys ADSL2MUE running RouterTech 2.94 in PPPoA half-bridge mode behind a WRT54GL-TM running latest tomatousb 2.6 kernel beta.

    At times very unstable in ADSL2+, and it will try for ages to reconnect until the ISP end auto adjusts the SNR target.

    Back on subject - the OP is looking for a script way of rebooting the modem. If the OS is still co-operating you could do it via http and the web interface, but the "Reboot Router" command pops up a confirmation button. I guess it would be easier to use Telnet to simply login and "/sbin/reboot" - I've seen a script on these forums to send an email using telnet - this would be much easier. But if the modem actually locks up - what happened to that hardware mod to power-cycle the modem? In both cases the script is going to be tricky to get right - need to leave long enough for the modem to reboot and Tomato to log-in over pppoe...
  6. Toastman

    Toastman Super Moderator Staff Member Member

    I use servers in Bangkok, Songkla, Singapore. PPPOE LLC MTU 1492 - QOS off, no other traffic on router. Most servers worldwide are similar. These pings on RT-N16, pings on WRT54GL are slower.

    [​IMG] [​IMG]

    Oh, forgot to say, yes, most of the modems I tested are totally unresponsive when they lose sync, probably crashed - they can't be rebooted except by pulling the plug. A few of them still had web access but did not respond to any attempt to change anything. And another comment - not many ADSL2+ modems (including many ISP-supplied Wireless/routers) were actually capable of sustained 16Mbps throughput. Aplogies to Aquafire if we're getting off-topic!
  7. Aquafire

    Aquafire LI Guru Member

    Well apologies...accepted...yeah we are swaying away a bit from the topic. For your information I do have a Huawei MT880 very basic DSL modem provided to me by the ISP when I took the connection.

    I did not use it much though, and switched to Aztech DSL600E , primarily because it is upgradeble with custom firmware from , which open up quite new possibilties. But since Tomato on Linksys offers much greater flexibitliy, I am now primarily using the Aztech DSL600E in full bridged mode.

    So basically my Huawei is spare, wanna buy it, you are more than welcome, but you have to bear the shipping charges :)

    The problem is occassional and seasonal with my ISP service, so I need to have a automatic recovery method for it. It is not with the ADSL2+ modulation or anything at my side. I have kept the modem in Multi-Modulation mode anyways to ensure best possible handshake.

    Yeah well now are you to the point. Very frequently the modem is still responsive and the web-interface of the modem keeps working (accessed via its IP address). You are right , I need to get to that "Reboot Router" confirmation button, via a script in Linksys, if internet disconnection occurs.

    If according to how you suggest, using telnet is a manual (user triggered event) or can it be done automatically. Any script examples would be a great help. As you can see in the first post, I have discovered in the modem firmware directory, where the CGI scripts reside (which possible are used, to reset or reboot the modem).

    According to the router tech website, there is also some script called "" which can be made to run on the modem, but only when it is not in BRIDGED mode. Since in my setup I prefer using the bridged mode, so maybe its not an option.

    Yeah I was the one working on the idea of modem lockup and then subsequent power cycling switch. It mostly done, I am controlling the GPIO PIN 5 LED (White SES) light with the script. Just above the LED, i have placed a photo transistor what alters the state on LED ON/OFF.

    Connected to the photo transistor is a circuit with relay and control transistor which is to be wired-in between the +/- wires of the power adapter of DSL modem. Hopefully if everything goes as planned, it should work.

    But I am maybe getting a bit lazy to do this manual work and wanted to find out a software based way to do so.

    Secondly I have seen another behavior tomato. I have written the reboot script and saved it in /JFFS directory. The command to call the script (basically a cron job) is written in the 'Scheduler' section of the firmware to be fired after every minute.

    The commands written in the 'Scheduler' (and also other like USB automount, firewall) are basically then copied as xxxxx.cmd files in the /tmp/var or maybe usr/tmp folder after some time delay from a cold restart of the router (swtiched ON from OFF state). These commands are then called every minute (according to the Scheduler setting) to perform specific function.

    The peculiar behavior I have seen is that if the router is started from a cold-state and the DSL modem is already working and connected to the internet , then these scheduling commands are copied correctly and hence would fire-up the subsequent times whenever any disconnection occurs.

    But if the DSL modem and Internet connection is already down, then these scheduling commands are not copied in the /usr/tmp folder and hence would never fire-up anytime. This happens no matter how long I wait after a router cold-start or warm-restart for that matter.

    This basically kills the whole purpose of the script, which is intended to power cycle the modem (no matter what state the modem is in, when the router had a cold-start). The execution of the script in Linksys seems to be now dependent on the fact that the modem should be connected at least at the time when it had a cold-boot. If the scripts are copied once, then they would keep firing up on all subsequent events.

    Hope I am barely able to make myself clear.

    Thanks for reading and replying though.

    Waiting for some more ideas, keep pouring.
  8. mstombs

    mstombs Network Guru Member

    It turns out to be pretty easy to use Tomato's Busybox Telnet with this script

    sleep 2
    echo root
    sleep 2
    echo Admin
    sleep 2
    echo /sbin/reboot
    sleep 2
    ) | telnet > session.log
    Change IP address and password to what you use, and "/sbin/reboot" to something kinder to test!

    It does work here:-

    root@wrt54g-tm:/tmp/home/root# ./
    root@wrt54g-tm:/tmp/home/root# cat session.log
    RouterTech.AR7RD login: root
    BusyBox v1.17.1 (2010-08-18 10:24:49 BST) built-in shell (ash)
    Enter 'help' for a list of built-in commands.
    /var # /sbin/reboot
    / #
    Entering character mode
    Escape character is '^]'.
    and a couple of minutes later I am able to post again!
  9. Aquafire

    Aquafire LI Guru Member

    Hmm.. now that looks like a ray of hope :)

    Will test it in the evening when I get back home and will then bother you thoroughly for the problems I encounter :)

    Just asking for the moment, considering that this script should be executed , only when a disconnection from the internet is detected. Which is checked by a previous script I wrote as follows :

    how can I then call the script you mentioned ( , if the condition is true (no connection to internet). Basically your script needs to be called from within my script replacing line number 5 ( since now we dont want to control GPIO state, but to call this rebooting script for the DSL modem).

    Any ideas how it could be done. Maybe test it at your end if possible.

    Thanks for help.
  10. Toastman

    Toastman Super Moderator Staff Member Member

    So, you are using the DSL600E as a basic modem in bridged mode. Still flogging the dead horse, did you try reverting to the stable Huawei MT880? You just may find it saves you needing the kludge. I work along these lines - the modem is supposed to reconnect. It isn't doing so. Therefore it is the modem that is at fault and it should not be necessary to jump through hoops.

    I may be interested in the modem if you don't need it, I'm in Bangkok, Thailand. Any idea of shipping cost?
  11. Aquafire

    Aquafire LI Guru Member

    "To every man his own", my experience with MT880 has been as worse as you might be considering the DSL600E to be ...a dead horse.

    I am no Pro, but I am also been in the same industry for quite some time and I even tried switching back to MT880 which did not resolve the problem. Once out of sync due to any reason (line noise, network issues, line attenuation), the modem whatever it maybe, sometimes do not connects itself again with the DSLAM. Running on copper lines it is expected, even the new Fiber Optic based ONU for customer premises have this problem.

    Sending you to bangkok, would be much costly than for what you would get an old used piece from any computer junkyard in the neighbourhood. Plus exporting any electronic item (fedEx, DHL) , does pose some custom regulation plus import duty at your end, which would be a bigger mess to get through.

    I am in Karachi, Pakistan. Drop me a line if sometime you visit here, will get in touch to hand it over to you :).
  12. Toastman

    Toastman Super Moderator Staff Member Member

    Sorry, flogging the dead horse is a British expression - referring to my going back to the same argument :)

    Fair enough - you've tried it, and it doesn't sing. Nonetheless, there is still something wrong with the firmware. If it will connect after a reboot, it should have connected before a reboot. But belt and braces is always a nice idea.
  13. Aquafire

    Aquafire LI Guru Member


    I have managed to make it work. The script ( which I originally mentioned in my earlier post now looks like this :

    Which calls another script "" (short for rebooting modem) and at the same time illuminates Whites SES LED to tell me when this is going on.

    For the sciprt I am thankful to mstombs who has given me right guidance to write it as follows (basically just a copy of what he posted, with the only change of IP address of my DSL modem, connected to WAN port in Bridge Mode).

    I have called the script via Scheduler after every 3 minutes to check the connectivity.

    Seems like it can ensure to automatically maintain a perpetual internet connection (passing through the odd disconnections itself).

    Will post results after real world checking in some days, working beautifully for the while.

  14. mstombs

    mstombs Network Guru Member

    Aquafire - please not there was a typo in the ha"shebang" at the top of the reboot script - I corrected it above - but you have used the old version. The script still works as "/bin/sh" is some sort of default - but better to correctly use "#!/bin/sh"
  15. Aquafire

    Aquafire LI Guru Member

    OK i have corrected the script. Thanks for it anyways.

    It also happens sometimes that apparently the script stops executing via the scheduler time interval defined (basically a cron job command called after every x minutes). I mean that the modem gets disconnected and the script does not seems to be triggered in the given time.

    Is there a way to check the status of the cron jobs running in the background to check is it really working in all the cases and scenarios or does it stops executing after a defined number of repetitions.

  16. rhester72

    rhester72 Network Guru Member


  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice