Score:0

How to configure failover in edgerouter x 5 ports?

ng flag

I have connected to my edgerouter x 5 ports, 2 WAN (WAN1 to eth0 and WAN2 to eth1 in failover)

Problem: WAN1 has 10 Mbps and WAN2 Failover 8 Mbps. When WAN1 drops, but not enough (example: 1 or 0.5 Mpbs), WAN2 failover does not enter.

What I want is that when WAN1 drops to XX Mbps, WAN2 goes into operation in failover mode and returns to WAN1 when it exceeds XX Mbps, in a recovery time of XX minutes

Where XX are values that I determine manually

My edgerouter x:

enter image description here

enter image description here

I did not find the information in the ubiquiti user manuals for this router HERE, HERE or HERE

I appreciate the help.

PS: I apologize if this is not the right forum to ask this question. I searched on stackexchange but didn't find any hardware to post this question

vidarlo avatar
ar flag
*What* parameter do you want to trigger on? When available bandwidth is under 2Mb/s? How can you know if available BW is <2Mb/s?
acgbox avatar
ng flag
The question describes the scenario. What I want to activate the failover when I want, according to my parameters and not when the router decides.
vidarlo avatar
ar flag
How do you determine the available bandwidth?
acgbox avatar
ng flag
I suppose that it will be necessary to take them from the RX/TX (although these values do not represent reality, but it is close). But I really wouldn't know
vidarlo avatar
ar flag
You can't do that. You don't know why you have low speed. It can be a video feed that just happens to consume 400Kb/s, or it can be a download that is slow. The problem is simply that the router has ***no way of knowing*** the parameter you want to act upon. This is not a trivial problem; it's fundamental.
Score:0
cn flag

There's no such thing as Ethernet running at 2Mbps. If you have some other means of getting a bandwidth report reliably (e.g. DSL or 3G modem status page) you can incorporate this check in a bash script, save it somewhere in /config/scripts so it will survive firmware upgrades and then call it in your load-balance stanzas like in the example below.

In this example WAN2 is on eth2 and is a backup, while WAN1 is on eth1 and its the primary link. You would also need to create routing tables 10 and 20 with the appropriate defaults in each and reference them in firewall modify rules:

load-balance {
group WAN2 {
    exclude-local-dns disable
    flush-on-active disable
    gateway-update-interval 20
    interface eth1 {
        failover-only
        route {
            table 10
        }
        route-test {
            initial-delay 180
            interval 60
            type {
                script /config/scripts/pinger
            }
        }
    }
    interface eth2 {
        route {
            table 20
        }
        route-test {
            initial-delay 180
            interval 60
            type {
                script /config/scripts/pinger
            }
        }
    }
    lb-local disable
    lb-local-metric-change disable
}
group WAN1 {
    exclude-local-dns disable
    flush-on-active disable
    gateway-update-interval 20
    interface eth1 {
        route {
            table 10
        }
        route-test {
            initial-delay 180
            interval 60
            type {
                script /config/scripts/pinger
            }
        }
    }
    interface eth2 {
        failover-only
        route {
            table 20
        }
        route-test {
            initial-delay 180
            interval 60
            type {
                script /config/scripts/pinger
            }
        }
    }
    lb-local disable
    lb-local-metric-change disable
}
}

The script is called with three parameters:

#!/bin/bash
targets=(
    '192.168.10.1'
    '192.168.20.1'
    '192.168.30.1' )
if [ $# != 3 ]
then
  echo "Usages: $0 <group> <intf> <status>"
  exit 1
fi

group=$1
intf=$2
status=$3

for host in "${targets[@]}"
do
  /bin/ping -n -c 1 -W 1 -w1 -I $intf $host
  if [ $? == 0 ]
    then
      exit 0
  fi
done

# fail

exit 1

This script uses ping via interface provided by EdgeOS upon the script startup to check availability of three uplink hosts and returns 0 (ok) if at least one of them responds and 1 (failure) when no hosts respond.

You could use the same approach to implement some logic so that when the $intf has a good status according to your checks, return 0 with exit 0, otherwise return 1 with exit 1.

acgbox avatar
ng flag
So, according to your answer, the "Trigger Level" and "Recovery Time" failover options do not exist in the Edgarouter-5-ports configuration.
Peter Zhabin avatar
cn flag
There's no such thing in EdgeOs in general, as far as I'm aware. Built-in functionality for load balancing is `route-test type ping` with success and failure counters triggering failure and recovery. But you can alter this with `route-test type script` as I described in my answer and implement your own logic in this script.
acgbox avatar
ng flag
I think you should explain how your script works and why you set those values
Peter Zhabin avatar
cn flag
I have included a complete script we use here to monitor dual-wan networks on EdgeOS together with a brief explanation of the logic behind it.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.