Software Secret Weapons™  
Linksys Router Reanimator Or Smoke And Mirrors Of Enterprise Reliability posted by Pavel Simakov on 2007-05-07 16:14:56 under Smoke & Mirrors
view comments
 


The problem

I am a proud owner of Linksys WRT54G router. Under $100, it's a great simple device that is used all over the place for home and office networking. Basic firewall features, wireless support, port forwarding – all you really need in one small package. When I travel or attend a customer site, I frequently need a remote access back to my home computer. For this purpose I keep the router always connected to the Internet, even there is not traffic going through. This can be done by enabling "Keep Alive" option under Setup tab.

However, the "Keep Alive" doesn't quite work if the Internet provider (the phone company in my case) has a temporary outage. During the outage router tries to reconnect couple of times and gives up. So when the phone company finally restores the connectivity, the router doesn't reconnect. And poor me, I can't connect to my home computer to get the files out of it.

The solution

To fully automate and improve the reconnect process I wrote a small program in Java. This program runs on one of the computers on local network. It periodically logs into the router via web admin interface, as a human would, and checks the router connection status. If router is "disconnected" the program "clicks" connect button. The whole cycle repeats every couple of minutes.

After a quick inspection of the HTML source for the router status page

    http://192.168.1.1/Status_Router.asp
I have discovered that one can force the 'connect' and the 'disconnect' commands with these GET requests (remove line breaks before using):


    http://192.168.1.1/apply.cgi
        ?change_action=gozila_cgi
        &submit_button=Status_Router
        &wan_proto=pppoe
        &submit_type=Connect_pppoe

    http://192.168.1.1/apply.cgi
        ?change_action=gozila_cgi
        &submit_button=Status_Router
        &wan_proto=pppoe
        &submit_type=Disconnect_pppoe

The Java source for LinksysRouterReanimator class is here. This is how it works:

  • get HTML source for the router status page
  • determine router state by looking at the words 'var status2 = "Connected";' or 'var status2 = "Disconnected";'
  • issue "connect" command in the disconnected state
  • sleep for a bit
  • repeat the whole thing

Use the following command line to run LinksysRouterReanimator (just provide the user name and password):


    java -Dhost="192.168.1.1" -Dname="bob" -Dpass="bob123" -Dperiod="300" LinksysRouterReanimator.class

When it runs it produces the following output:


    ?+?+?+?+?+?-S?+?+?+?+?x?x?x?+?+?+?+?+?+?+

The ? indicates that status was checked, + indicates that router was in the connected state, - indicates that router was in the disconnected stats, S indicates that "connect" command was sent to the router, and x indicates that router state was unknown (aka. Connecting...).

Finally, I can safely go to my friends and watch a movie streamed right from my home computer over the Internet. Any intermittent outage is immediately restored by my own LinksysRouterReanimator. God bless I know Java… Otherwise I had to hire a full time system administrator to push the reset button on the router.

Comments (3)

  • Comment by chris — August 29, 2007 @ 10:53 am

    Does it matter that ‘gozilla’ is spelt wrongly in the command?
    - Chris

  • Comment by Pavel Simakov — August 29, 2007 @ 11:23 am

    The action name “gozila_cgi” is expected by the router and must not be changed. I have no idea why it’s spelled this way. Maybe it’s a result of outsourcing the software development to some country in Asia…

    - Pavel Simakov

  • Comment by ycc — January 30, 2008 @ 8:39 am

    Thanks a million. I have the same router and the same problem. I put your GET-requests in curl-argument and will not have to get up in the night to check router status any more :)


Leave a comment


  Copyright © 2004-2007 by Pavel Simakov SourceForge.net Logo