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
5 ALT1.ASPMX.L.GOOGLE.COM.
5 ALT2.ASPMX.L.GOOGLE.COM.
10 ASPMX2.GOOGLEMAIL.COM.
10 ASPMX3.GOOGLEMAIL.COM.
1 ASPMX.L.GOOGLE.COM.
63.98.113.202

Thank you.

link|improve this question

80% accept rate
feedback

2 Answers

up vote 2 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.

link|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 at 19:53
feedback
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.

link|improve this answer
Hi there, I update my question. – sg552 Feb 5 at 20:07
By "ANY" I mean literally "ANY". It will return all resource record types for a given domain name. – Cakemox Feb 5 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 at 8:00
Yup, I was totally assuming that ns1.myname.com was authoritative for myname.com. – Cakemox Feb 8 at 12:12
feedback

Your Answer

 
or
required, but never shown

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