dig show only answer
Solution 1:
I am not sure why you are getting comments in the output. That is the correct set of options for the behaviour you want. Here are the same options with the same version of dig:
$ dig -version
DiG 9.7.3
$ dig +noall +answer google.de
google.de. 55 IN A 173.194.44.216
google.de. 55 IN A 173.194.44.223
google.de. 55 IN A 173.194.44.215
$
Solution 2:
Use the "+short" option
[root@myhost ~]# dig +short google.com
216.58.194.142
[root@myhost ~]# dig +short -x 216.58.194.142
dfw06s49-in-f14.1e100.net.
dfw06s49-in-f142.1e100.net.
[root@myhost ~]# dig +short google.com soa
ns1.google.com. dns-admin.google.com. 181803313 900 900 1800 60
Solution 3:
Use dig +param domain
, not dig domain +param
.
% dig +noall +answer -t aaaa d.ns.zerigo.net
d.ns.zerigo.net. 37788 IN AAAA 2607:fc88:1001:1::4
% dig -t aaaa d.ns.zerigo.net +noall +answer
; <<>> DiG 9.9.2-P2 <<>> -t aaaa d.ns.zerigo.net +noall +answer
;; global options: +cmd
d.ns.zerigo.net. 37797 IN AAAA 2607:fc88:1001:1::4
+noall +answer
switch works differently depending on its position in the command line. This is surely a bug in dig
since +short
works OK on both sides.
% dig +short -t aaaa d.ns.zerigo.net
2607:fc88:1001:1::4
% dig -t aaaa d.ns.zerigo.net +short
2607:fc88:1001:1::4