Readers will learn how to enable WAN failover on the EdgeRouter.
EdgeMAX can handle multiple WANs with failover. For a more recent article that shows this implementation with automatic failover, visit here.
My interface setup is as follows:
eth0 - WAN - IP: 10.75.1.2 / Gateway 10.75.1.1 eth1 - LAN - IP: 192.168.1.1 eth2 - WAN - IP: 10.90.1.2 / Gateway 10.90.1.1
First step is to add two tables to routing table. I use vi for this. From command line:
sudo su vi /etc/iproute2/rt_tables 1 ISP_PORT0 2 ISP_PORT2 Save
Next add the following to /etc/rc.local :
#ADD ROUTE FOR PORT 0 ip route add 10.75.1.0/24 dev eth0 src 10.75.1.2 table ISP_PORT0 ip route add default via 10.75.1.1 table ISP_PORT0 #ADD ROUTE FOR PORT 2 ip route add 10.90.1.0/24 dev eth2 src 10.90.1.2 table ISP_PORT2 ip route add default via 10.90.1.1 table ISP_PORT2 #ADD RULES FOR WAN(s) ip rule add from 10.75.1.2 table ISP_PORT0 ip rule add from 10.90.1.2 table ISP_PORT2 #DIVIDE TRAFFIC GIVE 1 ISP MORE WEIGHT. USE weight 1 FOR BOTH INTERFACES TO DIVIDE EVENLY ip route add default scope global nexthop via 10.75.1.1 dev eth0 weight 1 nexthop via 10.90.1.1 dev eth2 weight 4
Next download gwping script from here: https://raw.github.com/Evanlec/config/master/bin/g
Save script to /usr/sbin/gwping and chmod to 755
Edit the script to suit your environment, here is what mine looks like:
# Time between checks in seconds SLEEPTIME=3 #IP Address or domain name to ping. The script relies on the domain being #pingable and always available TESTIP=184.108.40.206 #Ping timeout in seconds TIMEOUT=2 # External interfaces EXTIF1=eth0 EXTIF2=eth2 #IP address of external interfaces. This is not the gateway address. IP1=10.75.1.2 IP2=10.90.1.2 #Gateway IP addresses. This is the first (hop) gateway, could be your router IP #address if it has been configured as the gateway GW1=10.75.1.1 GW2=10.90.1.1 # Relative weights of routes. Keep this to a low integer value. I am using 4 # for TATA connection because it is 4 times faster W1=1 W2=4 # Broadband providers name; use your own names here. NAME1=ISP_PORT0 NAME2=ISP_PORT2 #No of repeats of success or failure before changing status of connection SUCCESSREPEATCOUNT=4 FAILUREREPEATCOUNT=1
Finally we add the script to /etc/rc.local so it runs on startup:
Add to the end of the same file (rc.local) before exit 0
nohup /usr/sbin/gwping &
Restart the router and test!