Project

General

Profile

Bug #16653

Weird behaviour of Resolv module

Added by evserykh (Evgeniy Serykh) about 1 month ago. Updated about 1 month ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
[ruby-core:97258]

Description

I have to deal with DNS request. Here is some examples.

When I ask A records for example.com at some public DNS servers I get the results:
> Resolv::DNS.new(nameserver: ['8.8.8.8', '1.1.1.1']).getresources('example.com', Resolv::DNS::Resource::IN::A)
=> [#<Resolv::DNS::Resource::IN::A:0x00005631491d5918 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=11607>]

When I ask A records at DNS servers responsible for given domain there is no answer:
> Resolv::DNS.new(nameserver: ['a.iana-servers.net', 'b.iana-servers.net']).getresources('example.com', Resolv::DNS::Resource::IN::A)
=> []

Updated by jeremyevans0 (Jeremy Evans) about 1 month ago

Looks like the issue is using multiple domain names instead of IP addresses for the :nameserver option. Single domain name works, multiple IP addresses works, IP address and domain name works, multiple domain names does not work:

Resolv::DNS.new(nameserver: ['a.iana-servers.net', 'b.iana-servers.net']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => []

Resolv::DNS.new(nameserver: ['b.iana-servers.net']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => [#<Resolv::DNS::Resource::IN::A:0x0000177abba0b598 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=86400>]

Resolv::DNS.new(nameserver: ['a.iana-servers.net']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => [#<Resolv::DNS::Resource::IN::A:0x0000177a82c89998 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=86400>]

Resolv::DNS.new(nameserver: ['199.43.135.53', '199.43.133.53']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => [#<Resolv::DNS::Resource::IN::A:0x0000177a98047e58 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=86400>]

Resolv::DNS.new(nameserver: ['a.iana-servers.net', '199.43.133.53']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => [#<Resolv::DNS::Resource::IN::A:0x0000177a8d8fe0c0 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=86400>]

Resolv::DNS.new(nameserver: ['199.43.135.53', 'b.iana-servers.net']).getresources('example.com', Resolv::DNS::Resource::IN::A)
# => [#<Resolv::DNS::Resource::IN::A:0x0000177a1b8089a8 @address=#<Resolv::IPv4 93.184.216.34>, @ttl=86400>]

Also available in: Atom PDF