Project

General

Profile

Actions

Bug #11152

closed

Resolv::DNS should use Search Domains provided in /etc/resolv.conf by default

Added by IronYuppie (David Aronchick) almost 9 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:69180]

Description

For some reason Resolv::DNS does not use search domains. Many downstream projects rely on Resolv, and this appears broken. I'm showing this below in Kubernetes, but it's based on the search domain(s), rather than a cluster issue.

[1] pry(main)> require 'resolv'
=> true
[2] pry(main)> Resolv::DNS.new.getaddresses('client')
=> []
[3] pry(main)> nameservers = ["10.0.0.10", "169.254.169.254", "10.240.0.1"]
[4] pry(main)> search_domains = ["default.kubernetes.local", "kubernetes.local", "c.bar-foobar-91020.internal.", "55618245300.google.internal.", "google.internal."]
[5] pry(main)> a = Resolv::DNS.new(:nameserver => nameservers, :search => search_domains)
[...output...]
[6] pry(main)> a.getaddresses('client')
=> [#<Resolv::IPv4 10.0.118.178>]

Updated by tenderlovemaking (Aaron Patterson) almost 9 years ago

  • Status changed from Open to Feedback

Hi,

It should parse your /etc/resolv.conf file. Can you post your /etc/resolv.conf? Maybe it's a problem with the parser.

Updated by lisinge (Micke Lisinge) almost 8 years ago

Aaron Patterson wrote:

Hi,

It should parse your /etc/resolv.conf file. Can you post your /etc/resolv.conf? Maybe it's a problem with the parser.

I am seeing the same problem, tested with Ruby 2.2.5 and 2.3.1.

My code is running on a kubernetes cluster with docker just like David's.

This is the resolv.conf and David's probably looks the same:

search staging.svc.cluster.local svc.cluster.local cluster.local c.foo-project.internal. google.internal.
nameserver 10.7.240.10
options ndots:5

With the config above Resolv::DNS::Config.default_config_hash returns:

Resolv::DNS::Config.default_config_hash
=> {:nameserver=>["10.0.1.1"], :search=>nil, :ndots=>1}

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

It looks like the problem is a kubernetes-specific issue. With your resolv.conf file, I get the following for Resolv::DNS::Config.default_config_hash:

{:nameserver=>["10.7.240.10"], :search=>["staging.svc.cluster.local", "svc.cluster.local", "cluster.local", "c.foo-project.internal.", "google.internal."], :ndots=>5}

Based on the results of yourResolv::DNS::Config.default_config_hash output, I think the only explanation is that it is the /etc/resolv.conf is different from what is displayed. What is File.read('/etc/resolv.conf') if run directly after require 'resolv'? Alternatively, you can provide a self-contained reproducible example showing the problem?

Actions #4

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0