Many times it happens that when auditing a server you need to check which domain is resolving from the server in that case you can use the below simple shell script which will list all the domains with their respective IP’s.
For this all you need to do is to copy all the domains hosted on the server in a text file.
For cPanel you can copy all domains in a .txt file using the below command ::
root@server[#] cat /etc/userdomains | awk '{print $1}' | tr -d ':|*' > domainlist.txt
For Plesk you can copy all domains in a .txt file using the below command ::
root@server[#] cd /var/qmail/mailnames ; ls -l awk '{print $9}' > domainlist.txt
And for Plain server you can copy all the domains in a domainlist.txt file
Now, that we have all the domain names copied in the domainlist.txt file we just need to execute the below script from shell as a root user
root@server[#] for i in `cat domainlist.txt`; do host $i | grep 'not found|has IP address'; done
The above command will list the results as ::
test.com has address 192.168.0.1testing.com has address 192.168.0.2
That’s all.
