Aug 042011
 

If you find yourself with a customer requesting to know where all the domains associated with a cpanel account are pointing to or are migrating accounts, you can do the following:

#for each in `ls /var/cpanel/users/*`; do grep DNS $each >> domains.txt; done;
#sed -i 's:.*DNS.*\=::gi' domains.txt ;
#for each in `cat domains.txt`; do echo "doing a dig on $each"; dig $each | grep -E "^$each.*\b(A|CNAME).*\..*\..*" ; echo ""; done;

The output will be something similar to;

 doing a dig on cavemantech.net
 cavemantech.net.   13970   IN  A   68.180.131.16
 
 doing a dig on cave.cavemantech.net
 cave.cavemantech.net.  13970   IN  A   68.180.131.16
 
 doing a dig on training.cavemantech.net
 training.cavemantech.net. 13970    IN  A   68.180.131.16
 
 doing a dig on wordpress.cavemantech.net
 wordpress.cavemantech.net. 13970 IN    A   68.180.131.16
 
 doing a dig on roundcube.cavemantech.net
 roundcube.cavemantech.net. 13970 IN    A   68.180.131.16
 
 doing a dig on confluence.cavemantech.net
 
 doing a dig on dino.cavemantech.net
 dino.cavemantech.net.  13970   IN  A   68.180.131.16

Also if you need multiple queries for a specific record:

#dig example.com ns another.com ns

or if all records are needed:

#dig example.com any another.com any

which returns non-label (resource records) RRs for both domains

# dig example.com another.com any

which returns A (resource records) RR for 1st and non-label (resource records) RRs for 2nd domain

# dig example.com any another.com

which returns non-label (resource records) RRs for 1st and A (resource records) RR for 2nd

Share This!
 Posted by at 12:04 pm

Sorry, the comment form is closed at this time.