在resolv.conf中添加single-request-reopen选项cat /etc/resolv.conf
# Generated by NetworkManager
options single-request-reopen
nameserver 192.168.18.77
这其实是CentOS 6的一个Bug,可查询到的解释如下:The logic behind so long time for DNS resolution lies in fact that resolver use same socket for A(ipv4) and AAAA(IPv6) DNS record resolution. Some hardware mistaking send one reply and left resolver in waiting mode. Enabling option single-request-reopen will instruct resolver to use new socket if for AAAA if require.
原因是:CentOS 6中的DNS解析器对于ipv4和ipv6都使用同一个socket接口,在同时发出ipv4和ipv6解析请求后,只会收到一个ipv4的解析响应,此时socket将一处于“等待”模式,等待ipv6的解析响应,故导致解析缓慢;添加single-request-reopen后就可以重新打开一个新的socket接收ipv6的解析响应,而不影响ipv4的解析响应。
防止修改resolv.conf文件后,重启网络,会导致文件被重置的情况,原因是启用了NetworkManager服务1.创建一个脚本。
vi /etc/NetworkManager/dispatcher.d/15-resolv
#!/bin/bash
# Description : script to override default resolv.conf file
# with customized file.
cp -f /etc/resolv.conf.custom /etc/resolv.conf
2.设置文件权限
chmod u+x /etc/NetworkManager/dispatcher.d/15-resolv
3.创建一个文件
vi /etc/resolv.conf.custom
options single-request-reopen
nameserver xx.xx.xx.xx
4.重启服务
service NetworkManager restart
取消GSSAPIAuthentication认证与UseDNS反向解析功能:vi /etc/ssh/sshd_config
GSSAPIAuthentication no
#通用安全服务应用程序接口(GSSAPI) 是为了让程序能够访问安全服务的一个应用程序接口,取消这个认证。
UseDNS no
#DNS反向解析,设置为no