#!/bin/sh
# This script expects domain name as an argument and checks
# is the inputted domain properly recorded into a group of
# DNS servers.
#

# read domain
arg1="$1";

# input the DNSes to match domains against
DNS[1]='ns1.somedns.com';
DNS[2]='ns2.somedns.com';
DNS[3]='ns3.somedns.com';
DNS[4]='ns4.somedns.com';

# counts the DNS array
DNS_CNT="${#DNS[@]}";

if [ "$arg1" ]; then

for L in $(seq 1 ${DNS_CNT}); do
ret_line=$(host ${arg1} ${DNS[$L]} |grep -i "has address");
result=$(echo $ret_line |wc -l)
echo;

if [ ${result} == "1" ]; then
echo "$arg1 has record in ${DNS[$L]}";
echo "$ret_line";
echo "SUCCESS";
echo;
else
echo "FAILED";
echo "$arg1 no record in ${DNS[$L]}";
fi

done

else
echo "Missing argument, please enter the requested domain name!";
exit 1;

fi

