How can an internet connection be tested without pinging some website? I mean, what if there is a connection but the site is down? Is there a check for a connection with the
shortest way: fping 4.2.2.1
=> "4.2.2.1 is alive"
i prefer this as it's faster and less verbose output than ping
, downside is you will have to install it.
you can use any public dns rather than a specific website.
fping -q google.com && echo "do something because you're connected!"
-q
returns an exit code, so i'm just showing an example of running something you're online.
to install on mac: brew install fping
; on ubuntu: sudo apt-get install fping