Safari忽略了macOS High Sierra上的/ etc/hosts

dnn*_*agy 6 safari macos hosts

我试图使用/etc/hosts文件将一些网站重定向到localhost.为此,我在终端中打开它sudo nano /etc/hosts然后我修改了文件,并保存了它.作为最后一步,我刷新了DNS缓存sudo killall -HUP mDNSResponder.

这是我的hosts文件的样子:

$ 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 somethig.com
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Run Code Online (Sandbox Code Playgroud)

这根本行不通.我试图重新启动,没有运气.我也做了很多研究,但没有在互联网上找到任何有效的答案.操作系统是否仍然使用此文件,或者这从未真正起作用?

我正在使用macOS 10.13.

Mas*_*Lee 1

我相信您还需要覆盖“something.com”的 IPv6 地址。通过添加附加行“::1 somethig.com”来完成此操作。据我所知,还需要重新启动 Safari。(您可能还需要通过您提到的方法刷新 DNS 缓存。)