Connection check script

#!/bin/bash
x=`ping -c1 google.com 2>&1 | grep unknown`
if [ ! "$x" = "" ]; then
        echo "It's down!! Attempting to restart."
        service network restart
fi

# you can swap "service network restart" with "netplan apply" depending on your linux distro.

Leave a Reply

Your email address will not be published.