Centos 开启 dns缓存

安装nscd

yum install nscd

在有IPA Client(或SSSD)的情况下修改/etc/nscd.conf中enable-cache为如下

enable-cache hosts yes
enable-cache passwd no
enable-cache group no
enable-cache netgroup no
enable-cache services no

启动

systemctl enable nscd
systemctl restart nscd

验证已经开启

time getent hosts www.bing.com

结果中

real    0m0.002s
user    0m0.001s
sys     0m0.000s

real 几乎等于 user + sys