Last active
February 16, 2018 10:46
-
-
Save MarcelFox/ccd5c0313984ae98a3d435a3a6ed5e79 to your computer and use it in GitHub Desktop.
Check connection and IPs of a host.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
status_conn=$(wget -q --spider http://google.com && echo 0 || echo 1) | |
if [ $status_conn -eq 1 ] | |
then | |
printf "\n \e[36m Your Internet is pretty much dead!\n Check your networks...\e[0m\n\n"; | |
elif [ $status_conn -eq 0 ] | |
then | |
external=$(dig +short myip.opendns.com @resolver1.opendns.com); | |
locally=$(ip addr | grep -v inet6 | grep inet | awk '{print $2}'|cut -d"/" -f1 | tail -n1 | head -n2); | |
printf "\n \e[4mExternal\e[0m IP:\t\e[1m\e[32m$external\e[0m\n \e[4mLocal\e[0m IP:\t$locally\n\n"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can run it directly using curl:
bash <(GET https://gist.githubusercontent.com/MarcelFox/ccd5c0313984ae98a3d435a3a6ed5e79/raw/97b7af7945b12871dcbba90608534311eb50ed28/check_conn.sh)
You must install the proper 'dnsutils' package on your distribution in order to run dig.