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…
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:
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.