← Back to context

Comment by morcus

20 hours ago

> Technically speaking, the top of the DNS tree, the DNS root, is a null label referenced by a trailing dot. It's analogous to the '/' at the beginning of POSIX file paths. "gatech.edu" really should be written as "gatech.edu." to make it absolute rather than relative

I have never seen this, but I just tried it and it seems like browsers, even today will happily handle such URLs.

Neat!

If you work much with DNS, you will know about this. It is known as a FQDN, or a "fully qualified domain name", when the name ends with a .

When you don't use a FQDN, your DNS system is going to try to figure out if you mean a FQDN or actually belong to a subdomain.

On *nix, your /etc/resolv.conf file can have a "search" entries for search domains... that means that a lookup for "foo" will check "foo.bar.com" if "search bar.com" is in your /etc/resolv.conf

This does mean your query could end up making multiple queries to determine if you meant foo. OR foo.bar.com

You can configure how the machine makes the guesses with something called ndots... if you add "ndots 3" to your etc/resolv.conf, then your DNS queries will only try treating the domain as a FQDN if it has at least 3 dots... so for example, it would skip querying for foo as a TLD because it has no dots, and assume you mean "foo.bar.com", saving an unneeded DNS query.

This usually doesn't matter to people, but it can have big performance implications for things like Kubernetes, with lots of .svc.local bits being left off of internal queries and relying on search domains; by increasing the ndots, you avoid a ton of wasted queries.

They need to, as when the "." is not present, your search domains are used, but they are not used when the trailing "." is present.

For example, if you enter "ajdfajkhdfkajd.com", and your search domains contain one item called "mycompany.tld", then the browser will first query DNS servers for "ajdfajkhdfkajd.com.", and when an NXDOMAIN is returned, they will try "ajdfajkhdfkajd.com.mycompany.tld." next. If you type "ajdfajkhdfkajd.com." in the browser directly, only the first query is attempted.

Presumably they just split the “domain” part out of the URL on // and the first / and feed that into getaddrinfo, with the OS and DNS doing the rest?

But I agree, it’s definitely neat :)

> Even today

It's not like it's archaic. You still use the trailing dot when setting up DNS records to ensure they're unambiguous.