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.
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>]
- 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.
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}
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?
- Status changed from Feedback to Closed
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0