Solving My DSL and Router Problem
The DSL in my area is plagued with a few problems. One such problem disconnects the router from the Internet once or twice a week, requiring a full reboot of the router to cure the problem.
Normally, this isn’t an issue. I recognize that my connection to the Internet has been severed, walk over to the router, unplug it for 10–30 seconds, and then plug it back in. The router boots and dutifully reconnects to the Internet. If I’m near a computer, I can use the router’s web interface to accomplish the same goal, because it has a reboot function built in.
However, what about times when I’m not physically near the router, but need it reset? If I’m lucky, a family member is nearby and a phone call can fix the problem: "Can you go unplug the DSL router and plug it back in after about 10 seconds?"
The worst-case scenario is when I’m at a remote location, I need access to the home network, the router has been disconnected, and no one is at home.
To fix this problem, I had originally looked at remote power switches—the type that can be hooked up to a phone line or serial port and used to cycle power to connected devices. Then a simple phone call or serial signal could be used to cycle the router’s power and reset the connection. However, these devices had several drawbacks:
- They’re a little hard to find—they aren’t carried by the standard Radio Shack–like store, and are available only from specialty online merchants.
- The phone-connected switch requires a dedicated phone line for operation, because it answers each call in search of commands to execute.
- The devices can be pretty pricey, ranging from $100–300 depending on the number of power connections and access methods. (The really expensive switches connect to your LAN and can be controlled through a web interface or special signal via their IP address.)
It didn’t take long to rule out such devices.
I then realized that I could probably write a script that, when the Internet connectivity was disrupted, could "talk" to the router and use the web interface’s reboot command to reset the router. Such a script could also be used to control other devices on my LAN that used similar web interfaces.
The only problem was the HTTP-Auth. How would the script handle getting through the authentication process? Although it seems simple enough (pass the credentials!), in practice it’s a bit more complex and requires an understanding of how HTTP-Auth works and which side—server or client—is responsible for what piece.