Lately, I have been having issues with my landline internet connection. My internet was being cut off multiple times a day for short periods of time. Unfortunately for me, this caused some kind of unexpected glitch in my router and it was struggling to keep up with the interruptions. So, every time there was a cut-off, I had to go and restart the router to be able to connect to the Internet. This quickly became super annoying and I decided to reuse an old Chromebook I had sitting in my basement as a middleman to restart my router when the internet becomes unavailable.
Rebooting is a common technique that’s used to try and fix issues in lots of technologies. You have likely reboot your computer, television, tablet or phone before. Hopefully, when you did this, your problem was solved. Although it seems simple, disconnecting and reconnecting a technology from a power source can fix many common issues.
When you shut down your router, everything shuts down. The software inside the router that helps it run properly also temporarily shuts down if the router does not have power. When the system is temporarily shut down, the software remains unchanged. When you turn on your router again, the same software will run, but it should be running more effectively. Let me start explaining the steps that automated this rebooting process and spared me a few hundred button presses a month.
As the first thing, I decided to install a lightweight Linux distro on the chromebook, since it was super slow and unusable. After a quick research, I installed Linux Lite and removed the pre-installed Windows 7. This helped the computer breathe again and was ready to run my scripts.
Secondly, I connected the computer to the router via an ethernet cable, to provide instant access to internet and allow computer to access the router control panel. My router is a TP-LINK Archer C3200 and it allows Telnet access to perform some administrative actions on the device itself such as reboot, etc. Now that everything was ready, I could start writing the script that would reboot my router when there is an internet connection issue. Of course, not all interruptions require a router reboot, so being able to ping a fixed IP address gives the script the flexibility to decide if the connection is restored after a brief interruption and avoid the device reboot.
Here is the script that I wrote that runs on the computer. It takes in a few input arguments:
sudo bash router-controller.sh
HOST: 192.168.0.1
USERNAME: Router_control_panel_username_here
PASSWORD: Router_control_panel_password_here
Router controller is listening...
After making sure all the cables are connected, I tested it by unplugging the ethernet cable between the router and the modem to simulate a network outage. This simulation proved that the script is able to detect an internet outage in about 30 seconds and reboots the router until the internet connection is restored. Finally, now we have an automated way of restarting our router without manually pressing a button. This is especially useful if you are away for a vacation and a glitch happens on your home network. I've personally experienced this before where I could not access my security system due to an internet cut-off issue and had no way of rebooting the device to restore my internet access. Hope this post helps someone and brings more stability to your home network.
Here is the link to the source code: https://github.com/herrberk/router-resetter
Feel free to play around with the source code, contribute and tweak it to your liking to make sure it works with your setup. Please comment below any questions you might have, your experience with router glitches and let me know how it went. Happy coding!
Disqus Comments Loading..