Hello MikroTik Community,
I’ve developed a failover script for PPPoE connections that uses detect-internet, but I’m looking to enhance its reliability. Currently, the script checks if the PPPoE connection is established and uses detect-internet state, but I’ve identified a scenario where the interface shows as connected yet no traffic can pass through.
Current Script:
:local primaryState [/interface detect-internet state get [find name="pppoe0"] state]
:local backupState [/interface detect-internet state get [find name="ether2"] state]
:local powerState [/interface ethernet poe get ether2 poe-out]
# When primary WAN is down
:if ($primaryState != "internet") do={
# Check if ether2 is not powered on
:if ($powerState != "auto-on") do={
/interface ethernet poe set ether2 poe-out=auto-on
/ip firewall connection remove [ find ]
/log info "IntelliFailover: PPPoE interface (pppoe0) is DOWN"
/log info "IntelliFailover: Switching to backup (ether2) connection"
}
} else={
# When primary WAN is restored, check if both interfaces have internet
:if ($primaryState = "internet" && $backupState = "internet") do={
# Check if ether2 is powered on
:if ($powerState != "off") do={
/interface ethernet poe set ether2 poe-out=off
/ip firewall connection remove [ find ]
/log info "IntelliFailover: PPPoE interface (pppoe0) is RESTORED"
/log info "IntelliFailover: Restoring primary (pppoe0) connection"
}
}
}
Current Behavior:
[] Script uses detect-internet state to check interface status
[] Manages PoE power for backup interface (ether2)
[] Clears existing connections when switching
[] Logs failover events
Issue: While the script works well in most scenarios, there are cases where the PPPoE interface might show as having internet (via detect-internet) but actually can’t pass traffic. I’m looking to add additional verification methods to make the failover more robust.
Desired Enhancements:
- Additional connectivity checks beyond detect-internet state
- Verification of actual traffic flow through the PPPoE interface
- Potential implementation of multiple check methods before triggering failover
Questions:
- What’s the most reliable method to verify actual internet connectivity through the PPPoE interface beyond detect-internet?
- Would adding ping tests to multiple hosts ( like 1.1.1.1, 8.8.8.8 ) through the specific interface be beneficial?
- Are there any recommended timings or thresholds for these additional checks to avoid false positives?
- How can we implement these checks while maintaining the script’s current PoE management functionality?
Environment:
RouterOS version: 7.16.2
Hardware model: RB5009
Any guidance, especially regarding:
- Implementation of multiple check methods
- Best practices for timing and thresholds
- Script optimization
- Additional safeguards against false positives
Would be greatly appreciated.
Thank you in advance!