Jump to content
TorGuard
  • 0
Sign in to follow this  
PeterR

Best way to test VPN status from command-line?

Rate this question

Question

PeterR

My question has two parts:

 

1) Are there any conditions you can think of where pinging 10.8.0.1 would NOT determine if the VPN is UP? If so, please explain...

 

2) Is there an easier/better way I have not found yet? Like maybe to ask OpenVPN directly from the command line? If so please share that tidbit of info...

 

Background:

 

To date, I have been doing this by using wget to query a webserver to see what my public IP address is. For example:

 

wget http://mypiracy.net/ -O SomeFileName.html

 

Note: while the above example is a working method, it still requires that you parse the SomeFileName.html to get the IP address. Personally I am to lazy for that, so I wrote a simple php page, lets call it... IP_ADDR.php, that returns nothing expect the client`s IP.

 

?= $_SERVER[`REMOTE_ADDR`] ?

 

so what I actually do is more like

wget http://mysite.net/IP_ADDR.php -O ipaddr.txt
IP_ADDR=`cat ipaddr.txt` 

 

Which seemed easier than trying to parse the content from the mypiracy.net`s page for the IP. Forgive me for NOT sharing that URL with the world... although, it might be useful if torguard hosted something like that for all to use...just a thought guys;-)

 

That said, the above method overall is testing a bit more than if the VPN is connected. While that is not all bad, I was wondering if there is more direct method or a way to ask OpenVPN directly. It seems to me that another, somewhat more direct method might be to ping the private subnet gateway. For example, something like:

VPN_STATUS=0
if ping -W 2 -c 1 10.8.0.1 ; then 
VPN_STATUS=1  
fi 

 

Thanks

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Support

Hi Peter

 

Just out of curiosity do you use mainly UDP based connections ?

 

Regards

Share this post


Link to post
Share on other sites
  • 0
PeterR

fyi @ all

 

Yesterday I had some connection issues as a result of the certificate update on the CA servers. While that was happening, I had varying levels of connectivity where I was connected, then not, then connected but with a bad tls handshake and so on.

 

While none of the logic I scripted on my router yet depends on it, I have been logging the results. Using

 

VPN_STATUS=0

if ping -W 2 -c 1 10.8.0.1 ; then

VPN_STATUS=1

fi

 

as a simple means of checking if the VPN is up, worked perfectly in all states of connection. That is to say it always reported the truth...-;)

Share this post


Link to post
Share on other sites
  • 0
Support

Hi Peter

 

Thats good to hear, i was just curious as i did create a small script to check openvpn UDP (run via cron) to expect a certain reply upon each check which is very accurate at keeping tabs on openvpn.

 

Sometimes openvpn can run and go stale but will still report thats its running.

 

Regards

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...