Skip to content

Instantly share code, notes, and snippets.

@Sn4kY
Sn4kY / failover.sh
Last active January 30, 2022 00:20 — forked from Apsu/failover.sh
A failover script for dual WAN with dual interfaces, using a ping healthcheck and managing default routes appropriately, with antiflap and back to normal state availability
#!/bin/bash
# Set defaults if not provided by environment
CHECK_DELAY=${CHECK_DELAY:-5}
CHECK_LOOPS_FAIL=${CHECK_LOOPS_FAIL:-3}
CHECK_LOOPS_REVERT=${CHECK_LOOPS_REVERT:-5}
CHECK_IP=${CHECK_IP:-8.8.8.8}
PRIMARY_IF=${PRIMARY_IF:-enp0s17}
PRIMARY_GW=${PRIMARY_GW:-192.168.1.252}
BACKUP_IF=${BACKUP_IF:-enp0s18}