Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This command will show the output of MX record:

dig @ns1.myname.com myname.com +short MX

and this will output A record:

dig @ns1.myname.com myname.com +short A

My question is how to output both A and MX with +short in one output display? Thank you.

UPDATE: Cakemox this is the output I receive:

root@server1:~# dig +noall +answer @ns1.myname.com myname.com MX
myname.com.      86400   IN      MX      10 ASPMX2.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      10 ASPMX3.GOOGLEMAIL.COM.
myname.com.      86400   IN      MX      1 ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT1.ASPMX.L.GOOGLE.COM.
myname.com.      86400   IN      MX      5 ALT2.ASPMX.L.GOOGLE.COM.

I was hoping I could get this kind of output with just one dig command and without separating with semicolon?

root@server1:~# dig @ns1.myname.com myname.com +short MX; dig @ns1.myname.com myname.com +short A

Thank you.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

What do you mean by 'ouput in one display'?

I can almost not imagine this being the actual answer due to the simplicity, but based on what I assume is your answer now, this should do the trick:

dig @ns1.myname.com myname.com +short MX; dig @ns1.myname.com myname.com +short A

You can simply queue several commands in one line by separating them with a semicolon.

share|improve this answer
Ah yes thats what I mean actually. Sorry about my English. Is there anyway I could run it with just one dig query instead separating with semicolon? I will mark this as solve. Thank you. –  sg552 Feb 5 '12 at 19:53
dig +noall +answer @ns1.myname.com myname.com ANY

You can grep out the types you need if you don't want all of them, or query for each one you want in turn.

share|improve this answer
Hi there, I update my question. –  sg552 Feb 5 '12 at 20:07
By "ANY" I mean literally "ANY". It will return all resource record types for a given domain name. –  Cakemox Feb 5 '12 at 20:50
It's worth adding that ANY only works the way you expect with the authoritative name servers for that domain. Non-authoritative name servers will return everything they currently have cached but will not do any extra queries for records they don't have cached. –  Ladadadada Feb 8 '12 at 8:00
Yup, I was totally assuming that ns1.myname.com was authoritative for myname.com. –  Cakemox Feb 8 '12 at 12:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.