-1

i am runnning multiple openvpn instances each connected to different servers let's assume there are 3 and i am using a simple php script with this command

system('openvpn config1');
system('openvpn config2');
system('openvpn config3');

the config file conatin daemon and route-nopull ,at the end i'll tun0 tun1 tun2 enabled when i want to use tun0 i use

curl_setopt($curlh, CURLOPT_INTERFACE, "tun0");

now the first problem is if there was some problem with the interface,curl timeout won't work ! it will hang for there forever until i abort it mannually

and the second problem is even openvpn won't kill the interface if the connection failed for some reason,how can i check if the connection is alive all the time (keepalive 10 60 didn't do the trick,i don't know why)

i am not an expert in openvpn,and they don't have a lot of informations in their manual so how can i make sure all the time that the connection on a specific interface is working,and if it is not i wan't to kill that openvpn instance,and what is the solution for the curl timeout when using CURLOPT_INTERFACE

stuck
  • 1
  • 1

2 Answers2

0

The easiest way I can think of is checking the link status. For example:

$ ip link show tun0
11: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500
link/none

In the event it is active, you will see UP in those <>. You can also check that there are active routes associated with the interface. No active routes would mean the interface would go unused.

$ ip ro show dev tun0
default via x.x.x.x dev tun0  scope link  metric 1

The most correct way is to enable the management interface on the openvpn daemon and ask it the link status directly and read any errors. The documentation for the management interface is out on the openvpn site.

As far as the curl timeout, I don't know why it would do that. You may want to open a defect for it with PHP if it is reproducible with the most recent version.

Andrew Domaszek
  • 5,163
  • 1
  • 15
  • 27
-1
ping -c  1 whoami.ultradns.net

Returns your IP address (of your client). So very easy to see if your VPN is active / what VPN server you are connected via e.g in a Foreign country.

No config required.

social
  • 111
  • 3