I wrote this script to get me the necessary information on a domain:
Name Servers
A record
MX record
A record for each MX record
Expiration and Updated dates
Admin Contact's email address
Current status
Usage: dns.sh DOMAIN.COM
The info obtained from the WhoIs still needs some work to refine. Too bad there is no standard format for which all WhoIs results use. I hope someone finds this useful, too.
Code:
#! /bin/bash
if [ -n "$1" ]; then
echo ""
echo "<----- Domain Results ----->"
echo ""
echo "Nameservers for $domainname:"
dig ns $domainname +short
echo ""
echo "IP address for $domainname:"
dig $domainname +short
echo ""
echo "MX records for $domainname:"
dig mx $domainname +short
echo ""
echo "IP address for MX records:"
dig $(dig mx $domainname +short) +short
whois $domainname > ~/.whois.tmp
echo ""
echo "Important Dates:"
grep Expiration ~/.whois.tmp
grep "Updated Date:" ~/.whois.tmp
echo ""
echo "Administrative Contact:"
awk '/Administrative\ Contact/ {getline; print}' ~/.whois.tmp
echo ""
echo "$domainname Status:"
grep -i "status:" ~/.whois.tmp
rm ~/.whois.tmp
echo ""
echo "<----- End of Results ----->"
echo ""
else
echo " I need a domain"
echo " Usage: $0 DOMAIN.COM"
fi