After several years of dealing with problematic cable modems, I’ve finally gotten tired of having to power cycle my equipment just to restore our internet access. I’ve been through a few different modems over the years, and while some models are more temperamental than others – sooner or later I’ve always had to power cycle them to restore a connection. While It never used to bother me, It has become particularly inconvenient since I started mining LiteCoins. No internet = no LiteCoins, and missing out on hours worth of mining potential while you are sleeping or at work kind of sucks. So after a bit of research, I was able to craft a simple batch file to send a reboot command to my modem when my PC cannot reach the internet! I should of done this years ago 🙂
Since this post only covers one specific model, make sure to log in to your modem to verify your model number before you begin. Most cable modems you encounter can be accessed via their default IP address @ http://192.168.100.1/. Fortunately the DPC2100R2 modem is very popular, so chances are that if you were issued a modem from Time Warner Cable or Comcast you have a similar version. In any case, once you have verified your model number – You can click through the below sections that I have outlined step-by-step!
- A Windows machine that is always on.
- Your PC must be on a different sub-net than your modem.
(Example: Modem = 192.168.100.1 / Router = 192.168.1.1)
- When your modem is in a downed state, it must be responsive to remote commands
- Your Modem must be at fault for your connection issues and not your router.
Verify your Modems Frequency
Access your modem via: http://192.168.100.1/gscan.asp, And take note of your devices starting frequency. You should see a screen similar to below…
***Take note of your frequency, you will need it when creating your batch file in Step 3.[/learn_more][learn_more caption=”Step 2 – Download Curl For Windows”]
Download Curl For Windows
1.) Go to the Curl Download Wizard Page to download the appropriate .zip version of curl for your system.
2.) Create a Folder called “Curl” in the root of your C: drive.
3.) Then Extract the contents of the .zip folder to C:\Curl
[/learn_more][learn_more caption=”Step 3 – Create Your Batch File”]
Create Your Batch File
1.) Create a text file called RebootModem.txt
2.) Copy the following code into your text file, making sure to replace the starting frequency value for your own.
REM This Script will Ping 3 Major Sites, If it can not connect it will
REM initiate the reboot command via curl.
REM ping has an errorlevel output value. Success is 0, failure is 1
IF %ERRORLEVEL%==1 (
) Else goto done
IF %ERRORLEVEL%==1 (
) Else goto done
IF %ERRORLEVEL%==1 (
C:\curl\curl.exe http://192.168.100.1/goform/gscan -d SADownStartingFrequency=693000000
date /t >> LastReboot.txt
time /t >> LastReboot.txt
REM Thanks Anon for showing me how to setup this log file!
echo Awesome - looks like the internet is up!
3.) Rename your text file to RebootModem.bat
I’ve also noticed that when certain applications crash, I have to restart my LAN connection or my PC. If you are experiencing a similar issue – Try adding the following lines in your batch file:
netsh interface set interface "Local Area Connection" DISABLED
netsh interface set interface "Local Area Connection" Enabled
Now would also be a good time to do some preliminary testing with your .bat file & the reboot curl command. We want to make sure everything is working as expected before we move on to configuring the .bat file to run in Windows Task Scheduler.
A special thanks to peramikic @ Superuser.com for sharing the curl modem reboot code!
[/learn_more][learn_more caption=”Step 4 – Configure Task Scheduler”]
Configure Task Scheduler
1.) Browse to:
Control Panel > System & Security > Administrative Tools > Schedule Tasks
2.) Action > Create Task
3.) When you are creating the task, it is important to change the user to SYSTEM. This way it will run the batch file in the background and you won’t get an annoying command prompt window popping up every 10 minutes 😀
4.) Under the triggers tab, you are going to set how often the batch file is run.
(Personally I run the command every 10 minutes.)
5.) Finally, Under the action tab you are going to point your task to the batch file you created. You should be fine leaving the rest of the settings at their default values, but feel free to poke around and change anything else to your liking.[/learn_more][learn_more caption=”Bonus!!”]
Rebooting Your Router
Since I didn’t have any luck finding the reboot command that was required for my stock linksys router firmware, I flashed it with Tomato. Installing this 3rd party firmware gives us the ability to easily issue SSH commands to the router to send our reboot command.
1.) Upgrade your routers firmware to DD-wrt -or- Tomato.
2.) Enable SSH on your router.
3.) Download both Putty & Plink.
4.) We will first test our connection to the router with Putty, and in doing so we will also be able to accept the certificate being issued from our router to connect via putty. To connect in Putty, Open Putty – Enter your routers IP address, and then login using your routers username/password.
5.) Once connected you can then go about adding a reboot command via SSH & Plink in the batch file we created earlier.
C:\mining\Plink\plink -v -ssh -batch firstname.lastname@example.org -pw MyPasswordhere "reboot"
I admit that this is probably a bit extreme for most users, and honestly your upgraded firmware should be pretty solid and not require frequent reboots. BUT – It is nice knowing that you have the option 🙂
[/learn_more][learn_more caption=”Additional Resources”]
While the above batch file works great for me and my modem, there are many different variations of hardware loose in the wild. If you are having problems getting your reboot command to work – You may need to elevate your access level. If that doesn’t work for you, I’ve listed a few different articles below that tackle the problem in a slightly different way.
If anyone is able to improve the batch file above with the ability to log when the reboot command was issued – I would be super grateful if you posted the code in the comments section below 🙂