Verizon FIOS is great — the speeds are incredible, and the price is… well, kinda expensive. The real problem is that the terrible router they give you needs to be rebooted all the time, which is a royal pain considering it’s down in the basement. Plus, I don’t want to get off the couch.
So I contemplated how I could solve this problem using technology. That’s what geeks do, right?
Yeah, I know, I could probably call Verizon and upgrade the router, I’m sure they have a better model now. And sure, you can update the firmware, but that won’t work for my old router since there isn’t an update. Time for an easier solution that ideally involves a cron job. Cron jobs are always a good decision.
After three minutes of research and brainstorming, a solution presented itself: You can enable telnet on the router, setup a script that automatically runs a series of commands using the telnet interface, and then schedule that script with a cron job to run on a regular basis. For me, that meant every morning at 7am, an hour before I wake up, and again at 5:30pm, since I’m always out of the house at that point. Problem solved, and I can use Vim, which also makes me happy.
And of course, you can make a script to run on demand to immediately reboot the router whenever you want.
Note: you can probably do the same thing with a router that isn’t Verizon. You’ll need to check your router administration panel and see how the options work on there.
Connecting to Your Router via Telnet
The first thing you’ll want to do is figure out how to enable telnet on the router. For the Verizon router, that required going into Advanced -> Local Administration and making sure “Using Primary Telnet Port” is enabled. Make sure to click Apply.
At this point you can easily use telnet from the terminal or command prompt to connect to the router. If you’re using Windows, you’ll probably have to enable telnet. To connect, just type this, substituting the IP address for your own router’s IP if necessary (though most are set to use the 192 range)
Once you’re in there, you can usually type the help command to see what the options are. For Verizon FIOS, the option I was looking for was in the system sub-section, and was aptly titled “reboot.” You have to actually type “system reboot” and not just “reboot” though.
Once you type the command at the prompt, you’ll be disconnected, and the router will be rebooted. Easy, yes. But who wants to do all that typing every time?
Scripting Telnet through the Terminal (OS X or Linux or Cygwin on Windows)
We’re going to assume you have access to the bash shell, whether that’s in your normal OS, or if your OS (Windows) doesn’t have bash, you might have to install Cygwin.
It’s surprisingly easy to script a set of command and pipe them into the telnet application. All you need to do is something like this:
The only problem is the nagging login that you have to get through… it doesn’t show up right away. So if you pipe in an “echo admin” and then “echo password,” it will happen too quickly and won’t be sent to the server. The solution? Use the sleep command!
Adding in a couple of sleep 3 commands, to wait three seconds, solves the problem. First we’ll echo the username and password, and then we’ll echo the reboot command, and each time we’ll wait three seconds between. The final command will reboot the server immediately:
You can put this into a shell script and run it whenever you want. Or you can add it to your cron like this (on OS X or Linux):
Add this line somewhere:
This will reboot your router at 7:01 AM each morning.
Rebooting the Router the Windows Way
If you’re running Windows, it’s a lot more complicated to schedule this automatically, but we can definitely script it out easily enough. First you’re going to need to go into Control Panel, get to the “Turn Windows features on or off” panel (just search for it), and then enable the Telnet Client.
Now you can paste the following into Notepad, but change out the router IP if necessary, and change the mypassword line to be your actual password instead. You may need to edit the script for different commands.
Save it out as a .vbs extension, and then you can double-click on it any time you want to reboot the router.
Scheduling in Windows with a Scheduled Task
Open up the Task Scheduler and create a new Basic Task, giving it a name and a schedule — daily at a certain time would work. Then use the Start a Program option and browse to the script file that you’ve created.
That’s pretty much all you have to do.
Note: the instructions in this article are specific to Verizon FIOS but you can probably do this with any router. Please let us know in the comments if you get it to work with another router and we’ll update the article to reflect it.