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
.