Linux下用dnsmasq做dns cache server的配置方法
目前最新版是2.7.1,可去其FTP下载:http://www.thekelleys.org.uk/dnsmasq/
安装过程比较简单
yum-yinstalldnsmasq* wgethttp://www.keepalived.org/software/keepalived-1.2.9.tar.gz tarzxvfkeepalived-1.2.9.tar.gz cdkeepalived-1.2.9 ./configure--prefix=/usr/local/keepalived make&&makeinstall mkdir/etc/keepalived cp/usr/local/keepalived/etc/keepalived/keepalived.conf/etc/keepalived/ ln-s/usr/local/keepalived/etc/sysconfig/keepalived/etc/sysconfig/ ln-s/usr/local/keepalived/etc/rc.d/init.d/keepalived/etc/init.d/ ln-s/usr/local/keepalived/sbin/keepalived/usr/sbin/ chkconfig--addkeepalived chkconfig--level35keepalivedon
keepalived的配置很简单,只需要配置一个VIP可以在两台Server之间飘来飘去就可以实现主备了
!ConfigurationFileforkeepalived global_defs{ notification_email{ xxx@xxx.com } notification_email_fromxxx@xxx.com smtp_server127.0.0.1 smtp_connect_timeout30 router_idLVS_DEVEL } vrrp_instancednscache{ stateMASTER//另一台配置BACKUP interfaceeth1//在哪个接口上进行服务器状态检测 virtual_router_id51 priority180//BACKUP机器上配置100 advert_int1//检查间隔,单位为秒 authentication{ auth_typePASS auth_pass1234 } virtual_ipaddress{//VIP设置,指定到内网网卡 192.168.100.99/24deveth1 } }
dnsmasq的配置也很简单
resolv-file=/etc/resolv.dnsmasq.conf cache-size=1000 conf-dir=/etc/dnsmasq.d
将dns地址写入到/etc/resolv.dnsmasq.conf文件中
echo"nameserver8.8.8.8">/etc/resolv.dnsmasq.conf
本机和局域网其它全部的服务器dns解析都用它
echo"nameserver192.168.100.99">/etc/resolv.conf
最后找一台局域网Server验证一下,如果能解析就说明正常了.
nslookupwww.google.cn192.168.100.99
此方案只适合小型企业,规模少的情况下使用,解析量大的时候还是用bind最好。
下面是其它网友的补充:
sudopacman-S--neededdnsmasq cd/etc
[admin@huangyeetc]$sudocp-vdnsmasq.conf{,.orig} `dnsmasq.conf'->`dnsmasq.conf.orig'
[admin@huangyeetc]$sudovimdnsmasq.conf