帮助文档>Linux实用技巧 > CentOS8如何清除DNS缓存?附详细步骤

CentOS8如何清除DNS缓存?附详细步骤

发布时间:2023-05-26 14:29

很多用户在使用CentOS 系统时会遇到电脑突然无法上网或某些网站打不开但别的网站却可以打开的情况。很多时候这种情况是因为DNS缓存延时导致的。只要清除CentOS 系统上的DNS缓存,您的电脑就可以正常使用啦。下面117数据(www.117w.com)以CentOS8为例为您准备了详细操作步骤。

 

1. 打开终端窗口。

 

2. 作为root用户登录,或者使用sudo命令以管理员权限运行以下命令。

 

3. 输入以下命令以停止并清除dnsmasq服务的缓存:

 

   ```shell

   systemctl stop dnsmasq

   rm -f /var/lib/dnsmasq/*

   ```

 

4. 输入以下命令以重启dnsmasq服务:

 

   ```shell

   systemctl start dnsmasq

   ```

 

   或者,如果dnsmasq服务未启用,您可以使用以下命令启动它:

 

   ```shell

   systemctl enable dnsmasq

   systemctl start dnsmasq

   ```

 

5. 输入以下命令以清除本地DNS缓存:

 

   ```shell

   systemd-resolve --flush-caches

   ```

 

6. 输入以下命令以重启网络服务:

 

   ```shell

   systemctl restart network

   ```

 

完成以上这些步骤后,您的CentOS 8系统上的DNS缓存就已经清除啦,您可以正常使用您的电脑了

本文导读

客户热线:13306992629

客户服务中心