Hi
In our office, we have now USB LTE dongle (Huawei E3372h-153 LTE - HiLink) which works great with RB2011UiAS-2HnD-IN.
So: RB2011 is connected via ETHER1 to VDSL2 modem which is in bridge mode. RB2011 act as PPPOE Client.
Now, I configured LTE modem as usual. So, I added DHCP Client and did NAT on lte1 Interface. Everything works great.
Normally, lte1 interface is disabled. When I enable it, I don't need to switch off pppoe-out1 interface, because RB2011 is automatically giving lte1 interface route distance 0 and pppoe-out1 is always at route distance 1. So, when I'm enabling lte1 interface - all office works on lte connection. When I disable it, all office works on normal VDSL2 connection. It think this is the reason why it's working this way.
Now, I wanted to do a Failover thing, so in case my main VDSL2 connection is dead, RB2011 will switch on lte1 interface and voilla, I now have lte Internet in the office.
So this is my script:
# Following script is copied from the Mikrotik forum.
# Thanks to mainTAP and rextended for sharing
# http://forum.mikrotik.com/t/internet-connectivity-monitor-script-requierd-solved/77607/1
# Modified few contents to suite local requirements and added descriptions
# Regard's / Syed Jahanzaib / https://aacable.wordpress.com
# Script Starts here...
# Internet Host to be checked You can modify them as per required, JZ
:local host1 "8.8.8.8"
:local host2 "8.8.4.4"
# Do not modify data below without proper understanding.
:local i 0;
:local F 0;
:local date;
:local time;
:global InternetStatus;
:global InternetLastChange;
# PING each host 5 times
:for i from=1 to=5 do={
if ([/ping $host1 count=1]=0) do={:set F ($F + 1)}
if ([/ping $host2 count=1]=0) do={:set F ($F + 1)}
:delay 1;
};
# If both links are down and all replies are timedout, then link is considered down
:if (($F=10)) do={
:if (($InternetStatus="UP")) do={
:log error "WARNING : The INTERNET link seems to be DOWN. Please Check";
:set InternetStatus "DOWN";
## ADD YOUR RULES HERE, LIKE ROUTE CHANGE OR WHAT EVER IS REQUIRED, Example is below ...
/interface enable lte1
## /ip route set [find comment="Default Route"] distance=3
## /ip firewall nat disable [find comment="Your Rules, Example"]
:set date [/system clock get date];
:set time [/system clock get time];
:set InternetLastChange ($time . " " . $date);
} else={:set InternetStatus "DOWN";}
} else={
## If reply is received , then consider the Link is UP
:if (($InternetStatus="DOWN")) do={
:log warning "WARNING :The INTERNET link have been restored";
:set InternetStatus "UP";
## ADD YOUR RULES HERE, LIKE ROUTE CHANGE OR WHAT EVER IS REQUIRED, Example is below ...
/interface disable lte1
## /ip route set [find comment="Default Route"] distance=1
## /ip firewall nat enable [find comment="Your Rules, Example"]
:set date [/system clock get date];
:set time [/system clock get time];
:set InternetLastChange ($time . " " . $date);
} else={:set InternetStatus "UP";}
}
# Script Ends Here.
# Thank you
So, this script half works - actually with this settings inside - it creates a loop. When main connection is down, it enables LTE1 interface - which is fine - and backup link works fine. But after let's say 5 minutes (let's assume script execute every 5 mins) when script in executing again, it's disabling LTE1 interface and it's falling back to VDSL2 connection (which is DEAD) because it can ping host with LTE1 interface.
Of course, I can edit the script here:
## If reply is received , then consider the Link is UP
:if (($InternetStatus="DOWN")) do={
:log warning "WARNING :The INTERNET link have been restored";
:set InternetStatus "UP";
## ADD YOUR RULES HERE, LIKE ROUTE CHANGE OR WHAT EVER IS REQUIRED, Example is below ...
/interface disable lte1
## /ip route set [find comment="Default Route"] distance=1
## /ip firewall nat enable [find comment="Your Rules, Example"]
and prevent the script to disable LTE1 interface.
*Main question is: How to adjust the script so it'll check (ping few hosts) with VDSL2 connection (which may be dead or not), not LTE1?
*
So:
- VDSL2 is dead.
- Script enables LTE1 interface.
- Script checks few host using VDSL2 connection:
a) if can ping them - script just disable LTE1 and it auto fall back to VDSL2
b) if still can't ping them - do nothing.
Or maybe there is another way to do it?
Sorry for long writing.
Bart