←back to thread

.localhost Domains

(inclouds.space)
301 points todsacerdoti | 2 comments | | HN request time: 0.468s | source
Show context
lima ◴[] No.43644434[source]
On my Linux machine with systemd-resolved, this even works out the box:

  $ resolvectl query foo.localhost
  foo.localhost: 127.0.0.1                       -- link: lo
                 ::1                             -- link: lo
Another benefit is being able to block CSRF using the reverse proxy.
replies(1): >>43644518 #
1. jchw ◴[] No.43644518[source]
Yeah, I've been using localhost domains on Linux for a while. Even on machines without systemd-resolved, you can still usually use them if you have the myhostname module in your NSS DNS module list.

https://www.man7.org/linux/man-pages/man8/libnss_myhostname....

(There are lots of other useful NSS modules, too. I like the libvirt ones. Not sure if there's any good way to use these alongside systemd-resolved.)

replies(1): >>43648115 #
2. aib ◴[] No.43648115[source]
I ended up writing a similar plugin[1] after searching in vain for a way to add temporary DNS entries.

The ability to add host entries via an environment variable turned out to be more useful than I'd expected, though mostly for MITM(proxy) and troubleshooting.

1: https://github.com/aib/nss-userhosts