Some ways DNS can break
jvns.ca
jvns.ca
We've come a long way from good ole fashioned libc/glibc acting as a good ole fashioned stub resolver on my UNIX system. Is systemd even looking at /etc/resolv.conf anymore? Who is overwriting /etc/resolv.conf? Is the information provided via DHCP being ignored? Is Firefox using DoH? Where is caching happening? How do I clear it?
All of these questions have completely different answers depending on OS and how they're configured. I work with OSX, Debian, Redhat and OpenBSD on the regular and they all have different answers for the above questions.
This does my nut in too - even just narrowing the Q down to modern Linux Desktops with e.g. chrome/firefox, and I have absolutely no idea what the query path is. So many components have been added to the path over the last few years :(
echo 'nameserver 127.0.0.1' > /etc/resolv.conf
chattr +i /etc/resolv.conf
You can thank me later.So you essentially block any program trying to write it?
The only option is to replace the "execute this when DHCP reply is recieved" script, which is not a simple script at all. And then you're stuck three-way-merging your changes to that script with every security update.
So now I have a job that watch for that and does a bind mount to make everything work.
Yes, when debugging host name resolution for a specific host, don’t use dig; use “getent hosts <name>”. This will use the normal configured host name resolution path. (Personally I use "getent ahosts <name>" to get both IPv6 and IPv4 addresses.)
I can find no reference to this, nor does nslookup do that on my system. Maybe on Windows, its “nslookup” (which is not the real Unix nslookup) command does this?
In particular, note the following quote: “Unlike dig, nslookup does not use the operating system's local Domain Name System resolver library to perform its queries, and thus may behave differently. Additionally, vendor-provided versions may include output of other sources of name information, such as host files, and Network Information Service. Some behaviors of nslookup may be modified by the contents of resolv.conf.[2]”
Someone has configured a delegation loop. (Yep, been there more than once)
Records are currently unavailable, but someone has busted the cache. (Enjoy)
All services wait for the same DNS record to be fetched and will all ask the same service at exactly the time when DNS is done. (Again, clear yes, happens. That's why you should use prefetch)
No one knows how to handle DNS SRV priority correctly (please correct me if I am wrong).
dig . axfr @iad.xfr.dns.icann.org
and I received 24,448 records transferred over 83 DNS messages, according to the stats dig prints at the end.[1] https://datatracker.ietf.org/doc/html/rfc5936#section-2.2
I am curious how did you get there given the length field in DNS records is only 16 bits?
The standard[1] doesn’t show it was obsoleted by anything else.
-- Jeff Waugh
Continuing the example in the article, use `google.com.` and there will be just one query.
Using a FQDN (as in, a DNS name with the trailing dot) is the only reliable way to avoid this without breaking other things!
Curl has gone back and forth; dunno whether that is curl itself or the resolver libs. Firefox used to be broken, and may still be.
Apache used to almost blow chunks when it got one of these, and I filed a bug (https://bz.apache.org/bugzilla/show_bug.cgi?id=58007); the chosen fix was to serve some "random" cert. Just tried it with an older version of FFX which I know is borked though and it did the right thing, so presumably something further has occurred since 2017.
Not entirely sure which is doing the right thing by the spec here, but I much prefer the browser behavior, because I would really like to not have to add a hosts entry for everything I reverse proxy from Caddy for doing local HTTPS/HTTP2 development for production parity.
Oh, and I also found out that Node also isn't able to use the system-wide certs store (which local HTTPS in Caddy adds to) [1], so in the end even adding a hosts entry didn't work, and I had to revert to plaintext HTTP1. Deno is looking more attractive every day [2]. Too bad I can't use it for building VSCode extensions.
Really curious to hear how other folks are doing local HTTPS/HTTP2 setups in node these days.
I think that's the browsers making names up. No system resolvers I've seen respond to an x.localhost lookup.
I generally have a wildcard setup on an internal domain for generic local names (*.local.me)
> Node also isn't able to use the system-wide certs store
Node can use the `NODE_EXTRA_CA_CERTS` environment variable to add a file of one or more PEM trusted certificates at launch.
https://nodejs.org/dist/latest-v16.x/docs/api/cli.html#node_...
Fair enough, I guess I just wish node would behave more like a browser in this case then, as it'd have saved me a lot of headache.
> I generally have a wildcard setup on an internal domain for generic local names (*.local.me)
Curious how you set that up? Hosts files don't allow wildcards afaik, and that's what I've been struggling with.
> Node can use the `NODE_EXTRA_CA_CERTS` environment variable to add a file of one or more PEM trusted certificates at launch.
I actually tried this option briefly but couldn't get it to work, at least not with the root cert that Caddy generated. I would much prefer a `NODE_USE_SYSTEM_CERTS` option that doesn't require pointing to any specific paths though, as there's less room for misconfiguration, which I can't rule out in my case.
Via a DNS server we run, that then answers for local things or forwards requests on to the real world.
To do that locally, set up a DNS forwarder like dnsmasq [0] or unbound [1] (or coredns/bind/etc) to respond for the domain you want to wildcard to localhost. Point your OS DNS settings to 127.0.0.1, then configure the forwarder with your regular external DNS servers.
The equivalent to `NODE_USE_SYSTEM_CERTS` is a build time option unfortunately. I know the rhel/debian packages do integrate their builds with the system CA's but those packages tend to be ancient. Maybe try the nodesource [2] packaged node.js? The homebrew node formulae [3] looks like it integrates with the brew openssl CA's.
[0] https://stackoverflow.com/a/22551303
[1] https://unbound.docs.nlnetlabs.nl/en/latest/manpages/unbound...
[2] https://github.com/nodesource/distributions
[3] https://github.com/Homebrew/homebrew-core/blob/c2579d98415bd...
That said, you are free to create "<poop>.example.com", presuming you own example.com. Indeed, "`rm -rf *`.example.com" is a valid FQDN according to the DNS (protocol) as opposed to The DNS (implementation).
>problem: Java caching DNS records forever
SimpleResolver resolver = new SimpleResolver("8.8.8.8");
Name name = new Name(host + ".");
Record a = Record.newRecord(name, Type.A, DClass.IN);
Message query = Message.newQuery(a);
Message response = resolver.send(query);
Record[] answers = response.getSectionArray(Section.ANSWER);- this happened to me on two arch linux installations for different domains - I was unable to debug this - would love to somehow get this fixed but I switched to dnsmasq that works fine for me.