All pastes #566298 Raw Edit

Multiple ISP failover solution

public shellscript v1 · immutable
·published 2007-06-14 12:04 UTC
rendered paste body
#!/bin/bashGW1="111.111.111.111"GW2="222.222.222.222"TESTIP="66.94.234.13" # yahoo.com - Any reliable Internet ip that responds to ping.CURGW=`/sbin/route -n |awk '/^0.0.0.0/ {print $2 }'`if ping -w2 -c3 $TESTIP >/dev/null 2>&1; then  echo "Active ISP is Ok."else  if [ "$CURGW" = "$GW1" ]; then    NEWGW="$GW2"  else    NEWGW="$GW1"  fi  /sbin/route del default  /sbin/route add default gw $NEWGWfi