macos 清空dns缓存_如何在macOS上重置DNS缓存

macos 清空dns缓存_如何在macOS上重置DNS缓存_第1张图片

macos 清空dns缓存

macos 清空dns缓存_如何在macOS上重置DNS缓存_第2张图片

If you work on websites, you’ll occasionally need to reset your computer’s DNS cache, particularly after editing records or changing hosts. While flushing the DNS cache on Windows is easy with a dedicated command, Mac users have to use a bit of a workaround.

如果您在网站上工作,则偶尔需要重置计算机的DNS缓存,尤其是在编辑记录或更改主机之后。 尽管使用专用命令很容易在Windows上刷新DNS缓存 ,但Mac用户必须使用一些解决方法。

清除Mac上的DNS缓存 (Clear Your DNS Cache on Your Mac)

To clear your DNS cache on your Mac, open the Terminal, which you can find in Applications > Utilities or by searching with Spotlight, and then run the following command:

要清除Mac上的DNS缓存,请打开“终端”,您可以在“应用程序”>“实用工具”中找到该终端,或者通过使用Spotlight搜索,然后运行以下命令:

sudo killall -HUP mDNSResponder

Enter your password when it’s requested.

要求时输入密码。

So, what does this command actually do? What’s happening here is that you’re kind of tricking your system into flushing the cache. Wikipedia explains:

那么,此命令实际上是做什么的? 这里发生的事情是您在欺骗您的系统以刷新缓存。 维基百科解释:

The SIGHUP signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop (a hangup). In modern systems, this signal usually means that the controlling pseudo or virtual terminal has been closed. Many daemons will reload their configuration files and reopen their logfiles instead of exiting when receiving this signal. nohup is a command to make a command ignore the signal.

当SIGHUP信号的控制端子关闭时,它会发送到进程。 它最初旨在通知串行线掉线(挂断)过程。 在现代系统中,此信号通常意味着控制伪或虚拟终端已关闭。 许多守护程序将重新加载其配置文件并重新打开其日志文件,而不是在收到此信号时退出。 nohup是使命令忽略信号的命令。

Obviously you don’t need to know all of the rest of that. But now you do.

显然,您不需要了解所有其他内容。 但是现在你知道了。

There’s a lot of conflicting information on the web about this procedure. Some sites claim you need to run more commands than this on High Sierra, for example, while others make this command unnecessarily long. So far as we can tell, however, the command above is all that’s actually necessary. Here’s how to check your work.

网络上有很多与此过程有关的信息。 例如,某些站点声称您需要在High Sierra上运行比此命令更多的命令,而其他站点则使此命令不必要地冗长。 据我们所知,上面的命令实际上是必需的。 这是检查工作的方法。

检查您的DNS是否实际重置 (Check if Your DNS Is Actually Reset)

Not sure if your DNS reset actually worked? Closing your web browser before flushing the cache can help in some situations, but if that doesn’t seem to be working you can quickly verify that your cache is empty in two ways.

不确定您的DNS重置是否真的有效? 在刷新缓存之前先关闭Web浏览器在某些情况下会有所帮助,但是,如果这似乎不起作用,则可以通过两种方式快速验证缓存是否为空。

The first is site-specific. At the Terminal, type dig followed by the site’s URL. For example:

首先是特定于站点的。 在终端上,键入dig然后键入站点的URL。 例如:

dig howtogeek.com

In the “Answer Section” of the results, you’ll see the IP address that your computer knows for the site listed.

在结果的“答案”部分,您将看到您的计算机为列出的站点所知道的IP地址。

If you don’t see the new IP address, consider changing DNS settings on your Mac and flushing the cache again.

如果没有看到新的IP地址,请考虑在Mac上更改DNS设置,然后再次刷新缓存。

For a more global (non site-specific) method, you can also confirm that the cache is reset with the Console, which you can find in Applications > Utilities or by using Spotlight. With your system highlighted in the left panel, type “mDNSResponder” into the search box, hit Enter, type “Cache size” alongside that first query, and then hit Enter again. Like this:

对于更全局(非特定于站点)的方法,您还可以通过控制台确认缓存已重置,可以在“应用程序”>“实用程序”中或使用Spotlight找到该控制台。 在左侧面板中突出显示系统的情况下,在搜索框中键入“ mDNSResponder”,按Enter,在第一个查询旁边键入“ Cache size”,然后再次按Enter。 像这样:

macos 清空dns缓存_如何在macOS上重置DNS缓存_第3张图片

Now, with your Console window still open, head back to your Terminal window and run the following command:

现在,在“控制台”窗口仍然打开的情况下,返回到“终端”窗口并运行以下命令:

sudo killall -INFO mDNSResponder

You should see the DNS Cache size highlighted in the Console window. Now run this command:

您应该看到控制台窗口中突出显示的DNS缓存大小。 现在运行以下命令:

sudo killall -HUP mDNSResponder

And then, run this command once again:

然后,再次运行此命令:

sudo killall -INFO mDNSResponder

You should see the cache size change in the Console window. In the screenshot above, you can see that our cache size changed considerably after issuing the commands.

您应该在“控制台”窗口中看到缓存大小更改。 在上面的屏幕截图中,您可以看到发出命令后,我们的缓存大小发生了很大变化。

翻译自: https://www.howtogeek.com/180356/how-to-reset-the-dns-cache-on-mac-os-x/

macos 清空dns缓存

你可能感兴趣的:(java,linux,python,mac,网络)