How do I query a DNS server for the MX (or other) records it holds on a domain?

Tim Rohaly

The DNS protocol is described in RFC 1035 (http://www.faqs.org/rfcs/rfc1035.html), with clarifications in RFC 2181 (http://www.faqs.org/rfcs/rfc2181.html).

Operating system libraries usually provide a way to find out the A records, e.g. gethostbyname() - this same functionality is in the java.net.InetAddress class in Java via getByName() and related methods. I've never encountered a system function to get the MX records, and the same is true in Java. To find the MX records you will need to open a socket to the DNS server and form a proper query. Refer to the above RFCs for details of the protocol.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact