生產環境:
操作系統: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.8
nameserver 8.8.4.4
[root@sky9896 ~]#cat /etc/resolv.conf
nameserver 220.248.192.12 #修改成聯通的DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
[root@sky9896 ~]#ping www.hao123.com
ping: unknown host www.hao123.com #還是無法解析
[root@sky9896 ~]# netstat -rn #查看路由信息,發現聯通網關不存在
Kernel IP routingtable
Destination Gateway Genmask Flags MSS Window irtt Iface
113.195.210.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
117.40.239.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 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 -rn
Kernel IP routingtable
Destination Gateway Genmask Flags MSS Window irtt Iface
113.195.210.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
117.40.239.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 113.195.210.1 0.0.0.0 UG 0 0 0 eth0
0.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 ms
64 bytes from112.80.248.211: icmp_seq=2 ttl=55 time=33.4 ms
64 bytes from 112.80.248.211:icmp_seq=3 ttl=55 time=31.0 ms
64 bytes from112.80.248.211: icmp_seq=4 ttl=55 time=31.1 ms
64 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-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=113.195.*.*
NETMASK=255.255.255.0
GATEWAY=113.195.*.* #少寫了一個字母”T”,導致找不到網關
DNS=220.248.192.12 #聯通DNS
HWADDR=00:21:97:68:F2:70
TYPE=Ethernet
UUID=480c82ca-d673-466d-902a-9f31eaeb897c
ONBOOT=yes
NM_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 #下載速度
Testing upload speed..................................................
Upload: 45.33 Mbit/s #上傳速度
[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 #下載速度
Testing upload speed..................................................
Upload: 22.21 Mbit/s #上傳速度