1是dns解析问题
2.解决方法:开启dnsmasq服务使用本地dns缓存
3.真正有用的步骤:
(1)vi /etc/resolv.conf
在最前面添加: nameserver 127.0.0.1
其它的不用动,尤其不能相信把其它的都删空之类的话(pppoe可能可以那样干,但没有试验)。
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 127.0.0.1
nameserver 192.168.0.6
nameserver 192.168.0.5
[root@localhost ~]#
[root@localhost ~]# chattr +i /etc/resolv.conf #加锁,解决网络重启之后,会后自动修改的情况
[root@localhost ~]# time curl -s http://www.baidu.com > /dev/null
real 0m3.546s
user 0m0.007s
sys 0m0.011s
(2) 安装dnsmasq服务:
[root@localhost ~]# yum install -y dnsmasq
yum install -y dnsmasq
vi /etc/dnsmasq.conf
listen-address=127.0.0.1 #解除以下一行的注释(并加上ip地址):
resolv-file=/etc/resolv.conf #【ps:此处个人未设置,就OK了】
[root@localhost ~]# service dnsmasq restart
Redirecting to /bin/systemctl restart dnsmasq.service
[root@localhost ~]# time curl -s http://www.baidu.com > /dev/null
real 0m0.042s
user 0m0.006s
sys 0m0.011s
(3)将dnsmasq.conf服务设置为开机启动
修改前后对比【前】,需要5秒才能访问:
操作3(1)步骤之后,快了2秒:
安装dnsmasq服务,操作3(2),毫秒级返回:
[转载]https://leijiao.iteye.com/blog/1066892