1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Keeping active connection - Autoping script help

Discussion in 'Tomato Firmware' started by lindstroem, Nov 16, 2009.

  1. lindstroem

    lindstroem Addicted to LI Member

    Hello,
    I recently bought a WRT54GL to replace my old cheap Dlink router.
    But after the replacement I now face a problem. My internet connection is based on a html-login-site which is not PPPOE.

    I get my IP adress automatically though DHCP and am directed to a html adress to log in. This works fine with the router who just directs me to the loginpage. But, the internet connection disconnects fast due to innactivity (about 10 minutes) and if im not using the computer and having MSN or any other program activated, I get logged out.

    The weird thing is that with my D-link router I never faced this problem. As I am unable to use the "Keep alive"-function with the DHCP option, I am unable to keep a constant internet traffic with my router (to my knowledge).

    So my only possible sollution to the problem would be to create a ping-script that automaticly pings a internet-site every 5 minutes, just to keep using the internet.

    I have no idea to accomplish this, and this is the sole purpose of why I've created a user account here. The Tech-support did not offer any help.

    Please see this as a challenge and try to help me =)

    Any solutions/suggestions/questions are welcomed.

    Thankyou
    //Peter
     
  2. Planiwa

    Planiwa LI Guru Member

    There may be other ways to solve the problem.

    But to do what you imagine -- periodically generating minimal network traffic via ping -- Tomato offers:

    Administration > Scheduler ... run this every 5 minutes:

    Code:
    ping -q -c1 4.2.2.2 >/dev/null 2>&1
    
    Don't forget to click on the [SAVE] button.

    No need to restart your router!
     
  3. lindstroem

    lindstroem Addicted to LI Member

    Thank you for your reply,
    Not sure how to interpret "The tomato-way seems to be ..." :)
    Do you mean that the ping way is the easiest most effective or that there is a better solution?

    And by "your.isphost", do you mean the loginpage that I am refered to?

    Thank you again.

    EDIT: I entered >>>ping -q -c1 https://netlogon.student.uu.se >/dev/null 2>&1<<< in the router schedule now. I will shut down all internet traffic in a while and test ^^
     
  4. Planiwa

    Planiwa LI Guru Member

    Hm. DON'T DO THAT! Let me edit my message to make it more robust.
     
  5. lindstroem

    lindstroem Addicted to LI Member

    Yes almost figured as much :) I tried at didnt work,
    I will try your edited message and let you know again
     
  6. lindstroem

    lindstroem Addicted to LI Member

    Its unfortionatly still not working, even when I changed the interval to every 3 minutes. Other suggestions would be deeply appriciated =)
     
  7. Planiwa

    Planiwa LI Guru Member

    So, perhaps the pinging isn't happening, or perhaps the pinging isn't what is needed? :)

    Your mention of a web page and logging in and a university student netlogon page at that, suggests to me that there may be something different involved than mere traffic.

    You need to find out what is actually required to maintain "active" status.

    Perhaps things are set up as they are to defeat simplistic attempts to defeat the setup? :)
     
  8. lindstroem

    lindstroem Addicted to LI Member

    Hehe you have a point there, but simply having MSN Messenger running in the background is enough.

    And the fact that a 20$ router from Dlink was able to maintain the connection ^^

    You are sure that the ping order you wrote is correct and that a script may not be able to do it better? or another command?
     
  9. Planiwa

    Planiwa LI Guru Member

    Hm. I always run commands interactively before casting them in "NVRAM-stone".

    You could do this:

    logger "$(ping -c1 4.2.2.2)"

    Then you can check in the log to see the ping invocation and results.
     
  10. lindstroem

    lindstroem Addicted to LI Member

    Thank you for your responses, should i include that after the first command in the schedule? Pardon my inexperience.

    I've done so now for the time being .Also activated logger for schedule

    Seems to be doing its job...
     
  11. kenyloveg

    kenyloveg LI Guru Member

    what happens if the target site block ping requests?
    Or alternative way is to resolve sites via DNS port, would it be more stable?
     
  12. Toastman

    Toastman Super Moderator Staff Member Member

    Should it matter, even if the remote site does not reply to pings?
     
  13. lindstroem

    lindstroem Addicted to LI Member

    Thanks for the involvement guys.

    Well I belive that the main thing is to show internet activity really (as it can be proven that MSN is sufficient to maintain an active connection).

    I am unexperienced with Tomato and coding, as I've expressed before so if you come with tips/recommendations; please also include instructions on how to implement them :)

    I thought could be that 56b of data every 3 minutes is not sufficient as "internet activity". So could a solution be to either increase the packet size (which however may be a limit from the recieving end) or increase the number of pings executed every interval?

    For an example, 10 pings => 0,56kb data instead of 0,056kb.

    If this could be a possible solution, how do I change to code?
    Was a basic attempt on my side but is wrong according to the log file ^^

    EDIT: Changed the interval to once every minute with the same original code (with the correct -c1) and it now seems to be able to maintain the connection on its own. Will do further testing in a while and let you know.
     
  14. Planiwa

    Planiwa LI Guru Member

    Code:
    ping -c10 -s100 4.2.2.2
    will send (and receive) ~ 1kB in 9 seconds

    Code:
    ping -c2 -s500  4.2.2.2
    will do about the same, in 1s.

    -s size
    -c count

    (many hosts will not reply to requests that are "too" large, so I would not recommend much larger than 1kB).
     
  15. lindstroem

    lindstroem Addicted to LI Member

    SOLUTION 1:
    Turn the setting that allow the Router's firewall to recieve ICMP signals ON (this is off default). (Advanced > Firewall).
    This also solved the problem (possibly at the expense of a slightly less secure FW).

    SOLUTION 2:
    Access the schedule function (Administration > Scheduler)
    Using Ping formula (supplied by Planiwa) in scheduler: ping -q -c1 4.2.2.2 >/dev/null 2>&1
    Interval: Once every minute

    To temporarily control router actions, you can add the function: With log function: logger "$(ping -c1 4.2.2.2)"
    This will create a log over each ping event. It is not recommended to keep log function after testing because of RAM-usage.

    That apparently created sufficient internet traffic for the ISP to detect activity.


    Thank you again for the help with this matter, especially Planiwa =)
     
  16. Planiwa

    Planiwa LI Guru Member

    Thanks for the follow-up. Glad to see it's working. :)

    Some comments:

    1. I like to use 4.2.2.2 for (interactive) testing because it is easy to type, has high availability, does not depend on DNS resolution, etc.

    But for an automated ISP-specific setup I would recommend a local host, such as www.uu.se or google.se


    2. If making the router pingable is all that it maintain the connection to the ISP, that would definitely be my choice. (Advanced > Firewall).

    Be aware that the Scheduler will fire up 3 processes each time it runs, and will then use up more than 300k of RAM. This may destabilize a system that is running low on RAM.

    3. Logging the ping traffic is not necessary for it to work. It is only helpful to see that it is actually working. Useful for testing, but I wouln't want others to think it's part of the solution. Occam would have scratched his beard trying to figure out the point of such gratuitous complexity (and log pollution). :)
     
  17. lindstroem

    lindstroem Addicted to LI Member

    I changed the order of the solutions and added further guidance in accordance with your additions :)
     

Share This Page