FreeBSD部署dns缓存服务器
cd /usr/ports/dns/djbdns ; make install clean && rehash相关安装选项使用默认值。
建立dnscache目录,推荐放在/usr/dns/service下
mkdir -p /usr/dns/service同时修改/usr/local/etc/rc.d/svscan 内容,将/var/service 改为 /usr/dns/service
dnscache-conf nobody nobody /usr/dns/service/dnscache 127.0.0.1 #nobody是系统账号和组 在/etc/rc.conf里加入 svscan_enable="YES" vi /usr/dns/service/dnscache/env/IP加入127.0.0.1 ;此处所写的IP为dnscache服务所绑定的IP
【注意:
如果要为内网其它服务器提供dns服务器,需要增加内网ip。
并增加相关目录:
touch /usr/dns/service/dhscache/root/ip/192.168.1
这样就可以为网络为192.168.1.0的局域网提供缓存服务。】最后就可以运行/usr/local/etc/rc.d/svscan start启动服务了 服务启动以后查看一下127.0.0.1是否有53端口在监听,如果有,说明成功了
接下来就是修改/etc/resolv.conf的配置,如下: nameserver 127.0.0.1 nameserver 202.106.196.115 nameserver 8.8.8.8 nameserver 202.106.0.20 nameserver 202.96.199.133 nameserver 202.96.0.133 nameserver 202.106.148.1 nameserver 202.97.16.195 nameserver 202.138.96.2 把127.0.0.1放在其他的nameserver前,这样就优先使用缓存结果 ======================================================安装dnscache后的所需要执行的命令汇总。
mkdir -p /usr/dns/service
sed -i '' 's#/var/service#/usr/dns/service#g' /usr/local/etc/rc.d/svscan dnscache-conf nobody nobody /usr/dns/service/dnscache 127.0.0.1 echo 'svscan_enable="YES"' >> /etc/rc.conf echo '127.0.0.1' >> /usr/dns/service/dnscache/env/IP sed -i '' '/nameserver/d' /etc/resolv.conf echo 'nameserver 127.0.0.1' >> /etc/resolv.conf echo 'nameserver 202.106.196.115' >> /etc/resolv.conf echo 'nameserver 8.8.8.8' >> /etc/resolv.conf echo 'nameserver 202.106.0.20' >> /etc/resolv.conf echo 'nameserver 202.96.199.133' >> /etc/resolv.conf echo 'nameserver 202.96.0.133' >> /etc/resolv.conf echo 'nameserver 202.106.148.1' >> /etc/resolv.conf echo 'nameserver 202.97.16.195' >> /etc/resolv.conf echo 'nameserver 202.138.96.2' >> /etc/resolv.conf /usr/local/etc/rc.d/svscan start