您好,登录后才能下订单哦!
这篇文章主要讲解了“Linux下怎么用dnsmasq做dns cache server配置”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux下怎么用dnsmasq做dns cache server配置”吧!
安装过程比较简单
yum -y install dnsmasq* wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz tar zxvf keepalived-1.2.9.tar.gz cd keepalived-1.2.9 ./configure --prefix=/usr/local/keepalived make && make install 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 --add keepalived chkconfig --level 35 keepalived on
keepalived的配置很简单,只需要配置一个vip可以在两台server之间飘来飘去就可以实现主备了
! configuration file for keepalived global_defs { notification_email { xxx@xxx.com } notification_email_from xxx@xxx.com smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id lvs_devel } vrrp_instance dnscache { state master // 另一台配置backup interface eth2 // 在哪个接口上进行服务器状态检测 virtual_router_id 51 priority 180 // backup机器上配置100 advert_int 1 // 检查间隔,单位为秒 authentication { auth_type pass auth_pass 1234 } virtual_ipaddress { // vip设置,指定到内网网卡 192.168.100.99/24 dev eth2 } }
dnsmasq的配置也很简单
resolv-file=/etc/resolv.dnsmasq.conf cache-size=1000 conf-dir=/etc/dnsmasq.d
将dns地址写入到/etc/resolv.dnsmasq.conf文件中
echo "nameserver 8.8.8.8" > /etc/resolv.dnsmasq.conf
本机和局域网其它全部的服务器dns解析都用它
echo "nameserver 192.168.100.99" > /etc/resolv.conf
最后找一台局域网server验证一下,如果能解析就说明正常了.
nslookup www.google.cn 192.168.100.99
此方案只适合小型企业,规模少的情况下使用,解析量大的时候还是用bind最好。
下面是其它网友的补充:
复制代码 代码如下:
sudo pacman -s --needed dnsmasq
cd /etc
[admin@huangye etc]$ sudo cp -v dnsmasq.conf{,.orig}
`dnsmasq.conf' -> `dnsmasq.conf.orig'
[admin@huangye etc]$ sudo vim dnsmasq.conf
相比来说,dnsmasq的配置简单多了:
复制代码 代码如下:
resolv-file=/etc/dnsmasq.resolv.conf
addn-hosts=/etc/dnsmasq.hosts
local=/localnet/
no-dhcp-interface=eth0
conf-dir=/etc/dnsmasq.d
复制代码 代码如下:
[admin@huangye etc]$ sudo cp -v resolv.conf dnsmasq.resolv.conf
password:
`resolv.conf' -> `dnsmasq.resolv.conf'
sudo mkdir /etc/dnsmasq.d
sudo touch /etc/dnsmasq.hosts
sudo /etc/rc.d/dnsmasq start
最后,别忘记加入rc.conf daemons,注意要在network后面。
dnsmasq 可从额外的hosts文件读取条目,如可以这样添加正向解析:
echo "ip地址 域名" > /etc/dnsmasq.hosts
另外,重启dnsmasq可以用sighup(可以在修改hosts文件后,让配置生效)
killall -s sighup dnsmasq
查看服务状态:
netstat -tunl
tcp 0 0 0.0.0.0:53 0.0.0.0:* listen
udp 0 0 0.0.0.0:53 0.0.0.0:*
感谢各位的阅读,以上就是“Linux下怎么用dnsmasq做dns cache server配置”的内容了,经过本文的学习后,相信大家对Linux下怎么用dnsmasq做dns cache server配置这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。