Can I lookup NS and A at the same time using dig
dig +short ns google.com a google.com
No, it can't be done reliably, at least not in a single DNS query. Martin's answer satisfies the "single command" criterion, but would result in two queries to the DNS server.
There is the ANY
option (instead of NS
or A
) but it's not a reliable way to get both records.
If you ask Google's authoritative server you should indeed get everything back, but I suspect you won't know what their server is in advance, otherwise you wouldn't ask this question.
If you ask your local recursive server then you might get back both records, but only if they're both in the cache. Recursive servers aren't required to obtain every record and return them for an ANY
query, they're allowed to send back just what they already have.