[dig] Implement a "hit the right NS" flag
I often find myself having to query the DNS servers of a domain directly. Just to check if I configured it correctly, or because it's mandatory on the service I use.
Feel like I almost need a +trace, but a +trace would be overkill.
I often end up writing queries like:
dig 79.106.226.46.xbl.spamhaus.org @$(dig NS xbl.spamhaus.org +short | head -n 1)
but here I obviously "did what I guessed would work", but to implement it I'll do an SOA query first:
dig SOA 79.106.226.46.xbl.spamhaus.org
gives xbl.spamhaus.org.
, dig NS xbl.spamhaus.org
gives a few NS servers, allowing to use one, like dig 79.106.226.46.xbl.spamhaus.org @a.gns.spamhaus.org.
.
In some cases it would be nice to have the answers of all NS servers, which themselves can have multiples addresses (to check a config) but in other cases a single answer from a random NS server is enough (to query a DNSBL).