0

I need to check the vpn connection when is online/up with a batch file.

Actually i use this code:

PING -n 5 www.google.com|FIND /I "TTL">NUL

IF NOT "%ERRORLEVEL%"=="1" (
Echo "Vpn Connection Is Up"
)
IF "%ERRORLEVEL%"=="1" (
Echo "Vpn Connection Is Down"
)

Sometimes the ping give a non response or give a general failure response.

I would like to know that there is a better batch code alternative than the ping command.

I tried this alternative codes but do not recognize vpn when is online/up because the adapter is always in my pc installed.

First Alternative Code:

ipconfig|find /i "VPN" && GOTO startAPP || GOTO connectVPN

Second Alternative Code:

ipconfig|find /i "VPN"

if %errorlevle%==1 goto:connectVPN

echo Starting APP !
exit/b

:connectVPN
echo connecting to VPN

Third Alternative Code:

:start
cls
rasdial | find /I "%vpnname%" > nul
if errorlevel 1 goto vpndown
if errorlevel 0 goto vpnup

Can You recommend an alternative command to ping to be integrated into my batch code please ?

The alternatives code do not recognize when vpn connection is online, it's recognize if exist the adampter installed in my pc but i need to know when vpn is online/up (ready to go on internet).

1 Answer 1

0

You can look at this file: /etc/openvpn/openvpn-status.log

I would also try looking at the output of ifconfig and checking if the adapter exists and is up or down.

3
  • I don't find this file "/etc/openvpn/openvpn-status.log" in my openvpn i do not see this folder. I use openvpn 2.4.6-I602. thanks
    – camomillo
    Commented Feb 20, 2019 at 1:17
  • Do you have a different log file in that folder? You can also check your global log files (i.e. grep VPN /var/log/syslog)
    – Andy
    Commented Feb 20, 2019 at 4:07
  • Every vpn ip have a log, i do not find a global log file. i use more vpn ip.
    – camomillo
    Commented Feb 20, 2019 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .