So I have a couple of routers connected to my network each linking to a different ISP. When an ISP goes down, I want to easily switch ISPs from the command line and these are the couple of lines I use to do so:
#!/bin/bash
sudo ip route del default
if [ $1 == 'isp1' ]
then
echo "Switching ISP to $1"
sudo ip route add default via 192.168.1.1
else
echo "Switch ISP to ISP2"
sudo ip route add default via 192.168.0.1
fi