Hacker News new | ask | show | jobs
by amckinlay 2949 days ago
.local is used ad-hoc by mDNS (Apple). Last time the issue of naming local-area devices came up on ##networking, the consensus was to purchase a domain name in order to name local network devices without interfering with global name resolution standards, which seems ridiculous.
2 comments

That's the Microsoft recommendation. I think they're suggesting to use either split-view DNS (i.e., have DNS respond with internal vs external results depending on the source address of the requestor) or use a subdomain for internal hosts (e.g., corp.example.com). I don't think they mean to just buy a public domain and only use it internally.

I hope ...

I think you can use .localhost freely.
.localhost is the loopback IP on most resolvers, though.
"localhost" by itself is, but second-level domains (ex.: laptop.localhost) aren't, at least not anywhere I've tried it.
In a well-configured machine second-level domains for .localhost are also supposed to loopback, per the RFC.

(It's useful as a development tool as you can Virtual Host project1.localhost and project2.localhost to different in development sites if your OS and server support it, which tend to be in similar ways to how they generally support Virtual Hosts.)

RFC6761 says:

6.3. Domain Name Reservation Considerations for "localhost."

   The domain "localhost." and any names falling within ".localhost."
   are special in the following ways:

   1.  Users are free to use localhost names as they would any other
       domain names.  Users may assume that IPv4 and IPv6 address
       queries for localhost names will always resolve to the respective
       IP loopback address.
[...]

   3.  Name resolution APIs and libraries SHOULD recognize localhost
       names as special and SHOULD always return the IP loopback address
       for address queries and negative responses for all other query
       types.  Name resolution APIs SHOULD NOT send queries for
       localhost names to their configured caching DNS server(s).
And goes on to specify how resolvers, authoratitive DNS servers, registrars, etc. should behave.

This is implemented on my machine at least by systemd_resolved, see https://github.com/systemd/systemd/blob/master/src/resolve/r... which returns ::1/127.0.0.1 for any record for which which is_localhost is true (defined in https://github.com/systemd/systemd/blob/master/src/basic/hos...).