===== Ubiquiti Edge Router Internet Load Balancing =====
When configuring internet load balancing on an edge router you can also configure a script to be run when there is a transition on an interface. This is helpful if you find that site-to-site VPN routes don't correctly stay in the load balancing route tables or you want to receive a status update on the transition.
{{tag>Ubiquiti EdgeRouter Routing}}
==== Edge Router Configuration ====
Configuration for internet failover load balancing with transition script to add and remove route for site-to-site VPN based on eth0 status.
set load-balance group LB_GROUP exclude-local-dns disable
set load-balance group LB_GROUP flush-on-active enable
set load-balance group LB_GROUP gateway-update-interval 20
set load-balance group LB_GROUP interface eth0 route table 100
set load-balance group LB_GROUP interface eth1 failover-only
set load-balance group LB_GROUP interface eth1 route table 101
set load-balance group LB_GROUP lb-local enable
set load-balance group LB_GROUP lb-local-metric-change disable
set load-balance group LB_GROUP transition-script /config/scripts/lb-transition.sh
==== Transition Script ====
Transition script that runs configuration scripts based on interface status.
#!/bin/vbash
# Echo usage if no arguments passed
[ $# == 3 ] || { echo "Usage: $0 "; exit 1; }
GROUP=$1; INTF=$2; STATUS=$3
readonly GROUP INTF STATUS
if [ "$INTF" == 'eth0' -a "$STATUS" == 'inactive' ]
then
/config/scripts/lb-transition-eth0-inactive.sh
fi
if [ "$INTF" == 'eth0' -a "$STATUS" == 'active' ]
then
/config/scripts/lb-transition-eth0-active.sh
fi
==== Interface Configuration Scripts ====
=== eth0 active ===
Add route for site-to-site VPN when eth0 goes active.
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
set protocols static table 100 route 10.10.10.0/24 next-hop 169.254.168.2
commit
exit
=== eth0 inactive ===
Remove route for site-to-site VPN when eth0 goes inactive.
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template
configure
delete protocols static table 100 route 10.10.10.0/24
commit
exit