From: Yves-Eric Date: 2009-03-02T13:09:01+09:00 Subject: Re: DNS MX lookup issue: local machine returned as MX for an non-existant domain! Problem solved. Executive summary: it is a documentation bug. DNS name queries need a final dot. Do not query resources for "domain.com" as the Resolv documentation [1] suggests. One should instead query for "domain.com.", with an extra dot at the end. The first form, without the final dot, will also be looked up in the local domain (for example, you could look for just "www", and you would get the result for "www.localdomain.com"). The problem is when you have a wildcard DNS entry in the local domain: then any non-existent domain would match that entry. Because the current documentation uses "www.ruby-lang.org" as an example, a lookup could occur for something like "www.ruby-lang.org.localdomain.com", which is **not** what users unfamiliar with DNS would expect. More importantly, even people familiar with DNS could be mislead by the documentation and forget the final dot. So, to follow the principle of least surprise, the documentation should be updated to include the final dot in example DNS name strings. Where should I fill a bug report? PS: thanks again for your suggestions Brian. While it sounded quite daunting at first, I took the plunge into Ruby source code, and it was really not that bad. With a few strategically placed STDERR.puts, I could quickly get to the root of the problem. For the record, I also learned that "[|proto]" means that the packet was truncated at the "proto" protocol level, in our case "domain", and we needed to capture more data. So here is a new cleaned-up dump (thanks also for the Socket.do_not_reverse_lookup for noise reduction, it was indeed Ruby doing the PTR queries), where the second query shows the problem clearly: # dump of Resolv::DNS activity: host > dns: 0+ MX? i-dont-exist.com. (49) dns > host: 0 NXDomain 0/1/0 (122) host > dns: 1+ MX? i-dont-exist.com.mydomain.com. (61) dns > host: 1 2/13/11 CNAME mydomain.com., MX mydomain.com. 10 (491) [1] http://www.ruby-doc.org/core-1.9/classes/Resolv.html Best regards, -- Yves-Eric