5 ms·
Anatomy of a Linux DNS Lookup
- bandie91 5y agomany of you complained that there is no lightweight way on Linux to have different resolvers for different domains/zones (eg. one default and one for your VPN or whatever). see https://github.com/azukiapp/libnss-resolver https://github.com/azukiapp/libnss-resolver - it's an NSS lib just like libnss_dns or libnss_files, which looks up resolv.conf-style files according to the queried domain suffix. it's not a deamon. i integrated it with dhcp client and ifup/down and use it happily for years. disclaimer: i contributed to libnss_resolver.
- deknos 5y agothough the systemd-critique-people/hater have some vlaid points, i nowadays tend to ignore them. most of them do not contribute in building better solutions, which help more people then themselves. just blabbering on and requiring stuff which only works for THEIR usecase. this is really annoying at times.
- JoeyBananas 5y agoI always forget about strace. I'm gonna use that trick
- belter 5y agoFollow up: Anatomy of a Linux DNS Lookup – Part II https://zwischenzugs.com/2018/06/18/anatomy-of-a-linux-dns-lookup-part-ii/ https://zwischenzugs.com/2018/06/18/anatomy-of-a-linux-dns-l... Anatomy of a Linux DNS Lookup – Part III https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-lookup-part-iii/ https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-l... Anatomy of a Linux DNS Lookup – Part IV https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-lookup-part-iv/ https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-l... Anatomy of a Linux DNS Lookup – Part V – Two Debug Nightmares https://zwischenzugs.com/2018/09/13/anatomy-of-a-linux-dns-lookup-part-v-two-debug-nightmares/ https://zwischenzugs.com/2018/09/13/anatomy-of-a-linux-dns-l...
- necovek 5y agoThis does not cover the joy of eg. connecting to multiple networks (different DNS settings) with separate interfaces. Then you can hit DNS request hopping between servers too: https://github.com/systemd/systemd/issues/19209 https://github.com/systemd/systemd/issues/19209
- iso1631 5y agoBefore networkmanager and systemd, pretty much every tool used gethostbyname, which used standard nsswitch which tended to be hosts, then resolv.conf resolv.conf would use the first one, and then timeout and use the next one Nice and simple. The quote "simply turn off systemd-resolved" Is usually the answer, but it's a constant uphill battle to fix broken behaviour. Of course Pottering doesn't care.
- iso1631 5y agoAnd straight away it's a downvote. Pottering, in that thread, literally says "I have the suspicion that this going to negatively affect about as many people as it positively affects..." https://askubuntu.com/questions/907246/how-to-disable-systemd-resolved-in-ubuntu https://askubuntu.com/questions/907246/how-to-disable-system... is a "good" solution to the problem in ubuntu
- necovek 5y agoTo be honest, systemd-resolved actually for the first time provides an option of a solution for this use-case. Properly configured, without CNAMEs involved, it would just do the right thing. Relying on resolv.conf meant using the first one unless it times out, which makes it impossible for me to connect to two private networks with their own hostname resolution, if a hostname resolves in both but to different addresses.
- iso1631 5y agoBut how can you do that unless you are saying "map this .foo.com to resolver A, and map .bar.com to resolver B". You have an option to install dnsmasq or whatever resolver you want for that very unusual use case without installing tons of more bloated demons on machines that simply don't need it. 99% of linux machines are not laptops connecting to multiple networks with private DNS servers, they have static network configurations, or a single network connection with dhcp. Of the rest, most are laptops, and sure you want some form of gui selection to choose your wireless network, and maybe even set up your vpns, but that's such a rare case. Also remember that private DNS servers are on the way out now on a desktop, with DoH being embedded at the browser layer, so this tiny use case will shrink even more. by all means have a "yum install dns-multipathd" or whatever as a resolver to solve this problem on the 1 in a thousand machines it helps on, but why have any software installed and listening on port 53 by default? Seems a needless security risk to me
- tyingq 5y agoThis predates systemd's decision to get involved via systemd-resolved. So now it's got another step :) Edit: Well, and also browsers doing DNS over https. It's pretty confusing these days to know which path your app took to resolve a name.
- mike_d 5y agoWhich is super annoying when you actually want to run a DNS server and have to try and convince systemd-resolved to stay in its own lane.
- westurner 5y agoIs there a good example of a Linux package that does this correctly?
- tyingq 5y agoI suspect the big part is putting "DNSStubListener=no" into the [Resolve] section of /etc/systemd/resolved.conf if you want to have something else listening on port 53.
- jakobdabo 5y agoOr you can just mask the service (better than disabling): systemctl mask systemd-resolved.service Other services to consider masking if you are not using SystemD for network configuration and time sync., etc.: systemctl mask systemd-hostnamed.service systemctl mask systemd-timesyncd.service systemctl mask systemd-networkd.service systemctl mask systemd-homed.service
- westurner 5y agoYeah, but if you regress to 'legacy DNS' by removing systemd-resolved then there's no good way to do per-interface DNS (~client-split DNS), or (optionally) validate DNSSEC, or do DoH/DoT; and then nothing respawns and logs consistently-timestamped process events of substitute network service processes. FWIU, per-user DNS configs are still elusive. Per-user DNS would make it easier to use family-safe DNS (that redirects to family-safe e.g. SafeSearch domains) by default; some forums are essential for system administration.
- andred14 5y agoWe all know now that NASA lied about going to the moon so what else are they lying about???
- Pirate-of-SV 5y agoIn Kubernetes you can also add NodeLocal DNSCache [1] as a DaemonSet that injects iptable rules to cache DNS locally to offload the in-cluster coredns. [1] https://kubernetes.io/docs/tasks/administer-cluster/nodelocaldns/ https://kubernetes.io/docs/tasks/administer-cluster/nodeloca...
- mr-wendel 5y agoNot to be overlooked on this topic is this wonderful Tailscale blog entry: https://tailscale.com/blog/sisyphean-dns-client-linux/ https://tailscale.com/blog/sisyphean-dns-client-linux/ and corresponding HN: https://news.ycombinator.com/item?id=26821298 https://news.ycombinator.com/item?id=26821298 * disclaimer: I have no affiliation w/ Tailscale. I just wish I did.
- economusty 5y agoI recently had to circumvent the systemd resolvd auto config for dns it would randomly fail.
- iso1631 5y agoQuite normal - https://askubuntu.com/questions/907246/how-to-disable-systemd-resolved-in-ubuntu https://askubuntu.com/questions/907246/how-to-disable-system... for example
- gtsop 5y agoI actually went on to read this whole series a few months ago in search of what was wrong with some networking configuration I had at home. To no fault of the author, I felt like I trully learned a ton about DNS but couldn't apply that knowledge to solve my problem since ubuntu has added more stuff on top of these. I feel like the DNS situation is way too complicated, I really don't even know where the tunnel ends anymore. I resulted to using the GUI and hope it handles everything, which I hate because I want to understand what's happening under the hood. I felt powerless
- monkaiju 5y agoFor anyone trying to keep tabs on their dns propagation, check out dug! https://github.com/unfrl/dug https://github.com/unfrl/dug https://dug.unfrl.com https://dug.unfrl.com