您的位置:首页 > 运维架构 > Linux

Linux无法解析域名的背后原因

2017-09-04 11:50 302 查看
生产环境:
操作系统:CentOS release 6.8 (Final)
问题:无法解析域名,无法ping ip,公网不畅通。
分析:由电信专线换成联通专线,很有可能是这种原因造成的,但是IP和DNS都换成了联通啊。
解决问题过程:
[root@sky9896 ~]#wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz--2017-09-0410:46:26-- https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz正在解析主机 cn.wordpress.org... 失败:域名解析暂时失败。wget: 无法解析主机地址 “cn.wordpress.org”[root@sky9896 ~]#ping www.hao123.com #无法解析ping: unknown host www.hao123.com [root@sky9896 ~]#cat /etc/resolv.conf nameserver 202.101.224.68 #这个是电信的DNS,要改吗?nameserver 8.8.8.8nameserver 8.8.4.4 [root@sky9896 ~]#cat /etc/resolv.conf nameserver 220.248.192.12 #修改成联通的DNSnameserver 8.8.8.8nameserver 8.8.4.4 [root@sky9896 ~]#ping www.hao123.comping: unknown host www.hao123.com #还是无法解析 [root@sky9896 ~]# netstat -rn #查看路由信息,发现联通网关不存在Kernel IP routingtableDestination Gateway Genmask Flags MSS Window irtt Iface113.195.210.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0117.40.239.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth00.0.0.0 117.40.239.1 0.0.0.0 UG 0 0 0 eth0[root@sky9896 ~]#route add default gw 113.195.210.1 #添加联通网关[root@sky9896 ~]#netstat -rnKernel IP routingtableDestination Gateway Genmask Flags MSS Window irtt Iface113.195.210.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0117.40.239.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth00.0.0.0 113.195.210.1 0.0.0.0 UG 0 0 0 eth00.0.0.0 117.40.239.1 0.0.0.0 UG 0 0 0 eth0
[root@sky9896 ~]#ping www.hao123.com #可以解析了,但延时严重哦PING hao123.n.shifen.com(112.80.248.211) 56(84) bytes of data.64 bytes from112.80.248.211: icmp_seq=1 ttl=55 time=31.0 ms64 bytes from112.80.248.211: icmp_seq=2 ttl=55 time=33.4 ms64 bytes from 112.80.248.211:icmp_seq=3 ttl=55 time=31.0 ms64 bytes from112.80.248.211: icmp_seq=4 ttl=55 time=31.1 ms64 bytes from112.80.248.211: icmp_seq=5 ttl=55 time=31.1 ms [root@sky9896 ~]#wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz--2017-09-0411:11:47-- https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz正在解析主机 cn.wordpress.org... 66.155.40.250, 66.155.40.249正在连接 cn.wordpress.org|66.155.40.250|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:8641990 (8.2M) [application/octet-stream]正在保存至: “wordpress-4.8.1-zh_CN.tar.gz” 8% [===> ]716,386 399K/s ^Z[8]+ Stopped wgethttps://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz 小结:最终原因是在设置网关时少写了一个字母“T”,同时把备份的"ifcfg-eth0"相关文件删除,重新启动网络服务,会把相对应的电信IP和网关自动删除掉,从而避免冲突。[root@sky9896 network-scripts]#vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0BOOTPROTO=staticIPADDR=113.195.*.*NETMASK=255.255.255.0 GATEWAY=113.195.*.* #少写了一个字母”T”,导致找不到网关DNS=220.248.192.12 #联通DNSHWADDR=00:21:97:68:F2:70TYPE=EthernetUUID=480c82ca-d673-466d-902a-9f31eaeb897cONBOOT=yesNM_CONTROLLED=no 到这里把所有上述问题解决掉了。 顺便测试一下联通网络:[root@sky9896 network-scripts]# speedtest-cli --share
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Unicom (113.195.210.147)...
Selecting best server based on latency...
Hosted by ChinaTelecom.Hunan (Changsha) [107.66 km]: 34.473 ms
Testing download speed........................................
Download: 79.57 Mbit/s #下载速度
Testing upload speed..................................................
Upload: 48.33 Mbit/s #上传速度
Share results: https://www.speedtest.net/result/6594856504.png #测试结果
[root@sky9896 network-scripts]# speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Unicom (113.195.210.147)...
Selecting best server based on latency...
Hosted by ChinaTelecom.Hunan (Changsha) [107.66 km]: 36.537 ms
Testing download speed........................................
Download: 49.98 Mbit/s [b]#下载速度[/b]
Testing upload speed..................................................
Upload: 45.33 Mbit/s [b] #上传速度[/b]

[root@sky9896 network-scripts]# speedtest-cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Unicom (113.195.210.147)...
Selecting best server based on latency...
Hosted by ChinaTelecom.Hunan (Changsha) [107.66 km]: 45.695 ms
Testing download speed........................................
Download: 81.35 Mbit/s [b][b]#下载速度[/b][/b]
Testing upload speed..................................................
Upload: 22.21 Mbit/s [b][b]#上传速度[/b][/b]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息