change deafult gateway with ping

touch /etc/init.d/ping
chmod 755 /etc/init.d/ping
nano /etc/init.d/ping

#!/bin/bash
 
PINGOUT=`ping -c 10 194.145.63.12 | grep "100% packet loss"`
if [ "$PINGOUT" = "" ]; then
echo "ping gateway OK"
else
route del deafult
route add default gw 93.155.131.19
fi

nano /etc/crontab

*/1 * * * * root test -x /etc/init.d/ping && /etc/init.d/ping

/etc/init.d/cron restart

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.