Skip to content

Instantly share code, notes, and snippets.

@kgaughan
Last active December 12, 2017 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgaughan/b0ed6852f681be576f61aa0d0bf01314 to your computer and use it in GitHub Desktop.
Save kgaughan/b0ed6852f681be576f61aa0d0bf01314 to your computer and use it in GitHub Desktop.
Get A records for a given domain name
get_nss () {
dig +aaonly @$(dig +short $(echo $1 | cut -f2- -d.) NS | head -n1) $1 NS | \
grep -v '^;' | \
awk '$4 == "NS" {print substr($5, 1, length($5) - 1)}' | sort -u
}
fqdn=google.com
dig +short @$(get_nss $fqdn | head -n1) $fqdn A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment