DNS is used to translate between a human-readable name like poftut.com
and IP address like 45.79.1333.118
. DNS can use both UDP and TCP protocols but generally, UDP protocol is preferred. In this tutorial, we will learn how to flush, clear the DNS cache with ipconfig /flushdns
command. This tutorial can be applied to the All Windows Operating system versions like Windows XP, Windows 7, Windows 8, Windows 10, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows Server 2016, Windows Server 2019 without a problem. This will not require special privileges like Administrator.
DNS用于在易于poftut.com
名称(例如poftut.com
和IP地址(例如45.79.1333.118
之间进行转换。 DNS可以同时使用UDP和TCP协议,但通常首选UDP协议。 在本教程中,我们将学习如何使用ipconfig /flushdns
命令刷新,清除DNS缓存。 本教程可以毫无问题地应用于所有Windows操作系统版本,例如Windows XP,Windows 7,Windows 8,Windows 10,Windows Server 2003,Windows Server 2008,Windows Server 2012,Windows Server 2016,Windows Server 2019。 这将不需要管理员等特殊特权。
什么是DNS缓存? (What Is DNS Cache?)
For every domain name, DNS will query the DNS Server normally. But this may create a bottleneck in busy times. In order to prevent this bottleneck, DNS services use a cache mechanism. Learned DNS records are stored in a cache for some time. If during this period a DNS is queried cache returns if exists.
对于每个域名,DNS都会正常查询DNS服务器。 但这可能会在繁忙时期造成瓶颈。 为了防止出现此瓶颈,DNS服务使用缓存机制。 学习到的DNS记录会在缓存中存储一段时间。 如果在此期间查询DNS,则如果存在则返回缓存。
打印并列出当前的DNS缓存条目 (Print and List Current DNS Cache Entries)
We can print or list currently cached DNS entries with the /displaydns
option of ipconfig
command.
我们可以使用ipconfig
命令的/displaydns
选项打印或列出当前缓存的DNS条目。
> ipconfig /displaydns

As we can see from screenshot domain names are stored in DNS cache with related information. There is the following information
从屏幕截图中可以看到,域名与相关信息一起存储在DNS缓存中。 有以下信息
- Record Name specifies the name of the DNS record记录名称指定DNS记录的名称
- Record Type specifies the type of DNS entry记录类型指定DNS条目的类型
- Time To Live provides the validity time of the DNS entry生存时间提供DNS条目的有效时间
- Data Length资料长度
- Section部分
使用ipconfig / flushdns命令刷新DNS条目(Flush DNS Entries with ipconfig /flushdns Command)
In order to clear this DNS cache, we will use ipconfig
command with /flushdns
parameter. This will remove all DNS entries except localhost
because it is a local system DNS record.
为了清除此DNS缓存,我们将使用带/flushdns
参数的ipconfig
命令。 这将删除除localhost
以外的所有DNS条目,因为它是本地系统DNS记录。
> ipconfig /flushdns

We can see that flush is completed successfully from the screenshot.
从屏幕截图中我们可以看到刷新成功完成。
从运行框中清除DNS缓存 (Flush DNS Cache From Run Box)
In the previous example, we have used a command line which is named cmd.exe
. We can also run ipconfig /flushdns
command from Run
like below. This will open a command line and run the command to clear and delete all DNS cache entries. Then the command line will be closed automatically.
在前面的示例中,我们使用了名为cmd.exe
的命令行。 我们也可以像下面这样从Run
运行ipconfig /flushdns
命令。 这将打开命令行并运行命令以清除和删除所有DNS缓存条目。 然后命令行将自动关闭。

检查DNS缓存条目是否刷新(Check DNS Cache Entries Whether Flushed)
We can check whether flush is effective with the ipconfig /displaydns
command again like below.
我们可以再次使用ipconfig /displaydns
命令检查刷新是否有效,如下所示。
> ipconfig /displaydns

As we can see other DNS entries are deleted successfully. There are only localhost
and arpa
DNS entries which are static.
如我们所见,其他DNS条目已成功删除。 只有localhost
和arpa
DNS条目是静态的。
使用Clear-DnsClientCache PowerShell命令清除DNS缓存 (Flush DNS Cache with Clear-DnsClientCache PowerShell Command)
PowerShell provides very same of the traditional MS-DOS commands. We can use all of the MS-DOS commands in PowerShell too. We can flush the DNS cache records with the ipconfig /flushdns
command like below. First, we will open PowerShell from the start menu by writing powershell
like below.
PowerShell提供了与传统MS-DOS命令完全相同的功能。 我们也可以在PowerShell中使用所有MS-DOS命令。 我们可以使用ipconfig /flushdns
命令刷新DNS缓存记录,如下所示。 首先,我们将通过如下所示编写powershell
从开始菜单中打开PowerShell。

Then we will type the command like below.
然后,我们将如下所示键入命令。
PS> ipconfig /flushdns

使用PowerShell Clear-DnsClientCache Cmdlet刷新DNS (Flush DNS with PowerShell Clear-DnsClientCache Cmdlet)
Powershell provides a new way to clear DNS client cache or flush DNS with the Clear-DnsClientCache
cmdlet. We will just execute the command below.
Powershell提供了一种新的方式来清除DNS客户端缓存或使用Clear-DnsClientCache
cmdlet刷新DNS。 我们将只执行以下命令。
PS> Clear-DnsClientCache
翻译自: https://www.poftut.com/how-to-flush-dns-and-reset-tcp-ip-with-ipconfig-flushdns-command-in-windows/