mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #250] Use nsswitch.conf on Linux or document that it isn't used #415
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#415
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @briansmith on GitHub (Oct 24, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/250
One advantage of nsswitch.conf, IIUC, is that it can control whether /etc/hosts is read and/or whether DNS servers are used at all. I don't know if it is worthwhile to support it. If it isn't deemed worthwhile then it should be documented as part of #249 as a different from glibc.
@briansmith commented on GitHub (Oct 24, 2017):
FWIW, I don't have an immediate need for this, AFAICT. I just filed it for completeness sake as I was auditing the code.
@bluejekyll commented on GitHub (Oct 26, 2017):
I think it's just
hostswhere this is relevant, right?@rumpelsepp commented on GitHub (May 31, 2018):
nsswitch.conf is also relevant for mdns.
@bluejekyll commented on GitHub (May 31, 2018):
I think the big issue here is that we've incorporated
/etc/hostsfile lookup as part of the project, and that's just one part of the picture as it relates tonsswitch.conf.nsswitch.confhas a number of rules, and while some are applicable to DNS, others are not. I don't know what it would look like to support this, and I wonder if what we really need to do is move things to a higher level (i.e. something else that managesnsswitchand calls out to the resolver and others as necessary).mdns still has some known issues in trust-dns, beyond configuration as well.
@rumpelsepp commented on GitHub (May 31, 2018):
yep. Sry for digging out this issue, I was just reading through the issue tracker and dumped a thought.
nsswitch.conf is a complex beast, since it is extendable I fear there is no generic way to support this properly and completely in pure TRust-DNS.
IMO this would be pretty much the same as duplicating
std::net::ToSocketAddrson a TRust-DNS level. The problem is, that the intention ofnsswitch.confis the other way round: TRust-DNS can be part of the call chain innsswitch.confinstead of being a reimplementation of that "higher level":So, the only way to get it right would be creating nss-plugins using TRust-DNS and let
glibcdo thensswitch.confmagic. That's how systemd does it with its magic systemd-resolved crap. If everything is configured properly, then TRust-DNS would be called automatically when some program callsstd::net::ToSocketAddrs. The/etc/hostslookup can then be omitted in TRust-DNS.I think about something like this:
@bluejekyll commented on GitHub (May 31, 2018):
Thanks for that! I'm always thinking in the context of usage internally in Rust projects, not as system config option. This is a great idea. We should do that. It's somewhat related to #483, as we'd need that first.
@briansmith commented on GitHub (May 31, 2018):
Also, I think some projects probably are using Trust-DNS at least in part specifically to avoid that stuff.
IMO, nsswitch.conf processing should be done in some higher-layer crate that uses Trust-DNS as a dependency.
Perhaps that should have been done for
/etc/hostsand the Windows equivalent too, though I think that extant functionality isn't as problematic as nsswitch.conf so IMO it shouldn't be a priority to take it out.@msehnout commented on GitHub (Jun 1, 2018):
What would be the advantage here? Would you like to implement Trust-DNS support directly into glibc?
I'm using Unbound as a local resolver and I simply lock my
/etc/resolv.confto prevent NetworkManager from writing to it. This way I can keep nsswitch untouched.glibc contacts Unbound whenever it wants to resolve some name.
@rumpelsepp commented on GitHub (Jun 1, 2018):
The advantage is you don't violate layers. Your example with
/etc/resolv.confis only valid for thednsentity innsswitch.conf.No. You only need an nss plugin, that can be written in rust with some linker flags.
You can just enable unbound in the NetworkManager config, this way NetworkManager can notify unbound when you enable VPN etc. Locking
/etc/resolv.confviachattris not a good idea (I assume you meanchattr +iby "locking"). SeeNetworkManager.conf(5), search forunbound.The main problem here in this issue is, that resolving via
/etc/hostsnormally is triggered via thefilesbackend innsswitch.conf(5)(see FILES section). TRust-DNS reads/etc/hostsas well.Let's assume you use some TRust-DNS resolver binary from #483, listening on
127.0.0.1. When you putnameserver 127.0.0.1into/etc/resolv.conf, the following happens when a program callsgetaddrinfo(3); this hosts line is innsswitch.conf:/etc/hosts, this fails, the chain continues.*.local. If it is not a*.locallookup, the chain continues./etc/hostsagain. Make DNS requests, ...The admin is free to disable lookups via
/etc/hostssystem widely by removing the files entry. But TRust-DNS would happily continue reading/etc/hosts. So the right place to configure the host lookup backends for the whole system isnsswitch.conf.To integrate into this mechanism nss-plugins with limited scope can be provided and will be picked up by glibc. Since glibc provides a well defined interface this plugins can be written in any language which is C ABI compatible (rust can).
To sum up, @msehnout your example with
/etc/resolv.confmakes complete sense, when your resolver only does DNS. When you start mixing things up (/etc/hosts, mDNS, ...), it will cause problems for admins who alternsswitch.conffor whatever reasons (one could e.g. store hostnames in some database instead).Here is a nss plugin in rust, which can be used to steal some ideas: https://github.com/outlook/libnss-aad
@msehnout commented on GitHub (Jun 1, 2018):
That was my point actually. I think we should do only DNS. Let the standard mechanism for hosts lookup handle the files.
Regarding the unbound section in NetworkManager.conf(5), that is exactly what I am using, but the whole architecture of NetworkManager -> dnssec-trigger -> Unbound is a mess. I'd like to use trust-dns as a replacement and connect it directly to NetworkManager via D-Bus, but first I need the standalone resolver.
@rumpelsepp commented on GitHub (Jun 1, 2018):
Ok, sry for assuming you do some
chattrmess. I have seen this in the wild a few times...