Skip to content

Instantly share code, notes, and snippets.

@yaci
Last active March 16, 2019 21:29
Show Gist options
  • Save yaci/9c266f2bcc8150307c9fca0a2f7890fd to your computer and use it in GitHub Desktop.
Save yaci/9c266f2bcc8150307c9fca0a2f7890fd to your computer and use it in GitHub Desktop.
ANY metatype for DNS queries is being phased out, so here is the reimplementation of "dig -t any domain.tld"
#! /bin/bash
# new DNS specification RFC8482 states that DNS servers do not need to respond to ANY metatype
# and can return NOTIMP (not implemented) response for such query. Many of us however, used
# `dig -t any domain.tld` command
# for various debugging purposes. Since more and more servers will be refusing such queries,
# the alternative is to query servers "manually" for every possible record type.
domain="$1"
# https://en.wikipedia.org/wiki/List_of_DNS_record_types
recordTypesList=("A" "AAAA" "AFSDB" "APL" "CAA" "CDNSKEY" "CDS" "CERT" "CNAME" "DHCID" "DLV" "DNAME" "DNSKEY" "DS" "HIP" "IPSECKEY" "KEY" "KX" "LOC" "MX" "NAPTR" "NS" "NSEC" "NSEC3" "NSEC3PARAM" "OPENPGPKEY" "PTR" "RRSIG" "RP" "SIG" "SMIMEA" "SOA" "SRV" "SSHFP" "TA" "TKEY" "TLSA" "TSIG" "TXT" "URI")
for recordType in ${recordTypesList[@]}; do
dig @8.8.8.8 +noall +answer +multiline -t $recordType $domain &
done | awk '!x[$0]++'
# awk '!x[$0]++' removes duplicated lines (querying dns for "exotic" record types may yield an
# answer for CNAME instead, so we try to filter out such responses for better readability)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment