From: Jon@... Date: 2014-11-26T22:41:38+00:00 Subject: [ruby-core:66498] [ruby-trunk - Bug #10550] [Open] Resolv::DNS.getaddresses returns no IPs when nameserver returns in differing case than query Issue #10550 has been reported by Jon Hyman. ---------------------------------------- Bug #10550: Resolv::DNS.getaddresses returns no IPs when nameserver returns in differing case than query https://bugs.ruby-lang.org/issues/10550 * Author: Jon Hyman * Status: Open * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Our servers are hosted with Rackspace and following patching of BIND, their DNS servers started returning different casing for the ANSWER. For example, here is me resolving sendgrid.com. You'll see the first command returns "sendgrid.com" in the answer section, while another returns "SENDGRID.COM". $ dig sendgrid.com ; <<>> DiG 9.8.1-P1 <<>> sendgrid.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7895 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;sendgrid.com. IN A ;; ANSWER SECTION: sendgrid.com. 5 IN A 104.20.21.26 sendgrid.com. 5 IN A 104.20.20.26 ;; Query time: 2 msec ;; SERVER: 69.20.0.164#53(69.20.0.164) ;; WHEN: Wed Nov 26 22:21:04 2014 ;; MSG SIZE rcvd: 62 $ dig sendgrid.com ; <<>> DiG 9.8.1-P1 <<>> sendgrid.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21767 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;sendgrid.com. IN A ;; ANSWER SECTION: SENDGRID.com. 5 IN A 104.20.20.26 SENDGRID.com. 5 IN A 104.20.21.26 The problem here is that due to https://github.com/ruby/ruby/blob/570c028c7ebb18c6d276e5fac3a1b20f76f28db7/lib/resolv.rb#L579, the addresses won't get returned because of the case difference. As a result, Resolv::DNS sporadically returns no IP addresses. In my example, let's say that I'm calling Resolv::DNS.new.getaddresses("sendgrid.com") and it returns uppercase. The message returned will be something like this => #, Resolv::DNS::Resource::IN::A]], @answer=[[#, 1, #, @ttl=1>], [#, 1, #, @ttl=1>]], @authority=[], @additional=[]> whereas "n0" will be => # so the comparison in line 579 returns false. --- Here's another example of this in an irb console on my Rackspace server require 'resolv' r = Resolv::DNS.new 10.times { puts r.getaddresses("sendgrid.com").inspect } [#, #] [#, #] [#, #] [] [#, #] [#, #] [] [] [#, #] [#, #] => 10 DNS is case-insensitive, so the comparison should be case-insensitive as well. -- https://bugs.ruby-lang.org/