dnsmasq 1个域名配置多个解析
**Dnsmasq version 2.76 配置2个address= ,只生效第一个解析,需要按照如下格式配置host-record
host-record=testxx.heytea-co.com,1.1.1.1
host-record=testxx.heytea-co.com,2.2.2.2
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.16 <<>> testxx.heytea-co.com @10.250.0.136 A +noall +answer
;; global options: +cmd
testxx.heytea-co.com. 0 IN A 2.2.2.2
testxx.heytea-co.com. 0 IN A 1.1.1.1
* *巡检探测.sh
for i in {1..10}; do
dig @10.250.0.136 testxx.heytea-co.com A +short
done
**如果需要解析v4 和v6 ,host-record=server01.example.com,10.10.10.10,2001:db8::10
**
2. address=:地址覆盖/强制映射
address= 更适合:
“这个域名匹配到以后,不要再正常递归查询,直接告诉它这个地址。”
例如:
address=/api.example.com/10.10.10.100
意思大致是:
查询:
www.api.example.com
api.example.com
xxx.api.example.com
如果符合 dnsmasq 的匹配规则,就可以被这个地址规则直接处理。
更典型的是:
address=/example.com/10.10.10.100
相当于:
*.example.com
↓
10.10.10.100
因此 address= 很适合做:
DNS 黑洞
address=/ads.example.com/0.0.0.0
内网强制解析
address=/internal.example.com/10.10.10.50
某个域名整个范围覆盖
address=/test.example.com/10.10.20.100
**以后配置 dnsmasq,可以直接这么判断:
我要“创建一个具体主机的 DNS 记录”
host-record=
例如:
host-record=device-shop.heytea-co.com,15.197.196.221
host-record=device-shop.heytea-co.com,99.83.217.141
我要“一个域名/域名范围强制返回某个地址”
address=
例如:
address=/ads.example.com/0.0.0.0
或者:
address=/internal.example.com/10.10.10.100
我要“把某个域名交给指定 DNS 服务器解析”
server=
例如你的 AD:
server=/mxx.sz.com/10.250.0.100
所以可以最终记成:
host-record = 我自己定义这个 hostname 的 DNS 记录
address = 我强制把这个域名匹配到某个地址
server = 我把这个域名交给某个 DNS 服务器解析

共有 0 条评论