• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 974
  • Last Modified:

Applet to Prevent VPN Timeouts

I have a couple clients with whom I have VPN accounts where the VPN servers are configured with short timeout periods.  (5 minutes, I believe.)  If I'm using VPN, and I hop over to a local application even for a brief period of time, I get a timeout.  To reestablish my work on the client server, I typically have to logon via VPN and then logon via RD as well.  It's a pain.  Is there a little applet out there (or even a BAT script, VBS script, or a VB.NET piece of code) that would maintain a minimal level of activity through the VPN tunnel that would prevent these timeouts?
0
jdana
Asked:
jdana
  • 2
  • 2
1 Solution
 
purplepomegraniteCommented:
It would be very easy to write a script to ping the server at intervals (this is usually enough to keep a connection alive).  Or you could just:

ping (server) -l 1 -t

where (server) is the IP address of a server the other side of the VPN.  The above from a command prompt, and it just pings with one byte of data (the l parameter can be adjusted if this is not enough).

BUT... you say it times out, are you actively disconnected, or does the VPN simply stop working?  If you exceed the Windows idle time, the server will disconnect the VPN.  If the connection just goes dead (but looks like it is connected), then there is likely to be another issue.
0
 
jdanaAuthor Commented:
purplepomegranite (nice name),

It is a timeout (as opposed to VPN stopping).  

ping (server) -l 1 -t seems pretty good.  Any idea how to call it from a vbs script?  (I'd like to drop it in a loop to slow it down a bit.)
0
 
purplepomegraniteCommented:
The attached code will ping until the first unsuccessful ping (or you stop the script with <CTRL><C>).  Just change the parts I've commented.  It outputs the result to the command window.
Option Explicit
dim blnPinged, strHost
strHost="www.google.com"  ' Change the address to where you want to ping
blnPinged=true
 
while blnPinged ' Loop while ping is successful
	blnPinged=Ping(strHost)
	if blnPinged then
		wscript.echo "Pinged " & strHost & " successfully at " & Now
		WScript.Sleep 1000 ' 1000 is one second, adjust accordingly
	else
		wscript.echo "Ping failed to " & strHost & " at " & Now
	end if
wend
 
 
Function Ping(strHost)
	dim objPing, objRetStatus
	set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
	("select * from Win32_PingStatus where address = '" & strHost & "'")
 
	for each objRetStatus in objPing
		if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode<>0 then
			Ping = False
		else
			Ping = True
		end if
	next
End Function

Open in new window

0
 
jdanaAuthor Commented:
Awesome!  Thanks!
0

Featured Post

 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now