Last active
October 27, 2021 00:02
-
-
Save Haeniken/a95dd0a757df34d65ae60546a50c1ea7 to your computer and use it in GitHub Desktop.
dg
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 | |
# resolve a from local dns | |
echo '```' | |
echo -e "\e[1;33m$ dig a" $1 "+short\e[0m" | |
dig a $1 +short; | |
echo '```' | |
# check our ip | |
dig a $1 +short | xargs yii ip/is-our-ip | |
echo "" | |
echo -e "\e[1;33m$ dig a" $1 "+short @8.8.8.8\e[0m" | |
dig a $1 +short @8.8.8.8; | |
# resolve a from google public dns | |
echo "" | |
RESULT=$(dig a $1 +short @8.8.8.8 | xargs yii ip/is-our-ip | awk '(NR == 1)';) | |
if [[ $RESULT == Y* ]] | |
then echo -e "\e[1;32m$RESULT\e[0m" | |
else echo -e "\e[1;31m$RESULT\e[0m" | |
fi | |
# check registrar | |
echo "" | |
RESULT=$(whois $1 | grep -i registrar: | head -n 1;) | |
if [[ $RESULT =~ "beget" || $RESULT =~ "BEGET" || $RESULT =~ "Beget" ]] | |
then | |
echo -e "\e[1;33m$ whois $1 | grep -i registrar:\e[0m" | |
echo -e "\e[1;32m$RESULT\e[0m" | |
else | |
echo -e "\e[1;33m$ whois $1 | grep -i registrar:\e[0m" | |
echo -e "\e[1;31m$RESULT\e[0m" | |
fi | |
# check ns from whois | |
echo "" | |
RESULT=$(whois $1 | head -n 55 | grep --color=never -iE "name server|nserver";) | |
if [[ $RESULT =~ "beget" || $RESULT =~ "BEGET" ]] | |
then | |
echo '```' | |
echo -e "\e[1;33m$ whois" $1 "| grep -iE \"name server|nserver\"\e[0m" | |
echo -e "\e[1;32m$RESULT\e[0m" | |
echo '```' | |
else | |
echo '```' | |
echo -e "\e[1;33m$ whois" $1 "| grep -iE \"name server|nserver\"\e[0m" | |
echo -e "\e[1;31m$RESULT\e[0m" | |
echo '```' | |
fi | |
# check ns from local dns | |
echo "" | |
RESULT=$(dig ns $1 +short;) | |
if [[ $RESULT =~ "beget" ]] | |
then | |
echo -e "\e[1;33m$ dig ns" $1 "+short\e[0m" | |
echo -e "\e[1;32m$RESULT\e[0m" | |
else | |
echo -e "\e[1;33m$ dig ns" $1 "+short\e[0m" | |
echo -e "\e[1;31m$RESULT\e[0m" | |
fi | |
# check mx from google | |
echo "" | |
RESULT=$(dig mx $1 +short @8.8.8.8;) | |
if [[ $RESULT =~ "beget" ]] | |
then | |
echo -e "\e[1;33m$ dig mx" $1 "+short @8.8.8.8\e[0m" | |
echo -e "\e[1;32m$RESULT\e[0m" | |
else | |
echo -e "\e[1;33m$ dig mx" $1 "+short @8.8.8.8\e[0m" | |
echo -e "\e[1;31m$RESULT\e[0m" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It look like this: