celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

DNS should use search domains by default #146

Open aronchick opened 9 years ago

aronchick commented 9 years ago

Currently, Resolv::DNS does not use search domains by default. This is, IMHO, broken. Celluloid should use these domains. To repro, you need a domain that is only available via a search domain, not the standard DNS on the system (I'm using Kubernetes) - client is the name of a service in Kubernetes, which is resolvable via the search domains:

[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>]
digitalextremist commented 9 years ago

@ioquatix is the Celluloid::DNS contributor, which I believe Celluloid::IO will be refactored to use. But calling something broken because the default behavior you expect is not how you expect it to be, then expecting a library which uses that dependency to change its behavior per your view? If Resolve::DNS is in fact staying, then I could perhaps see providing access to the configuration so you can set that yourself?

aronchick commented 9 years ago

I believe a user's expected experience is that anything that uses DNS should use the search domains - as curl, wget, and countless other applications do, and is specified in resolv.conf man page:

man resolv.conf

domain Local domain name.
Most queries for names within this domain can use short names relative to the local domain. If no domain entry is present, the domain is determined from the local hostname returned by gethostname(2); the domain part is taken to be everything after the first '.'. Finally, if the hostname does not contain a domain part, the root domain is assumed.

search Search list for host-name lookup.
The search list is normally determined from the local domain name; by default, it contains only the local domain name. This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found. For environments with multiple subdomains please read options ndots:n below to avoid man-in-the-middle attacks and unnecessary traffic for the root-dns-servers. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains are not local, and that queries will time out if no server is available for one of the domains. The search list is currently limited to six domains with a total of 256 characters.

That Resolv::DNS does not do this by default feels like a bad user experience - and cascades down to anything that uses it (including Celluloid - today, anyway).

jgrowl commented 9 years ago

+1 I think it makes a lot of sense to use the search domain.

ioquatix commented 8 years ago

You should discuss this on the Celluloid::DNS issue tracker and feel free to submit a PR.

clonezone commented 8 years ago

I'm able to work around this because all of my current non-fully-qualified domains need the same suffix applied to them. I don't know how I would work around this otherwise.

ioquatix commented 8 years ago

@aronchick @clonezone Let's discuss this on the Celluloid-DNS issue tracker.