This script helps ensure your MikroTik router's OpenVPN connection remains stable by checking the interface status directly, without relying on ICMP ping. If the OpenVPN interface is not running, it w
This script scans all OpenVPN client interfaces and checks their connection status. If any interface is not running, it will be disabled and re-enabled automatically.
Script setup
you can choose to use basic script or the one with telegram notification
⚙️Basic Script (No Notifications)
# --- Loop through all OpenVPN client interfaces ---
:foreach id in=[/interface ovpn-client find] do={
:local isRunning [/interface ovpn-client get $id running]
:if ($isRunning = false) do={
:local ifaceName [/interface ovpn-client get $id name]
/log warning "$ifaceName is not running. Restarting..."
/interface ovpn-client disable $id
:delay 2s
/interface ovpn-client enable $id
:delay 5s
}
}
🛠️ This script works automatically for all OpenVPN client interfaces on your router.
💡With Telegram Notification
This version adds Telegram notifications whenever an OpenVPN client interface is restarted.
🔧 Configuration
Replace the botToken and telegramId with your own values from your Telegram Bot: