If you are using Mikrotik’s /interface/detect-internet and have been googling for a solution, or even a reason, as to how to use the thing, then perhaps the following will help.
Scenario:
You have 3 wan links, and want to fail over between which ever one is up/down to the least preferred.
Mikrotik’s detect-internet uses the source IP and routing of an interface, to try and connect to a Mikrotik cloud service. If it’s reachable via an interface the status changes to “internet”.
This means that detect-internet is capable of telling you whether a WAN link has internet capability without having to roll your own solution. You can read more about the feature here.
This script uses that capability to change the interface (whether DHCP or static default route) to the weight that you require. This is good, because ROS does the work of using the correct source interface, so that you don’t have to go and add routing entries and ping destinations for each interface to monitor to see if a link is up.
“detect-internet” uses a source-ip bound connection to cloud.mikrotik.com to determine if a link has internet accces. Essentially if an interface has connectvity, it’s /interface/detect-internet/state entry will be “internet” and that’s a really easy way to know of a specific WAN interface has connectivity, without too much trouble
You have to setup the interfaces in interface->detect-internet however. Applicable to ROS 7.
I’m not a fan of mikrotik scripting, the syntax is terrible. But it gets the job done. Schedule the script below every 20 seconds using /system/scheduler, and it will check the status of each interface, and apply the default route distances making the most viable route the default.
All you have to do is edit the bottom 3 lines of the script, and set your preferred default route distances so that your WAN links will always choose the most available default route. Add some more, or less, depending on your requirements.
:global checkinternet do={
:local hasinternet [/interface/detect-internet/state/find name=$ifname and state=internet]
:local rtid [/ip/route find where dst-address=0.0.0.0/0 and immediate-gw~$ifname]
:if ([:len $rtid] = 0) do={
# :log info "$linkname/$ifname has no default route"
} else {
:local distance [/ip/route/get value-name=distance [find where dst-address=0.0.0.0/0 and immediate-gw~$ifname]]
# [:log info "$linkname/$ifname distance is $distance" ]
:if ([:len $hasinternet] = 0) do={
:if ($distance!=$downdistance) do={
[:log info "$linkname/$ifname is down" ]
/ip route set [find where dst-address=0.0.0.0/0 and immediate-gw~$ifname] distance=$downdistance
}
} else={
:if ($distance!=$updistance) do={
[:log info "$linkname/$ifname is up" ]
/ip route set $rtid distance=$updistance
}
}
}
}
$checkinternet linkname="CISP" ifname="ether6" downdistance="50" updistance="5"
$checkinternet linkname="AFRIHOST" ifname="ether7" downdistance="100" updistance="10"
$checkinternet linkname="LTE" ifname="ether8" downdistance="150" updistance="15"
That is all.
I’ve replaced all my shitty EzViz cameras with TP-Link cameras.
Goodbye EZViz, and good riddance. I will not be missing you.
In January of 2014, I built a new, proper firewall, because all the previous franken-machines I used before had hard-drive issues, and I really needed a stable development server.
This machine is still going today, 10 years later, and aside from the fact that it’s limited to 16Gb of DDR3 RAM, it’s still a core part of my home lab.
But the time came to change it from it’s home-made angle-iron “spider” platform to something a bit more modern, and dust-proof.
The new living space for “spider”
And what it used to be mounted on, steampunk style.
It was pretty challenging to find a chassis that accomodates a horizontally mounted mini-ITX board, but Lian-Li came through. My big concern was the massive Zalmann heat pipe that I had installed initially, because I wanted the system as quiet as possible, but it fit perfectly into the Lian-Li PC-QR36W I acquired.
I can’t believe this machine has served me so well for 10 years, and it’s still not bad in terms of performance.
Progress, far from consisting in change, depends on retentiveness. When change is absolute there remains no being to improve and no direction is set for possible improvement: and when experience is not retained, as among savages, infancy is perpetual. Those who cannot remember the past are condemned to repeat it.
If you like perfume, and don’t want to pay an arm and a leg for good fragrances, check out my wifes’ Ameru.co.za perfume selection.