Centos系统清除DNS缓存
创始人
2024-11-28 19:04:52

在CentOS系统中,清除DNS缓存的方法如下:

1、使用systemdresolve命令清除DNS缓存

Centos系统清除DNS缓存

systemdresolve是CentOS 7及更高版本中用于管理DNS解析的系统服务,要清除DNS缓存,可以使用以下命令:

 sudo systemdresolve flushcaches 

2、重启systemdresolved服务以清除DNS缓存

如果上述方法不起作用,可以尝试重启systemdresolved服务来清除DNS缓存:

 sudo systemctl restart systemdresolved.service 

3、使用nscd服务清除DNS缓存

nscd(Name Service Cache Daemon)是一个守护进程,用于缓存DNS查询结果,要使用nscd清除DNS缓存,请按照以下步骤操作:

安装nscd

 sudo yum install nscd y 

启动并启用nscd服务:

Centos系统清除DNS缓存
 sudo systemctl start nscd.service sudo systemctl enable nscd.service 

使用以下命令清除DNS缓存:

 sudo /etc/init.d/nscd restart 

4、使用iptables命令清除DNS缓存

如果上述方法都不起作用,可以尝试使用iptables命令清除DNS缓存,请注意,这种方法可能会导致网络连接中断,因此在执行此操作之前,请确保已备份重要数据。

查看当前网络接口名称:

 ip link show | grep '^[09]' | cut d ' ' f 2 | head n 1 

假设网络接口名称为eth0,则执行以下命令清除DNS缓存:

 sudo iptables t nat F && sudo iptables t mangle F && sudo iptables F && sudo iptables X && sudo iptables t nat P PREROUTING ACCEPT && sudo iptables t mangle P PREROUTING ACCEPT && sudo iptables P INPUT ACCEPT && sudo iptables P FORWARD ACCEPT && sudo iptables P OUTPUT ACCEPT && sudo service network restart && echo "nameserver 8.8.8.8" > /etc/resolv.conf && echo "nameserver 8.8.4.4" >> /etc/resolv.conf && sudo service network restart && sleep 5 && clear && cat /etc/resolv.conf | grep "nameserver" && dig www.baidu.com @8.8.8.8 +short && dig www.baidu.com @8.8.4.4 +short && dig www.google.com @8.8.8.8 +short && dig www.google.com @8.8.4.4 +short && dig www.bing.com @8.8.8.8 +short && dig www.bing.com @8.8.4.4 +short && dig www.yahoo.com @8.8.8.8 +short && dig www.yahoo.com @8.8.4.4 +short && dig www.github.com @8.8.8.8 +short && dig www.github.com @8.8.4.4 +short && dig www.apple.com @8.8.8.8 +short && dig www.apple.com @8.8.4.4 +short && dig www.amazon.com @8.8.8.8 +short && dig www.amazon.com @8.8.4.4 +short && dig www.microsoft.com @8.8.8.8 +short && dig www.microsoft.com @8.8.4.4 +short && dig www.linuxmint.com @8.8.8.8 +short && dig www.linuxmint.com @8.8.4.4 +short && dig www.ubuntu.com @8.8.8.8 +short && dig www.ubuntu.com @8.8.4.4 +short && dig www.redhat.com @8.8.8.8 +short && dig www.redhat.com @8 
Centos系统清除DNS缓存

相关内容

热门资讯

延安12345 | 拍照只会比... 近日,“剪刀手拍照会泄露指纹信息”冲上热搜,不少网友表示,没想到手指轻轻比个“耶”,竟可能把自己的隐...
填补世界空白的“大国重器”正式... 今天(8日),一项填补世界空白的“大国重器”正式上岗!我国自主研发的全球首套盾构超高压“三元混合气”...
科技助力唱“主角” 数字“新农... 科技助力唱“主角” 数字“新农具”耕出“智慧”丰收田 央视网消息:在湖北黄冈市,依托当地政府打造的...
数字技术赋能乡村振兴——以福建... 胡冰川 当下,数字技术正成为驱动农业农村高质量发展的新质生产力。数字农业以物联网、大数据、人工智能、...
构建智能体EDA方法论:挑战与... 工具与方法论之间的关系是双向的。工具赋能方法论,方法论依赖工具的功能特性及其所提供的数据。然而,当前...