Is it possible to write a script to avoid VPN from getting timeout
Asked Answered
S

3

10

I recently connected to VPN using Nortel client.

The problem that i faced, I borrowed RSA from somebody connected to VPN , had to leave pc idle for 30min or so and VPN timed out. So i had to wake people up and ask for keys to connect.

So I was wondering if its possible to write a script (I am familiar with Batch and javaScript ) that do not let the connection timeout? What I could think of : keep on sending inputs after a time and do not let it get idle enough to avoid the timeout period. is that a feasible approach ? if not anything better?

I have not tried anything yet, except for googling and that too with not much positive outcomes. and I do not know where to start.

I am not asking for a cooked up solutions(though if someone has it would be great , lol ) , just little guidance, the right direction? or references to some resources maybe?

I would really appreciate some guidance and not downvotes.

Studding answered 29/11, 2012 at 14:58 Comment(0)
P
9

Well, if it is a matter of timing out because idle standby, the solution is rather simple. The following pseudocode can be be implemented in many ways

repeat:
   ping once gateway_ip  
   wait n seconds

You can do this as a bash or batch script. Here's an example in bash:

while true
do
   ping -c 1 gateway_ip
   sleep 3
done

Or as a batch script:

:loop
ping -n 1 gateway_ip
ping -n 3 127.0.0.1 
goto loop
Parotitis answered 29/11, 2012 at 15:51 Comment(1)
thats working like a charm. thanks a lot , appreciate your response (y)Studding
S
6
$ ping -i 30 127.0.0.1

ping provides an interval option, so you don't even need to use a script to create a VPN stay-alive.

$ man ping   
...   
OPTIONS  
...  
    -i interval
        Wait interval seconds between sending each packet.  The default is to wait
        for one second between each packet normally, or not to wait in flood mode. 
        Only super-user may set interval to values less 0.2 seconds.
Sphacelus answered 5/7, 2016 at 13:31 Comment(0)
M
2

Many VPN clients do have keep-alive settings, and you could artificially generate traffic on your end to achieve a similar effect, but many times, timeouts are not under your control, as they're caused by something "out there" that temporarily causes packet drops or other forms of extensive delays.

The better answer is probably "don't borrow someone elses keys/passphrase - get your own, so you can reconnect any time you need to".

Micrography answered 29/11, 2012 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.