Give this a try (I'm not good in scripting, but it works for me): #!/bin/bash GW1="192.168.10.4" GW2="19.18.31.18" TEST=$GW1 echo "Setting default gw to $GW1" route add default gw $GW1 route -n echo Starting gateway test ... while true ; do echo "GW1: $GW1, GW2: $GW2, testing $TEST" ping $TEST -c 1 > /dev/null 2>&1 # $? returns 1 if host if [ $? = 1 ] ; then echo Gateway is down, resetting routes ... route del default gw $GW1 route add default gw $GW2 route -n if [ $TEST=$GW1 ] ; then TEST=$GW2 else TEST=$GW1 fi echo "Now testing $TEST" fi done
Hi! This problem seems to be interesting for me too. So I've got one question: Could there be set two Gateway-entrys? Seems to me like you could set different metrics so there is the one with the lower one taken until it isn't available. Could please tell me anyone if I'm wrong? Christian Am Sam, 10 Mär 2001 schrieben Sie:
Give this a try (I'm not good in scripting, but it works for me):
#!/bin/bash
GW1="192.168.10.4" GW2="19.18.31.18" TEST=$GW1
echo "Setting default gw to $GW1" route add default gw $GW1 route -n
echo Starting gateway test ...
while true ; do echo "GW1: $GW1, GW2: $GW2, testing $TEST" ping $TEST -c 1 > /dev/null 2>&1 # $? returns 1 if host if [ $? = 1 ] ; then echo Gateway is down, resetting routes ... route del default gw $GW1 route add default gw $GW2 route -n if [ $TEST=$GW1 ] ; then TEST=$GW2 else TEST=$GW1 fi echo "Now testing $TEST" fi done
--------------------------------------------------------------------- To unsubscribe, e-mail: suse-security-unsubscribe@suse.com For additional commands, e-mail: suse-security-help@suse.com --
Christian Uhde Dreikreuzenstrasse 6 30449 Hannover Germany mail@christian-uhde.de http://www.christian-uhde.de --
At 08:41 AM 13/03/2001, you wrote:
Hi! This problem seems to be interesting for me too. So I've got one question: Could there be set two Gateway-entrys? Seems to me like you could set different metrics so there is the one with the lower one taken until it isn't available.
Could please tell me anyone if I'm wrong?
You didn't say "what" your two gateways are, but I would certainly look at GNU Zebra to do this stuff for you. Specifically use OSPF (Open Shortest Path First) routing.. Cheers --- Nix - nix@susesecurity.com http://www.susesecurity.com
participants (3)
-
Björn Engels
-
Christian Uhde
-
Nix