Check to see if DNS is local or external
From brokenpoet.org wiki
The purpose of this script is to check all sites on a cPanel server to see if the domains are using the local nameservers or external nameservers.
It gets a domain list from the user files in /var/cpanel/users/ and the nameserver info from /etc/nameserverips
wget http://scripts.brokenpoet.org/chkdns.sh
#!/bin/bash
#
# written by benjamin cathey on 2008.11.22
# for cPanel servers, this script runs a whois lookup for all domains hosted
# on the server to see if they use the servers nameservers or if they use
# external DNS
domains=$(cat /var/cpanel/users/* | grep -e '.*\..*' | grep DNS | cut -d'=' -f2| awk '!/[a-z].*\.[a-z].*\.[a-z].*/')
nameservers=$(cat /etc/nameserverips | cut -d'=' -f2 | awk '/[a-zA-Z].*\.[a-zA-Z].*\.[a-zA-Z].*/')
echo "DOMAINS"
echo "-------"
printf "$domains\n"
echo
echo "NAMESERVERS"
echo "-----------"
printf "$nameservers\n"
echo
for domain in $domains
do
for nameserver in $nameservers
do
if [ -z "`whois $domain | grep -i $nameserver`" ]
then
user=$(basename `grep -lr "$domain" /var/cpanel/users/`)
dns=$(whois $domain | awk '/[a-zA-Z].*\.[a-zA-Z].*\.[a-zA-Z]/' | grep -i ns | sed 's/\ //g')
if [ -z $count ]
then
echo "DNS NOT ON THIS SERVER"
echo "----------------------"
echo "$domain ($user)"
printf "$dns\n"
echo
count=1
break
else
echo "$domain ($user)"
printf "$dns\n"
echo
count=$(( $count + 1 ))
break
fi
fi
done
done
if [ -z $count ]
then
exit 1
else
echo
echo "$count domain(s) not on this server"
fi
