1
In Raspbian (Debian) on the RaspberryPi, I've got two interfaces, eth0
and wlan0
, and I'm using eth0
(a cellular modem) as the primary connection, with only some heavy traffic going out through wlan0
. To that end, I'm using the ip route
command.
Eg: (Routing Google's stuff through wlan0)
ip route add 74.125.228.0/24 dev wlan0
But, unfortunately, the power in our building occasionally goes out, rendering wlan0
useless.
How can I keep this static connection routed only when the host (eg. Google.com) is reachable via wlan0
(ie. wireless), but switch to eth0
(ie. cellular) when the power goes out (eg. Hurricane Sandy), and the wireless router is useless?
Write a script that pings the first hop (the AP) IP address. If it's not available, reconfigure so that the wireless is disabled. Note, you can either then write a script that attempts to reconnect every 30 mins by turning the port on and attempting to ping the AP, or you have to reset it by hand. – Everett – 2013-02-19T03:37:23.050
There are routing protocols that do this for you. You just need to have OSPF or BGP enabled (instead of using a static route). – Everett – 2013-02-19T03:38:00.817
@Everett That first suggestion sounds promising. Could you point me towards some material I could use as examples for that kind of scripting? As for the second suggestion, while it is true that those routing protocols could handle it, I'm worried that they may forego the use of the cellular
eth0
all together (by definition, that's what OSPF would want to do, I feel). – tamsanh – 2013-02-19T04:41:23.227@Everett, it seems like going the script route will be the best option. Probably I'll set up something on a cron job which checks if it can ping a certain domain via the
wlan0
. If it can't ping it, then it'll just reroute everything. – tamsanh – 2013-02-20T22:06:58.073