Automatically reset your cable modem when the Internet goes missing

So…  I have Comcast cable Internet service at home, and a Motorola SB6120 cable modem that I own myself.  I’m not sure if it is Comcast, the modem, the combination of the two, or something else altogether… but, every now and then, the modem goes into a funk and the Internet stops working, and the only way to fix it is to power-cycle the modem.

This doesn’t happen terribly often, maybe once a month or so.  (Occasionally it will happen, say, twice in one week and thus cause me to think about it a little more.)  Power-cycling the modem is not a big deal, but I do access stuff that I have at home remotely, so if the connection dies while I am at work or away someplace, I can’t fix it until I return home.

It would be great if there was a way for a computer at the house to, say, periodically check and see if the Internet is working and if it is not, somehow reset the modem.  So, I did some searching on the topic, and… it turns out that it is possible to do this, and in fact, it is pretty simple.

What you’ll need…

  • A PC at home that is on all of the time.
  • wget installed on said PC (Windows version here).

All I did was set up a script to fire every five minutes.  This script attempts to load the homepages of Google, Bing, Yahoo!, Facebook, and Twitter.  If all five fail, it will issue a reset command to the modem.

Wait, what?  During my searching I found someone else with Comcast mention that their modem had a web interface accessible at http://192.168.100.1/.  I checked and, sure enough, there is my cable modem talking to me.  On one of the pages, there is a button that you can click to reset it.  I used the Google Chrome developer tools to watch what happens when I click the button, and it is a simple request to:

  • http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem

You don’t even need a username/password to do it.  You can issue it from a scriptable tool like wget and it works there too.  There is about a 10-15 second delay from when the command is issued and the modem actually begins its power cycle, and then of course a minute or so while it reconnects.

Caveats…  For this fix to work, the following must be true:

  • Your modem must have a web-accessible reset button that you can hit with wget.  I only have one modem and one ISP to test with, so I don’t know if it is always this easy to find the reset button, if the URL for the reset command varies from modem to modem, or if all ISPs configure the modem to listen on the same IP address.
  • If your cable modem is listening on 192.168.100.1, your home network must be on a the subnet other than 192.168.100.x.  Otherwise, you won’t be able to talk to it (you’ll probably get your home router instead).
  • This assumes that the cable modem will respond to the reset request while it is in the funk state.  For me, this seems to be the case.
  • This also assumes that the intermittent problem lies in the modem (or beyond) and not in the router.  Again, for me, this seems to be the case.

Without further ado, my script, as a Windows batch file:

@ECHO OFF

REM This script checks for an active Internet connection by trying to access
REM five different web sites.  If all five checks fail, it will reset the cable
REM modem.

wget --tries=1 --timeout=10 -O - "http://www.google.com/"
IF %ERRORLEVEL%==0 GOTO done
echo Google failed.

wget --tries=1 --timeout=10 -O - "http://www.bing.com/"
IF %ERRORLEVEL%==0 GOTO done
echo Bing failed.

wget --tries=1 --timeout=10 -O - "http://www.yahoo.com/"
IF %ERRORLEVEL%==0 GOTO done
echo Yahoo! failed.

wget --tries=1 --timeout=10 -O - "http://www.facebook.com/"
IF %ERRORLEVEL%==0 GOTO done
echo Facebook failed.

wget --tries=1 --timeout=10 -O - "http://www.twitter.com/"
IF %ERRORLEVEL%==0 GOTO done
echo Twitter failed.

REM If we got here...  The Internet appears to be broken.
echo Restarting cable modem...
wget --tries=1 -O - "http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem"
echo Restarting cable modem. >> C:\Users\Aaron\log\internet-check.log
date /T >> C:\Users\Aaron\log\internet-check.log
time /T >> C:\Users\Aaron\log\internet-check.log
echo . >> C:\Users\Aaron\log\internet-check.log

exit 1

:done
echo The Internet appears to be working.
exit 0

I try to load five different sites and if they all fail, issue the reset command.  I also write out some log information so that I can see if the script is being effective.  If you want the logging, you probably want to change the path to the log file.

Anyway, I wrote the script about a week ago and, according to the log file, it has already rescued my Internet connection once while I was away.

This script should be easy enough to convert to bash for you Linux and Mac OS X folks.

Update: February 22, 2012

My next article describes how to use X10 devices to power-cycle the modem, so it doesn’t matter if you can reset it from the web interface or not.

26 thoughts on “Automatically reset your cable modem when the Internet goes missing”

  1. When i executed the script that is a part of the answer.

    Connecting to 10.0.0.1:80… connected.
    HTTP request sent, awaiting response… 200 ok
    Length: unspecified [text/html]
    Saving to: ‘STDOUT’

  2. hi! this is what i’ve been looking for. i am no good with programming so i’m and i have a different modem… a Prolink ADSL modem. i am hoping you could help me modify your script for it to work on my system with regards to the line [wget –tries=1 -O – “http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem”]

    hoping to hear from you soon. cheers!

  3. hi! this is what i’ve been looking for. i am no good with programming and i have a different modem… a Prolink ADSL modem. i am hoping you could help me modify your script for it to work on my system with regards to the line [wget –tries=1 -O – “http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem”]

    hoping to hear from you soon. cheers!

  4. Brilliant! It took some digging and fiddling to figure out the URLs for my cable modem, but it works great.

    In case anyone else has a Motorola SurfBoard SBG6580 (mine is from Time Warner), here are the commands that worked for me.

    First is the login, and second is the reboot command.

    Just put your password in the script.

    wget –tries=1 –post-data=”loginUsername=admin&loginPassword=yourpassword” http://192.168.100.1/goform/login

    wget –tries=1 –post-data=”SaveChanges=Reboot” http://192.168.100.1/goform/RgConfiguration

  5. Good article! One question though, is there a way to access the modem’s internal LAN 192.168.100.1 from external WAN? I’ve used port forwarding many times for IP cams and such, but my router (Linksys E2500) only allows port forwarding to 192 . 168 . 1.X internal addresses (of which all of my other LAN devices seem to be), not the 192 . 168 . 100.X of the router. How can I access the GUI at 192 . 168 . 100.X remotely?

  6. The router allows you to forward ports to a machine on your LAN, but the cable modem is not on your LAN (being attached to the WAN port on the router). The only way I can think of to accomplish this would be to install something on a LAN PC to redirect HTTP requests to the cable modem, and the open a port to said PC on your router. Apache with ProxyPass could do this but that might be a bit tricky to set up…

  7. thank you very much >>>>>>>>>> Arron
    my problem was that my router dosen’t support telnet by defult and telnet access will go off after
    reboot , as it only support telnet i debug mode>>> i am not a programmer but
    my Goal was that to make my linksys router WAG200G reboot when the net is off
    with your beutifule script and the ping to make sure that the net is off :)
    and it was diffeculte for me to fine a url to auto reboot through wget only >>>
    this is my adding hoping that it would help others >>>>>>>>>>

    @ECHO OFF

    REM This script checks for an active Internet connection by trying to access
    REM five different web sites. If all five checks fail, it will reset the cable
    REM modem.

    wget –tries=1 –timeout=10 -O – “http://www.google.com/”
    IF %ERRORLEVEL%==0 GOTO done
    echo Google failed.

    wget –tries=1 –timeout=10 -O – “http://www.bing.com/”
    IF %ERRORLEVEL%==0 GOTO done
    echo Bing failed.

    wget –tries=1 –timeout=10 -O – “http://www.yahoo.com/”
    IF %ERRORLEVEL%==0 GOTO done
    echo Yahoo! failed.

    wget –tries=1 –timeout=10 -O – “http://www.facebook.com/”
    IF %ERRORLEVEL%==0 GOTO done
    echo Facebook failed.

    wget –tries=1 –timeout=10 -O – “http://www.twitter.com/”
    IF %ERRORLEVEL%==0 GOTO done
    echo Twitter failed.

    REM If we got here… The Internet appears to be broken.
    echo Restarting cable modem…

    wget “http://192.168.0.1/setup.cgi?todo=debug”
    echo telnet 192.168.0.1
    echo reboot
    echo Restarting cable modem . >> “C:\Program Files (x86)\GnuWin32\bin\log\internet-check.txt”
    date /T >> “C:\Program Files (x86)\GnuWin32\bin\log\internet-check.txt”
    time /T >> “C:\Program Files (x86)\GnuWin32\bin\log\internet-check.txt”
    echo . >> “C:\Program Files (x86)\GnuWin32\bin\log\internet-check.txt”

    exit 1

    :done
    echo The Internet appears to be working.
    exit 0

  8. Hi, great information. sorry for the dum question but How do I setup this batch file to run automatically ? In windows task scheduler I don’t see a option to run by X minutes . thank you!

  9. If you set the task to run daily at midnight, there is a checkbox at the bottom of the schedule page to allow you to repeat the task at a specified interval.

  10. It seems the log only includes this no matter what the results were:

    Fri 06/26/2015
    07:55 AM
    .

    Is there a way to include a note in the log stating whether that run was successful or not? I cant seem to be able to tell if there was a rescue or not, only that the script ran.

  11. Thanks so much for this! I have this exact modem and ever since upgrading my machines in the house to Win10 my cable modem loses connectivity until I restart it every single day for some wierd reason. All I had to change in the script is where the log files were written, works a treat thx!

  12. I have a Motorola/Arris SB6183 Cable Modem. I tried the above solutions to reboot it from the command line, I could not succeed.

    This one seems close but It will not reboot it:
    wget –tries=1 –post-data=”SaveChanges=Reboot” http://192.168.100.1/goform/RgConfiguration
    When I go to web interface of the cable modem, this page has the “Reboot” button.
    http://192.168.100.1/RgConfiguration.asp
    When I manually click on it, it will ask me a question “Are you sure you want to reset the modem?, then I have to click “Yes” or “No”. Clicking Yes will reboot the modem.

    I wget creates a file on my PC named RgConfiguration.asp every time I run it. This file may give some clues what the correct command is, Unfortunately, I do not understand the programming and what is being exchanged between the wget and the Modem web server.

    If anyone accomplished this reboot with SB6183 Cable Modem, please share. It would be really nice to incorporate it into Tomato Firmware. Pls check here:
    http://www.linksysinfo.org/index.php?threads/v1-23-how-to-script-automatic-wan-dhcp-release-renew.29372/

  13. Thanks for posting this article. Been trying to figure out how to do something like this for a while now. For those who keep getting a “wget is not a recognized internal command” error, I just copied the contents of the GNUwin32/bin to the same folder as my batch file. the exe and all dlls. Good luck.

  14. MY_BEY

    I recently upgraded my modem to an SB6183 and instead of using wget I use the following curl command to reset the modem.

    curl –data “Rebooting=1” http://192.168.100.1/goform/RgConfiguration.pl

    I hope this is helpful to you or anyone else using this setup.

  15. A cheap instant solution is “MSNSwitch” and its many variants. Available on Amazon for about $100. Does the job right out of the box without any configuration, but also has many cool features if you want/need them. I have two of them, for a DSL modem at my parents’ house, and the cable modem at my house. Terrific.

  16. My SB6183 likes:

    wget –tries=1 –post-data=”Rebooting=1″ http://192.168.100.1/goform/RgConfiguration

    Just in case anyone else needs this info. The above methods described for the SB6183 did not work for me, for whatever reason.

  17. You can restart the newer ones with curl as follows:

    curl ‘http://192.168.100.1/cgi-bin/reboot’ –data ‘rebooting=1&RestoreFactoryDefault=’

  18. On my SBG9XX
    IT could be do with snmpset

    snmpset -v2c -c public 192.168.100.1 1.3.6.1.2.1.69.1.1.3.0 i 1

    But it needs snmpt-utils

  19. Китайский скребковый массаж ГУА-ША

    Молостов В.Д.. Все книги — Видео
    Скребковый массаж гуа-ша является китайским народным массажем, который возник в сельскохозяйственных районах Китая несколько тысячелетий назад.

    Массаж отличается простотой проведения. Берётся костяная пластинка, сделанная из рога буйвола, и ей целитель трёт кожу спины до покраснения. Главный механизм лечебного воздействия массажа состоит в выведении продуктов клеточного распада и токсинов из кожи спины. Тантрический массаж http://massage-relaks.ru/goods/Tantricheskij-massazh

    Парень на ночь http://massage-relaks.ru/goods/paren-na-noch

    массаж в бане сауне http://massage-relaks.ru/catalog/massazh-v-bane-saune

    Мужчины по вызову http://massage-relaks.ru/goods/muzhchina-po-vyzovu

    оргазм массаж http://massage-relaks.ru/goods/orgazm-massazh

    Продукты клеточного распада накапливаются у здорового человека. Тем более в организме человека накапливаются токсины, яды, продукты распада при болезни. Если вывести хотя бы часть токсинов из организма, то человек будет чувствовать себя значительно лучше.

    Поэтому, исходя из чисто теоретических представлений, массаж гуа-ша можно проводить всем здоровым людям и больным. Удаление токсинов из организма также способствует увеличению длительности жизни человека.

    Массаж

  20. Here’s something I put together for dd-wrt/tomato etc…

    ## Add a script to check WAN Connection
    sleep 300 #sleep for 5 mins before adding the script to the router
    touch /tmp/checkWAN.sh
    echo ‘#!/bin/sh
    HOST1=`ip route | awk “/default via/ {print $3}”` #Default Gateway
    HOST2=”8.8.8.8” # Google DNS
    ping -q -c 2 $HOST2 &> /dev/null; HOST2PING=$?; sleep 1;
    ping -q -c 2 $HOST1 &> /dev/null; HOST1PING=$?; sleep 1;
    if [ $HOST2PING -eq 1 ] && [$HOST1PING -eq 1] ; then
    wget –tries=1 -O – “http://192.168.100.1/reset.htm?reset_modem=Restart+Cable+Modem”
    #curl -v -d “RestoreFactoryDefault=1&ResetReq=1” http://192.168.100.1/goform/RgConfig &> /dev/null
    #curl -d ResetReq=1 http://192.168.100.1/goform/RgConfig &> /dev/null
    /sbin/reboot
    fi’ > /tmp/checkWAN.sh
    touch /tmp/cron.d/checkWAN
    echo ‘*/5 * * * * root /bin/sh /tmp/checkWatchdog.sh’ > /tmp/cron.d/checkWAN

  21. Great Article!

    But I have a different problem. My ISP has assigned me dynamic IPs. So whenever I reset my modem, my IP address changes. But some IP addresses that are assigned to me have some messed up routing, and so give me very high latency on some applications that I use. Whereas sometimes I’m assigned IPs that give me very optimal latency on same applications.

    I’ve been searching and searching for a script that would check my assigned IP, and if its from the pre-defined range, it will keep the modem on. If not, then it will reset the modem and do a new IP check again. And it will keep resetting the modem until I’m assigned the IP that I want, that I have pre-defined in the script.

    Can this be done?
    Thanks

  22. !!!THIS NO LONGER WORKS!!! Motorola fixed this vulnerability and most ISPs have rolled it out in early 2016. The modem still returns the same html page that states that the modem will reboot in 10 seconds, but does not. This vulnerability enabled more than just restarting. My setup is the ever-popular Motorola SB6141 that I purchased to use with Comcast. The “Reset all defaults” and “Restart Cable Modem” buttons are no longer available on the configuration page when you have the updated firmware.

Leave a Reply

Your email address will not be published. Required fields are marked *

*