Figured out how to get anything.lan (including foo.bar.lan etc) to resolve to 127.0.0.1 on my Mac laptop, using dnsmasq installed from Homebrew https://til.simonwillison.net/macos/wildcard-dns-dnsmasq
Local wildcard DNS on macOS with dnsmasq

I wanted to get wildcard DNS running on my Mac laptop, for development purposes. I wanted http://anything.mysite.lan/ to point to my localhost IP address.

... and it turns out that's not necessary at all, because `foo.bar.localhost` resolves to `127.0.0.1` on macOS (and Linux) out of the box!
@simon well crikey, it does on Ubuntu too. TIL, indeed
@simon .... 😲... well... that... might save a lot of tweaks to my /etc/hosts thanks!
@simon pro tip: don't use `.lan`, use `.lan.<your-domain>` so you can provision HTTPS certificates for it.
@glyph whoa... so I could buy myself a wildcard certificate for a domain, and then use subdomains of that on my own local machine!?
@simon I used to maintain a tool for this, but I archived it because with the DNS challenge you can just do it with certbot out of the box
@simon no need to have wildcard certs either, if you don't mind writing code like this ;-) https://github.com/twisted/twisted/pull/11861/files
[#9885] add `tls:` server endpoint that supports SNI, PEM parsing, and supporting code that changes OpenSSL connection/context building by glyph · Pull Request #11861 · twisted/twisted

Scope and purpose Fixes #9885 This also makes it possible to do twist web --path whatever --listen=tls:path/to/certbot/config/live if path/to/certbot/config/live is a directory containing .pem file...

GitHub
@simon but yes I've been developing against real, public certs on my local machine since 2015

@simon Uhhhh…

$ python3 -c 'import socket; print(socket.getaddrinfo("foo.bar.localhost", 0))'

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

socket.gaierror: [Errno 8] nodename nor servname provided, or not known

@glyph
.localhost is a feature of *chrome* and nothing else (not even other browsers, as far as I can tell.)
@simon
@simon local.computer should work, too. So does foo.bad.local.computer.