它在旧配置中工作了一段时间,但由于某种原因停止工作。
这是我的 Mountain Lion MacBook Air 中的 /etc/hosts 文件:
127.0.0.1 reddit.com www.reddit.com
127.0.0.1 facebook.com www.facebook.com
##
# 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
fe80::1%lo0 localhost
Run Code Online (Sandbox Code Playgroud)
这会阻止 Reddit,但不会阻止 Facebook。
我试过刷新机器的 DNS 缓存(“sudo killall -HUP mDNSResponder”),浏览器(FF 和 Chrome),我试过重新启动计算机。
我已经按照本文的建议将条目移到文件的顶部,但之前它在底部时也不起作用。每次它都会阻止 Reddit 但不会阻止 Facebook。
(这个问题在 10.7.1 更新中消失了 - /etc/hosts 现在对我来说一如既往地工作)
我已经将我的 Mac 更新为 Lion,现在我注意到 /etc/hosts 是最后查询的,即使在 DNS 之后也是如此。这很烦人,因为我有很多用于开发的主机名。
名称解析顺序在哪里配置?我可以使用 dscacheutil 检查它,所以这是雪豹机器告诉我的:
pilif@tali ~ % dscacheutil -configuration
DirectoryService Cache search policy:
/Local/Default
/BSD/local
Settings:
AAAA Queries - Disabled (link-local IPv6 addresses)
Default TTL - 3600
Policy Flags - 0
Run Code Online (Sandbox Code Playgroud)
这是狮子告诉我的
pilif@kosmos ~ % dscacheutil -configuration
DirectoryService Cache search policy:
/Local/Default
Unable to get details from the cache node
Unable to get cache configuration information
Run Code Online (Sandbox Code Playgroud)
除了这两个错误之外,我认为 /BSD/Local 是让它更早读取 /etc/hosts 的原因。
有没有人知道这个“缓存搜索策略”的存储位置以及如何将其更改回来?
我知道我可以使用 dcsl 创建主机名条目,但我真的很想保留我在各种机器上使用的 /etc/hosts。
更新:解析顺序显然可以在目录实用程序中配置。不幸的是,此安装 …