Home Blog Bash Check network connectivity

Check network connectivity

Check if we have a network connection

if nc -zw1 google.com 443; then
  echo "connected"
fi

Wait until we have a network connection

Wait until we have a network connection

until nc -zw1 google.com 443; do sleep .5; done

Sources