Created
December 19, 2021 16:48
-
-
Save goncalor/b4a377b98abc27d7fcf0efaeaf679819 to your computer and use it in GitHub Desktop.
Scripts to resolve domains to IPs
This file contains hidden or 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
/NXDOMAIN/ {print $2, "?"; next} | |
/SERVFAIL/ {print $2, "?"; next} | |
/mail is handled by/ {next} | |
/is an alias for/ {doms[$6]=$1; next} | |
{ | |
if ($1"." in doms) | |
print doms[$1"."], $4 | |
else if (match($0, "has IPv6 address")) | |
print $1, $5 | |
else | |
print $1, $4 | |
} | |
# This script processes a domain list such as this one | |
# example.com has address 93.184.216.34 | |
# example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946 | |
# example.com mail is handled by 0 . | |
# Host nx.example.com not found: 3(NXDOMAIN) | |
# | |
# and outputs the following format | |
# $ awk -f convert.awk domains-resolved.txt | |
# example.com 93.184.216.34 | |
# example.com 2606:2800:220:1:248:1893:25c8:1946 | |
# nx.example.com ? |
This file contains hidden or 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
#/urs/bin/env bash | |
xargs -n 1 host 2>&1 | |
# cat domains.txt | ./resolve.sh | tee domains-resolved.txt | |
# Be careful about line terminators on the input. Ensure \n only is used, UNIX style. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment