我们在日常工作中,有时候客户反馈野草云的VPS 访问 github 很慢,这是不应该的。在技术同事检查后发现VPS默认的DNS为 8.8.8.8,但该NS似乎未能准确识别到服务器IP地址的归属地,导致github解析IP响应异常,例如香港的VPS返回了美国的github节点,此时延迟可能就非常高了。您可以将服务器DNS修改为 1.1.1.1,然后就获取更好的速度。
以下是技术同事的检查流程,以及更改DNS为1.1.1.1后ping github延迟的结果,得到了明显的改善:
[root@test ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
[root@test ~]# tracepath github.com
1?: [LOCALHOST] pmtu 1500
1: 38.147.170.254 0.430ms
1: 38.147.170.254 0.491ms
2: 10.0.2.13 0.403ms
3: 172.31.2.2 1.260ms
4: 172.31.2.1 0.627ms
5: no reply
6: ae-20.r26.tkokhk01.hk.bb.gin.ntt.net 4.713ms asymm 8
7: no reply
8: ae-4.r25.snjsca04.us.bb.gin.ntt.net 162.646ms asymm 12
9: ae-5.r24.snjsca04.us.bb.gin.ntt.net 161.835ms asymm 10
10: ae-5.r25.asbnva02.us.bb.gin.ntt.net 214.143ms asymm 15
11: ae-0.a00.rstnva04.us.bb.gin.ntt.net 204.568ms asymm 15
12: no reply
13: no reply
[root@test ~]# ping github.com
PING github.com (140.82.114.4) 56(84) bytes of data.
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=1 ttl=43 time=209 ms
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=2 ttl=43 time=209 ms
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=3 ttl=43 time=209 ms
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=4 ttl=43 time=209 ms
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=5 ttl=43 time=209 ms
64 bytes from lb-140-82-114-4-iad.github.com (140.82.114.4): icmp_seq=6 ttl=43 time=209 ms
^C
--- github.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5005ms
rtt min/avg/max/mdev = 209.279/209.355/209.479/0.463 ms
[root@test ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 1.1.1.1
[root@test ~]# tracepath github.com
1?: [LOCALHOST] pmtu 1500
1: 38.147.170.254 0.380ms
1: 38.147.170.254 0.478ms
2: 10.0.2.13 0.406ms
3: 172.31.2.2 1.149ms
4: 172.31.2.1 0.772ms
5: no reply
6: no reply
7: ae-2.a00.newthk04.hk.bb.gin.ntt.net 0.729ms asymm 6
8: ae-0.microsoft.newthk04.hk.bb.gin.ntt.net 4.203ms asymm 7
9: ae27-0.icr02.hkg20.ntwk.msn.net 1.932ms asymm 7
10: be-102-0.ibr01.hkg31.ntwk.msn.net 38.072ms asymm 14
11: be-14-0.ibr01.hkg30.ntwk.msn.net 34.376ms asymm 12
12: be-15-0.ibr02.sg2.ntwk.msn.net 34.085ms asymm 11
13: be-2-0.ibr01.tyo79.ntwk.msn.net 128.692ms asymm 18
14: ae120-0.icr01.sg3.ntwk.msn.net 37.986ms asymm 10
15: be-5-0.ibr01.sin30.ntwk.msn.net 122.177ms
16: no reply
17: ae102-0.icr02.sg3.ntwk.msn.net 85.338ms asymm 10
18: no reply
[root@test ~]# ping github.com
PING github.com (20.205.243.166) 56(84) bytes of data.
64 bytes from 20.205.243.166 (20.205.243.166): icmp_seq=1 ttl=113 time=34.8 ms
64 bytes from 20.205.243.166 (20.205.243.166): icmp_seq=2 ttl=113 time=34.7 ms
64 bytes from 20.205.243.166 (20.205.243.166): icmp_seq=3 ttl=113 time=34.7 ms
64 bytes from 20.205.243.166 (20.205.243.166): icmp_seq=4 ttl=113 time=34.7 ms
^C
--- github.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 34.690/34.726/34.774/0.230 ms