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
428 views 2 comments
by anonymous

I have an RUTX11 with the following configuration:

  • Primary WAN on Ethernet with Failover, flush on connected
  • Backup WAN on LTE modem with Failover, flush on disconnected
  • OpenVPN configured via external services (Nord VPN)
The Failover works exactly as intended, but the problem is that when switching connections, OpenVPN does not re-negotiate the VPN connection and I get no internet access through to the LAN until I manually turn OpenVPN on and off or restart the service.
Via the command line I can restart the service:
service openvpn restart
Is there a way to configure this command to run whenever a failover happens?

1 Answer

0 votes
by anonymous

Hello,

   

To achieve this, a custom script could be used to check weather OpenVPN is connected or not:

#!/bin/sh

if ubus call vuci.services.openvpn openvpn_status | grep -q 'ipaddress'; then
        logger "OpenVPN is connected"
else
        logger "OpenVPN is disconnected, restarting..."
        /etc/init.d/openvpn restart
fi

For this example, this script can be placed in /etc/check_openvpn.sh

Afterward, run a command chmod +x /etc/check_openvpn.sh to allow the file to be executed.

Then a crontab would need to be added:

* * * * * /etc/check_openvpn.sh >/dev/null 2>&1

This would run the script every minute. This crontab syntax can be altered using this crontab generator.

For editing the existing crontab file and creating a script file, the VI editor can be used. More information about it can be found here.

  

NOTE: Please keep in mind, that in the script, logs will be added every time the script runs. This can be useful for troubleshooting, however, if they are not needed, they can be omitted.

  

Let me know if any more help is needed!

Best regards,
DaumantasG

by anonymous
Runing official openwrt on a large fleet of RUT955s, switchover events (WAN, WIFIWAN, WWAN) I detect using '/etc/mwan3.user' script. No need fron cron.
by anonymous
Hello,

This indeed could be a better option. Thank you for sharing!

Best regards,
DaumantasG