He configurado DNSmasq localmente para traducir todos los *.localhost
solicitudes a 127.0.0.1
(según el ahora caducado Proyecto de RFC let-localhost-be-localhost
).
Estoy ejecutando DNSmasq en un puerto no estándar (para no colisionar con multipass
):
18411 ?? Ss 0:00.03 /nix/store/qv29whm9sdfwbxpsysjdiki6z0rylabv-dnsmasq-2.82/bin/dnsmasq --listen-address=127.0.0.1 --port=35353 --keep-in-foreground --address=/localhost/127.0.0.1
Que se ejecuta utilizando Launchd:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>org.nixos.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/nix/store/qv29whm9sdfwbxpsysjdiki6z0rylabv-dnsmasq-2.82/bin/dnsmasq</string>
<string>--listen-address=127.0.0.1</string>
<string>--port=35353</string>
<string>--keep-in-foreground</string>
<string>--address=/localhost/127.0.0.1</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/dnsmasq.log</string>
</dict>
</plist>
El /etc/resolver/localhost
contener:
nameserver 127.0.0.1.35353
scutil --dns
devuelve la entrada para localhost
TLD:
DNS configuration
resolver #1
search domain[0] : srebrna.space
nameserver[0] : 192.168.188.199
if_index : 6 (en0)
flags : Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
resolver #2
domain : local
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300000
resolver #3
domain : 254.169.in-addr.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300200
resolver #4
domain : 8.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300400
resolver #5
domain : 9.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300600
resolver #6
domain : a.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300800
resolver #7
domain : b.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 301000
resolver #8
domain : localhost
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
DNS configuration (for scoped queries)
resolver #1
search domain[0] : srebrna.space
nameserver[0] : 192.168.188.199
if_index : 6 (en0)
flags : Scoped, Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
Pero no puedo resolverlo:
$ host test.localhost
Host test.localhost not found: 3(NXDOMAIN)
Incluso cuando la consulta de DNSmasq devuelve directamente la respuesta correcta:
$ dig -p 35353 @127.0.0.1 test.localhost
; <<>> DiG 9.10.6 <<>> -p 35353 @127.0.0.1 test.localhost
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18207
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test.localhost. IN A
;; ANSWER SECTION:
test.localhost. 0 IN A 127.0.0.1
;; Query time: 0 msec
;; SERVER: 127.0.0.1#35353(127.0.0.1)
;; WHEN: Mon Jan 25 14:23:47 CET 2021
;; MSG SIZE rcvd: 59
Mi sistema es Big Sur 11.1
Darwin 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64 i386