Created
January 21, 2015 20:12
-
-
Save sgraham785/244ba6f81c484fc072ff to your computer and use it in GitHub Desktop.
Dig domains from txt file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## HOW TO USE | |
# sh dig_domains.sh A "8.8.8.8" (this returns the A records) | |
# domain.com 1224 IN A 127.0.0.1 | |
# sh dig_domains.sh A "8.8.8.8" "mail." (returns the mail. subdomain A records) | |
# mail.domain1.com. 14399 IN CNAME domain1.com. | |
# mail.domain2.com. 3599 IN A 127.0.0.1 | |
# sh dig_domains.sh MX "8.8.8.8" | awk '{print substr($1, 1, length($1)-1), "\t" substr($6, 1, length($6)-1)}' | |
# domain.com smtp.secureserver.net | |
# sh dig_domains.sh A "8.8.8.8" | awk '{print substr($1, 1, length($1)-1), "\t" substr($5, 1, length($5))}' | |
# domain.com 127.0.0.1 | |
## START SCRIPT | |
for domain in `cat /path/to/file.txt` | |
do | |
NS=$2 | |
PREFIX=$3 | |
TASK=$1 | |
domain=$3$domain | |
#dig @$NS $domain $TASK | |
# host $domain | |
dig @$NS $domain $TASK | grep -A 1 ";; ANSWER" | grep -v -e ";; ANSWER" | |
#sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment