Mini Shell
Direktori : /opt/sharedrads/ |
|
Current File : //opt/sharedrads/check_dns |
#!/bin/bash
# Originally written by Kevin Arima, rewritten by Laura Smith with collaboration by Chase Stricklan, Joseph Martin and Daniel King.
# Edited again by Laura Salaj 1/2/23 to update for newer TLDs.
domain="${1?No domain specified.}"
echo
regex="^((\w+)*)([\w\-\_\.]+)$"
# 1/2/23 - regex updated from restrictive conditions for domains since they have since changed since this was originally written.
# also removed the below lines as the error reporting was only relevant when there was a TLD the regex didn't mathc.
#if grep -P "$regex" <<< $domain > /dev/null 2>&1 ; then
# echo "That is a valid domain name." > /dev/null 2>&1
#else
# echo "That is not a valid domain name.";echo && exit
#fi
echo_green () { echo -en "\033[0;32m$1\033[0m"; echo; }
echo_cyan () { echo -en "\033[0;36m$1\033[0m"; echo; }
echo_red () { echo -en "\033[0;31m$1\033[0m"; echo; }
echo_blue () { echo -en "\033[0;34m$1\033[0m"; echo; }
check="dig +nocmd +noall +answer $1"
google=$($check @8.8.8.8)
echo "--- $1 is pointed to the following nameservers ---"
$check ns | awk {'print substr(1,length($1)),$5'}
public_dns=$($check ns | grep NS | awk {'print "@"substr($5,1,length($5)-1)'})
imh=$($check @ns.inmotionhosting.com ns | grep NS | awk {'print "@"substr($5,1,length($5)-1)'})
hub=$($check @ns1.webhostinghub.com ns | grep NS | awk {'print "@"substr($5,1,length($5)-1)'})
if [[ ! $public_dns ]]
then
echo_red "No Nameservers found."
else
echo "Querying DNS Servers"
echo -ne "\033[0;33mLocal Resolver\033[0m"
for i in "" ${public_dns:=@ns @ns2}; do
echo_green "$i:"
$check $i soa +short | awk {'print "\tSOA: " $3'}
$check $i +short | awk {'print "\tA: " $1'}
$check $i mx +short | awk {'print "\tMX: " $1,$2'}
$check $i txt +short | awk -F '"' {'print "\tTXT: " $2'}
done
fi
if [[ ! $imh ]]
then
echo_red "No records found for IMH nameservers."
else
echo_blue "IMH Nameservers:"
for i in ${imh:=@ns @ns2}; do
echo_green "$i:"
$check $i soa +short | awk {'print "\tSOA: " $3'}
$check $i +short | awk {'print "\tA: " $1'}
$check $i mx +short | awk {'print "\tMX: " $1,$2'}
$check $i txt +short | awk -F '"' {'print "\tTXT: " $2'}
done
fi
if [[ ! $hub ]]
then
echo_red "No records found for HUB nameservers."
else
echo_cyan "HUB Nameservers"
for i in ${hub:=@ns @ns2}; do
echo_green "$i:"
$check $i soa +short | awk {'print "\tSOA: " $3'}
$check $i +short | awk {'print "\tA: " $1'}
$check $i mx +short | awk {'print "\tMX: " $1,$2'}
$check $i txt +short | awk -F '"' {'print "\tTXT: " $2'}
done
fi
if [[ ! $google ]]
then
echo_red "No records found for Google DNS."
else
for i in @8.8.8.8; do
echo -e "\033[0;35mGoogle DNS:\033[0m"
$check $i soa +short | awk {'print "\tSOA: " $3'}
$check $i +short | awk {'print "\tA: " $1'}
$check $i mx +short | awk {'print "\tMX: " $1,$2'}
$check $i txt +short | awk -F '"' {'print "\tTXT: " $2'}
done
fi
echo && exit
Zerion Mini Shell 1.0