The below sh script trigger rebooting server if Google DNS does not respond

#!/bin/sh
ping -w 10 -c 1 8.8.8.8
if [ $? = 0 ]
then
        echo noreply
else
        /sbin/reboot
fi

In the AsusWrt, the below script works good

/jffs/scripts/reboot_if_ping_does_not_work
#!/bin/ash

if [ $( ping -c 1 google.com | grep ttl | wc -l ) -eq 0 ]
then
        echo noreply
        /sbin/reboot
else
        echo "google.com is reachable"
fi