一、实验环境
dnsmasp01 192.168.1.104
dnsmasq02 192.168.1.106
dnsclient 192.168.1.102
二、安装配置
在dnsmasp01服务器
# yum -y install dnsmasq
# cat /etc/dnsmasq.conf
###################################
domain-needed
bogus-priv
resolv-file=/etc/resolv.conf
strict-order
address=/www.example.com/192.168.1.110
address=/www.example.com/192.168.1.120
listen-address=127.0.0.1,192.168.1.104
no-hosts
expand-hosts
addn-hosts=/etc/hosts
domain=www.example.com
conf-dir=/etc/dnsmasq.d
#####################################
在dnsmasp02服务器
# yum -y install dnsmasq
# cat /etc/dnsmasq.conf
######################################
domain-needed
bogus-priv
resolv-file=/etc/resolv.conf
strict-order
address=/www.example.com/192.168.1.110
address=/www.example.com/192.168.1.120
listen-address=127.0.0.1,192.168.1.106
no-hosts
expand-hosts
addn-hosts=/etc/hosts
domain=www.example.com
conf-dir=/etc/dnsmasq.d
##########################################
启动dnsmasq
# systemctl restart dnsmasq
# systemctl status dnsmasq
# systemctl enable dnsmasq
三、dnsclient服务器域名解析测试
# cat /etc/resolv.conf
# ping www.example.com
# ping www.baidu.com
测试可知,dnsmasq可以继承宿主机的nameserver,内外网域名解析,没问题。
关闭dnsmasq01上服务,也就是说 nameserver 192.168.1.104 无法工作了
# systemctl stop dnsmasq
在dnsclient上测试域名解析
# ping www.example.com
# ping www.baidu.com
# nslookup www.example.com
nameserver 192.168.1.104挂了,nameserver 192.168.1.106,依然能顺利完成解析!
四、参考
How to Setup a DNS/DHCP Server Using dnsmasq on CentOS/RHEL 8/7
https://www.tecmint.com/setup-a-dns-dhcp-server-using-dnsmasq-on-centos-rhel
dnsmasq wiki
https://wiki.archlinux.org/title/dnsmasq
Index of /dnsmasq
https://thekelleys.org.uk/dnsmasq
负载均衡手段之DNS轮询
https://www.cnblogs.com/data2value/p/6107380.html
什么是循环 DNS?
https://www.cloudflare.com/zh-cn/learning/dns/glossary/round-robin-dns/
Using Dnsmasq for local development on OS X
https://passingcuriosity.com/2013/dnsmasq-dev-osx
dnsmasq轻量级DNS安装配置
https://developer.aliyun.com/article/459556
Linux安装DNSmasq搭建自己的公共DNS
https://cloud.tencent.com/developer/article/1024293
使用 dnsmasq 转发 dns 请求
https://einverne.github.io/post/2014/05/dnsmasq-dns-forward.html
DNS 解析 DNSPod
https://cloud.tencent.com/document/product/302
Simple Load Balancing with DNS on Linux
https://www.linux.com/topic/networking/simple-load-balancing-dns-linux
dnsmasq 介绍与使用
http://www.enkichen.com/2017/05/23/dnsmasq-introduce