简体   繁体   English

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

[英]Safari ignores /etc/hosts on macOS High Sierra

I tried to use /etc/hosts file to redirect some websites to localhost. 我尝试使用/etc/hosts文件将一些网站重定向到localhost。 To do so, I opened it in terminal using sudo nano /etc/hosts then I modified the file, and saved it. 为此,我使用sudo nano /etc/hosts在终端中打开它,然后我修改了文件并保存了它。 As the last step I flushed the DNS cache with sudo killall -HUP mDNSResponder . 作为最后一步,我使用sudo killall -HUP mDNSResponder刷新了DNS缓存。

Here's what my hosts file looks like: 这是我的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

This simply doesn't work. 这根本行不通。 I tried to reboot, without luck. 我试图重新启动,没有运气。 I also did a lot of research but did not find any working answers on the internet. 我也做了很多研究,但没有在互联网上找到任何有效的答案。 Does the OS still use this file, or will this never really work? 操作系统是否仍然使用此文件,或者这从未真正起作用?

I'm using macOS 10.13. 我正在使用macOS 10.13。

I believe that you need to also override the IPv6 address for "something.com". 我相信您还需要覆盖“something.com”的IPv6地址。 Do this by adding the additional line "::1 somethig.com". 通过添加额外的行“:: 1 somethig.com”来完成此操作。 So far as I can figure out, restarting Safari is also required. 据我所知,还需要重新启动Safari。 (You may also need to flush the DNS cache via the method you mentioned.) (您可能还需要通过您提到的方法刷新DNS缓存。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM