CentOS ping: unknown host 解决方法
2015-11-23 00:25
771 查看
分类:
Centos运维(8)
作者同类文章X
目录(?)[-]
1 确定设置了域名服务器
2 确保路由表正常
3 确保可用dns解析这步常忘了
如果ping命令返回如下错误,那主要的可能性就是系统的DNS设置有误。
[cpp]
view plaincopyprint?
[root@CentOS5 ~]# ping www.sina.com.cn
ping: unknown host www.sina.com.cn
可以通过如下方法来解决,此方法已经在linux和solaris系统下通过验证。
[cpp]
view plaincopyprint?
# cat /etc/resolv.conf
-------------------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
-------------------------------------------------------------------
view plaincopyprint?
[root@CentOS5 ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.128.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.128.2 0.0.0.0 UG 0 0 0 eth0
如果未设置, 则通过如下方式增加网关:
[cpp]
view plaincopyprint?
# route add default gw 192.168.128.2
view plaincopyprint?
# grep hosts /etc/nsswitch.conf
-------------------------------------------------------------------
hosts: files dns
-------------------------------------------------------------------
注意,上面的配置要加上dns。
以下是dns的配置,备忘。
hosts: dns files
表示只在DNS失效时候才使用/etc/hosts文件
hosts: dns
表示只用DNS解析主机
host: files
表示只用/etc/hosts文件解析主机
hosts: files dns
将使用/etc/hosts文件解析主机,表示如果无法解析主机名将使用DNS。
分类:
Centos运维(8)
作者同类文章X
目录(?)[-]
1 确定设置了域名服务器
2 确保路由表正常
3 确保可用dns解析这步常忘了
如果ping命令返回如下错误,那主要的可能性就是系统的DNS设置有误。
[cpp]
view plaincopyprint?
[root@CentOS5 ~]# ping www.sina.com.cn
ping: unknown host www.sina.com.cn
可以通过如下方法来解决,此方法已经在linux和solaris系统下通过验证。
1) 确定设置了域名服务器
没有的话, 建议设置Google的公共DNS服务, 它应该不会出问题的[cpp]
view plaincopyprint?
# cat /etc/resolv.conf
-------------------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
-------------------------------------------------------------------
2) 确保路由表正常
[cpp]view plaincopyprint?
[root@CentOS5 ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.128.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.128.2 0.0.0.0 UG 0 0 0 eth0
如果未设置, 则通过如下方式增加网关:
[cpp]
view plaincopyprint?
# route add default gw 192.168.128.2
3) 确保可用dns解析(这步常忘了)
[cpp]view plaincopyprint?
# grep hosts /etc/nsswitch.conf
-------------------------------------------------------------------
hosts: files dns
-------------------------------------------------------------------
注意,上面的配置要加上dns。
以下是dns的配置,备忘。
hosts: dns files
表示只在DNS失效时候才使用/etc/hosts文件
hosts: dns
表示只用DNS解析主机
host: files
表示只用/etc/hosts文件解析主机
hosts: files dns
将使用/etc/hosts文件解析主机,表示如果无法解析主机名将使用DNS。
相关文章推荐
- golang windows 交叉编译 Linux
- Linux相关收藏
- linux下批量替换文件中的某个字符串
- Linux CAN编程详解
- linux日常管理-防火墙netfilter工具-iptables-2
- 每天学一点linux(5)
- linux iptables 笔记
- centos 7 安装配置centos 7
- Linux 的账号与群组[转自vbird]
- CentOS6下安装Java jdk1.7.0_10
- linux目录和文件限制
- Linux 常用命令
- linux下firefox手工安装flash插件
- Linux最常用20条命令
- arm-linux-gcc交叉工具安装配置
- VirtualBox安装linux系统过程非图形化界面问题解决
- centos6 安装android studio 依赖包
- 树莓派hwclock命令参数及用法详解--linux显示/设置硬件时钟命令
- hadoop在linux环境下的安装
- UNPV22 RPC运行server提示Cannot register service: RPC: Unable to receive; errno = Connection refused