FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
749 views 4 comments
by anonymous

Hi, 

I use a Rut955 that closes a VPN with one of our servers, I’m experiencing the following problem:

When it goes away the internet connection from the route 955 the vpn falls, in order to retrieve the vpn I must necessarily disconnect and attack the vpn manually, as a solution I was thinking of using the function "ping reboot" and restart only the vpn service. 

Is it possible to restart the VPN service when it no longer pings an address? Through a Script Custom

1 Answer

0 votes
by anonymous

Hello,

It is possible to restart the VPN service when it no longer pings an address, through a script. However, it is not entirely clear, if you want to restart VPN on internet connection loss or after tunnel disconnects. A better description of the issue is needed.

The idea would be to continuously ping an address via VPN interface and, on occasion of failed pings, restart openvpn service.

For that you would need to login to router's WebUI, navigate to System -> Custom scripts section and add a similar script:

#!/bin/ash
while [ 1 ]; do   #Marks the beginning of an infinite loop to repeatedly execute commands below
        sleep 5   #A timer to wait 5 seconds, before executing following command  
        #Command below is to ping IP address over VPN tunnel and check ping status        
        ping -I <tunnel_interface> <ip_to_ping> -c 3 -q >/dev/null
        ret=$?   #$? is a special variable containing the return code of the previously run command (0 = success, else = failure)
        if [ $ret -ne 0 ]; then #If ping commands return failed status, following commands are executed
                logger "State: Disconnected"  #Creates log entry with the message 
                /etc/init.d/openvpn restart   #Restarts VPN service
        else   #If ping commands return success status, following command is executed
                logger "State: Connected"   #Creates log entry with the message 
        fi  #End of conditional statement
done #End of loop

Replace <*> accordingly.

The basic working is that every 5 seconds router sends 3 pings to the specified IP address via tunnel interface and, if no echo is received, openvpn service is restarted. It also adds log entries on the state of the VPN connection. 

Best regards,

by anonymous

Having installed the route 955 in rural areas we found connection holes , in some cases the VPN does not fall in other cases falls and you have to restart the route 955 via sms ( reboot) in order to hang up the VPN. We use OpenVPN. Could you explain the script to me or tell me where to study the script?

Thank you so much for your answer.laugh

by anonymous

I have added comments explaining each line.

However, the tunnel connection should recover on its own. 

Are you sure, that you have stable internet connectivity after disconnects occur?

Are you using mobile or wired connectivity to access internet?

If it is mobile, you could simply configure automatic modem reboots on disconnection instances to try reestablish connectivity.

Best regards,

by anonymous

I use a mobile connection.

If the connection to the tunnel is restored by itself, then the problem is not the closing of the vpn but the re-connection of the telephone sim to the internet. 

Is there any way to get confirmation that it is a problem of reconnecting mobile internt and not the vpn ?

Rebooting the modem restarts only the mobile network adapter ? do not reboot the other network interfaces ( lan wan .)?

Thanks laugh

by anonymous

Is there any way to get confirmation that it is a problem of reconnecting mobile internet and not the vpn?

For this a troubleshoot file from the device would be needed after the disconnect happens. To get the file access router's WebUI, go to System -> Administration -> Troubleshoot section and download troubleshoot file from there. The logs in the file might provide more insight into the issue. Attach it by editing your original question or by sending in a private message.

Rebooting the modem restarts only the mobile network adapter ? do not reboot the other network interfaces ( lan wan .)?

That is correct, only modem module is impacted.

Best regards,