I have a linux (debian) router with two internet connections (A) and (B).
(A) is preferred, (B) is fallback.
I want to monitor the internet connection (and not only the availability of the gateways!) and change the default route appropriately.
- If (A) is not providing internet, switch to (B)
- If (A) is providing internet again, switch back to (A).
Only problem I have is in case (2). My routing table points towards a working internet so I cannot easily detect whether internet is working over link (A) again.
I am search for a ping or traceroute (or other diagnosis-tool) which can select the next-hop explicitly.
ping -rlooks promising, but can only ping a host on the lan. (It only has to write another destination address in the packet, damnit!)
traceroute -g gatewaylooks even more promising and nearly does what I want - but sets source routing options which my next-hops deny. (Not within my administrative boundary...)
I just want a $ping, that can:
- select a source interface (and address)
- select a next-hop on that interface
- ping any arbitrary ip address
I could do evil trickery with policy-based routing but that would have production impact for all users. I would like to see a side-effect-free solution....