NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Internet connection redundancy (DSL and 4GLTE)
RVP a écrit :
> On Wed, 8 Jun 2022, BERTRAND Joël wrote:
>
>> For example, how can I ping a server on WAN side through
>> 192.168.15.19 gateway and with 192.168.15.20 default route ?
>>
>
> Don't need to do that: just ping the host and if ping fails,
> switch routes round-robin; something like this:
>
> ```
> #!/bin/sh
>
> PRI=192.168.15.19
> SEC=192.168.15.20
> R=$PRI
> H=8.8.8.8
> T=10
>
> while :
> do if ! ping -nc1 $H >/dev/null 2>&1
> then case $R in
> $PRI) R=$SEC ;;
> $SEC) R=$PRI ;;
> esac
> route add default gw $R
> echo switched to $R
> S=1
> else S=$T
> fi
> sleep $S
> done
Your script runs, but SEC is only a backup and I have to switch back to
PRI as soon as possible (PRI has a fixed IP address).
JKB
Home |
Main Index |
Thread Index |
Old Index