当前位置: 首页 > news >正文

linux:Temporary failure in name resolutionCouldn’t resolve host

所有域名无法正常解析。

  • ping www.baidu.com 等域名提示 Temporary failure in name resolution错误。
root@localhost:~# ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution
root@localhost:~# 

一、ubuntu/debian(emporary failure in name resolution)

1、修改/etc/resolv.conf配置文件

sudo vim /etc/resolv.conf 

添加如下内容:nameserver 8.8.8.8

然后重新试下,访问正常

root@localhost:~# ping www.baidu.com
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=52 time=21.9 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=52 time=21.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=52 time=37.3 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=52 time=23.0 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=5 ttl=52 time=32.4 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=6 ttl=52 time=42.5 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=7 ttl=52 time=22.0 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=8 ttl=52 time=25.9 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=9 ttl=52 time=22.1 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=10 ttl=52 time=42.2 ms
^C
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 28ms
rtt min/avg/max/mdev = 21.801/29.118/42.487/8.263 ms
root@localhost:~# 

二、 CentOS(Couldn’t resolve host)

CentOS 下面直接修改 /etc/resolv.conf 不行,因为该文件调用了 /etc/sysconfig/network-scripts/ifcfg-eth0 的配置预设,既然知道了这两个文件的工作原理,那么我们必须要在 /etc/sysconfig/ network-scripts/ifcfg-eth0 里面最后加上 dns 地址让 resolv.conf 来调用。否则重启后,因为 eth0 中没有预设 dns 的相关信息,就会使 /etc/resolv.conf 恢复到原来的状态,解析还是不成功。

修改 /etc/sysconfig/network-scripts/ifcfg-eth0 文件

最后加上两行

DNS1=8.8.8.8
DNS2=8.8.4.4

改完后重启网卡

service network restart

重启后再查看 /etc/resolv.conf 文件是这样的:

# Generated by NetworkManager
search webhostbox.net
nameserver 8.8.8.8
http://www.lryc.cn/news/132099.html

相关文章:

  • C 语言的 sprintf() 函数
  • 李沐pytorch学习-卷积网络及其实现
  • 记录:win10物理机ping不通虚拟机上的docker子网(已解决)
  • 深入浅出Pytorch函数——torch.nn.init.kaiming_normal_
  • D. Anton and School - 2
  • xcode把包打到高版本的iPhone里
  • PMP项目管理考试小结
  • 【NAS群晖drive异地访问】使用cpolar远程访问内网Synology Drive「内网穿透」
  • 【傅里叶级数与傅里叶变换】数学推导——2、[Part2:T = 2 π的周期函数的傅里叶级数展开] 及 [Part3:周期为2L的函数展开]
  • 【IMX6ULL驱动开发学习】06.DHT11温湿度传感器驱动程序编写与测试
  • sip开发从理论到实践,让你快速入门sip
  • 十三、Linux中必须知道的几个快捷键!!!
  • Django进阶-文件上传
  • clickhouse-数据导入导出方案
  • [JavaWeb]【一】入门JavaWeb开发总概及HTML、CSS、JavaScript
  • Python自动化小技巧18——自动化资产月报(word设置字体表格样式,查找替换文字)
  • FFmpeg5.0源码阅读——VideoToobox硬件解码
  • IDEA 中Tomcat源码环境搭建
  • MATLAB | 七夕节用MATLAB画个玫瑰花束叭
  • 嵌入式开发之configure
  • 深入浅出Pytorch函数——torch.nn.Module
  • 【100天精通python】Day38:GUI界面编程_PyQt 从入门到实战(中)_数据库操作与多线程编程
  • STM32--TIM定时器(3)
  • 爬虫框架- feapder + 爬虫管理系统 - feaplat 的学习简记
  • 设计模式详解-享元模式
  • BDA初级分析——用SQL筛选数据
  • (成功踩坑)electron-builder打包过程中报错
  • 【STM32】 工程
  • Git概述
  • ubuntu 编译安装nginx及安装nginx_upstream_check_module模块