问题1:ping网址很慢,要等5秒左右才出现类似于下面的这段文字。
PING www.taobao.com.danuoyi.tbcache.com (223.111.255.233) 56(84) bytes of data.
问题2:出现了上述文字后,还要等5秒左右才能支持发送接受报文。
问题一的解决方案
dns解析太慢导致的。
我的办法是添加192.168.1.1(ifconfig查询一下自己的ip,将后两位改成1)
要放在第一个。
vim /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1
nameserver 47.99.150.54
nameserver 114.114.114.114
也可以把常用网站的ip地址写入/etc/hosts
https://www.ipaddress.com/
github ip
https://help.github.com/en/github/authenticating-to-github/about-githubs-ip-addresses
也可以通过下面公共 DNS 服务器 IP 地址:
https://www.ip.cn/dns.html
一个一个在自己的电脑上试试看,哪个快就用哪个。
问题二的解决方案
禁止ping的时候使用反向DNS查询。
ping后加 -n
ping www.baidu.com -n
http://www.thekelleys.org.uk/dnsmasq/doc.html
https://www.cnblogs.com/sunsky303/p/9238669.html
https://cloud.tencent.com/developer/article/1174717
https://blog.csdn.net/hyz792901324/article/details/90228917
以下是网上查找解决办法时的各种尝试,只做记录。
最终解决办法是因为电脑上freebsd系统的网速相当快,对比了一下两者的区别很容易就解决了。
但是上述解决办法有个缺陷,每过一段时间,系统就会自动重新设置dns,把我的设置覆盖掉,于是又要重新写入。
参考下面链接的解决办法,尝试解决。(待验证)
vim /etc/sysconfig/network-scripts/ifcfg-shampoo
添加
PEERDNS=no
https://www.cnblogs.com/technologylife/p/9216744.html
http://man7.org/linux/man-pages/man5/resolv.conf.5.html
arch的wiki上看到解决办法
https://wiki.archlinux.org/index.php/NetworkManager_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
chattr +i /etc/resolv.conf
其实之前查找资料的时候也看到这种解决办法,当时觉得不是特别好,要是换了一个地方,我设置的dns地址没有现在这么快岂不是也无法写入新的路由?
要是有不更改我的设置,还能往里添加内容的办法就好了。
[clychee@Tashigi yum.repos.d]$ whereis avahi
avahi: /usr/lib64/avahi /etc/avahi /usr/share/avahi
[clychee@Tashigi yum.repos.d]$ service avahi-daemon stop
Redirecting to /bin/systemctl stop avahi-daemon.service
Job for avahi-daemon.service canceled.
sudo ifconfig lo down
[clychee@Tashigi yum.repos.d]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 47.99.150.54
nameserver 114.114.114.114
nameserver 8.8.8.8
nameserver 192.168.1.1
[clychee@Tashigi yum.repos.d]$
在 /etc/hosts 里面添加域名和IP 对,例如:
183.232.231.174 www.baidu.com
[root@Tashigi clychee]# time dig www.taobao.com
; <<>> DiG 9.11.11-RedHat-9.11.11-1.fc31 <<>> www.taobao.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36524
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: f3f37d0a922c2a31 (echoed)
;; QUESTION SECTION:
;www.taobao.com. IN A
;; ANSWER SECTION:
www.taobao.com. 394 IN CNAME www.taobao.com.danuoyi.tbcache.com.
www.taobao.com.danuoyi.tbcache.com. 30 IN A 223.111.230.235
www.taobao.com.danuoyi.tbcache.com. 30 IN A 223.111.255.233
www.taobao.com.danuoyi.tbcache.com. 30 IN A 223.111.244.23
www.taobao.com.danuoyi.tbcache.com. 30 IN A 112.25.57.103
www.taobao.com.danuoyi.tbcache.com. 30 IN A 223.111.255.232
;; Query time: 17 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 一 3月 02 11:51:38 CST 2020
;; MSG SIZE rcvd: 180
real 0m1.033s
user 0m0.008s
sys 0m0.008s
[root@Tashigi clychee]# time dig www.baidu.com
; <<>> DiG 9.11.11-RedHat-9.11.11-1.fc31 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22924
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 004bbf567004b805 (echoed)
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 231 IN CNAME www.a.shifen.com.
www.a.shifen.com. 104 IN A 183.232.231.172
www.a.shifen.com. 104 IN A 183.232.231.174
;; Query time: 17 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 一 3月 02 11:51:53 CST 2020
;; MSG SIZE rcvd: 113
real 0m7.031s
user 0m0.009s
sys 0m0.006s
[clychee@Tashigi ~]$ ls /etc/sysconfig/network-scripts/ifcfg-shampoo
/etc/sysconfig/network-scripts/ifcfg-shampoo
[clychee@Tashigi ~]$ vim /etc/sysconfig/network-scripts/ifcfg-shampoo
网友评论