Skip to content

Instantly share code, notes, and snippets.

@Daniyal-Javani
Daniyal-Javani / failover.sh
Last active July 17, 2019 12:23 — forked from Apsu/failover.sh
An example failover script for dual WAN, using a ping healthcheck and managing default routes appropriately
#!/bin/bash
# Set defaults if not provided by environment
CHECK_DELAY=${CHECK_DELAY:-4}
CHECK_IP=${CHECK_IP:-8.8.8.8}
PRIMARY_IF=${PRIMARY_IF:-eth0} PRIMARY_GW=${PRIMARY_GW:-192.168.1.1}
BACKUP_IF=${BACKUP_IF:-wlan0}
BACKUP_GW=${BACKUP_GW:-192.168.43.1}
# Compare arg with current default gateway interface for route to healthcheck IP