我的 Mac(Mojave 10.14)无法访问任何带有.dev域名,例如获取.dev。我尝试运行$ ping get.dev
并得到以下输出:
PING get.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.044 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.161 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.070 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.166 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.189 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.056 ms
^C
--- get.dev ping statistics ---
6 packets transmitted, 6 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.044/0.114/0.189/0.059 ms
我知道重新映射到本地主机很流行.dev
,我想我可能在过去的某个时候做过这件事,然后就忘了。然而,当我运行$ cat /etc/hosts
:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
我不确定在哪里可以继续解决此问题。还有其他hosts
文件可以添加其他条目吗?
编辑:我的 DNS 设置为使用 1.1.1.1,根据他们的指示。
编辑:下面进行更多故障排除。
$ dig get.dev
:
; <<>> DiG 9.10.6 <<>> get.dev
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58743
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;get.dev. IN A
;; ANSWER SECTION:
get.dev. 300 IN A 216.239.32.29
;; Query time: 44 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Wed May 15 14:35:46 CEST 2019
;; MSG SIZE rcvd: 52
curl -v get.dev
:
* Rebuilt URL to: get.dev/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connection failed
* connect to 127.0.0.1 port 80 failed: Connection refused
* Failed to connect to get.dev port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to get.dev port 80: Connection refused
当返回 216.239.32.29 时为什么要curl
尝试 127.0.0.1 dig
?
答案1
运行scutil --dns
并检查是否发现类似如下的内容:
There was entry:
resolver #8
domain : dev
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
如果是这种情况你可以运行rm -f /etc/resolver/dev
来删除它