With default options dig
shows the return status for a DNS query in the comment ;; ->>HEADER<<- ... status: NXDOMAIN
:
ubuntu:~$ dig hosted-by.myinternetservices.com.
; <<>> DiG 9.11.3-1ubuntu1.2-Ubuntu <<>> hosted-by.myinternetservices.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 63671
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;hosted-by.myinternetservices.com. IN A
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Oct 17 10:15:02 CEST 2018
;; MSG SIZE rcvd: 61
But very often I want to have a shorter output from dig
and I use the option +noall
to achieve this:
ubuntu:~$ dig +noall +answer www.seznam.cz.
www.seznam.cz. 266 IN A 77.75.77.39
ubuntu:~$ dig +noall +short www.seznam.cz.
77.75.77.39
I also need to see the status for cases when there is no answer but I was not able to get the status when I use +noall
. Is there a simple way how to show the status?