dnsmasq的Rebind protection导致的域名解析问题

路由器配置如下:

root@liangbo:~# uci show network.wan
network.wan=interface
network.wan.ifname=eth0
network.wan.proto=dhcp   <=============WAN 自动获取配置信息

root@liangbo:~# uci show network.lan
network.lan=interface
network.lan.ifname=eth1
network.lan.force_link=1
network.lan.type=bridge
network.lan.proto=static
network.lan.ipaddr=192.168.1.1
network.lan.netmask=255.255.255.0
network.lan.ip6assign=60

root@liangbo:~# ifconfig eth0   <=====WAN口成功获得地址
eth0      Link encap:Ethernet  HWaddr 00:1B:C5:09:A6:F3
          inet addr:10.100.20.71  Bcast:10.100.20.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:c5ff:fe09:a6f3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:55112 errors:0 dropped:297 overruns:0 frame:0
          TX packets:32181 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:18004058 (17.1 MiB)  TX bytes:6529135 (6.2 MiB)

root@liangbo:~# uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].boguspriv=1
dhcp.@dnsmasq[0].localise_queries=1
dhcp.@dnsmasq[0].rebind_protection=1
dhcp.@dnsmasq[0].rebind_localhost=1
dhcp.@dnsmasq[0].local=/lan/
dhcp.@dnsmasq[0].domain=lan
dhcp.@dnsmasq[0].expandhosts=1
dhcp.@dnsmasq[0].authoritative=1
dhcp.@dnsmasq[0].readethers=1
dhcp.@dnsmasq[0].leasefile=/tmp/dhcp.leases
dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto   <==== 使用该文件解析域名.
dhcp.@dnsmasq[0].domainneeded=1
...

root@liangbo:~# cat /tmp/resolv.conf.auto                 <==== DHCP分配的DNS服务器
# Interface wan
nameserver 172.16.172.82
nameserver 172.16.172.83
search jiguan.hnecgc.com.cn

试图解析 oa.hnccgc.com 失败

root@liangbo:~# nslookup oa.hnccgc.com
Server:    127.0.0.1
Address 1: 127.0.0.1 localhost
nslookup: can't resolve 'oa.hnccgc.com': Name or service not known    <=== failed

试图使用172.16.172.82 解析 oa.hnccgc.com 成功
root@liangbo:~# nslookup oa.hnccgc.com 172.16.172.82
Server:    172.16.172.82
Address 1: 172.16.172.82 bogon
Name:      oa.hnccgc.com
Address 1: 172.16.172.101 bogon   <===== successed

原因:

dnsmasq 开启了rebind protection,也就是反域名劫持保护。由于上级dns返回的地址是个私有局域网地址,所以被看作是一次域名劫持,从而丢弃了解析的结果。

解决方法:
关闭掉rebind protection就好了,具体方法是:Network==〉DHCP and DNS ==> Server settings ==> General Settings , 勾选掉 Rebind protection.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
dnsmasq中配置域名解析可以通过编辑dnsmasq.conf文件来实现。首先,打开dnsmasq.conf文件,可以使用文本编辑器打开该文件。然后,根据你的需求添加以下配置: 1. 使用strict-order配置项,确保按照resolv-file文件中的顺序从上到下进行DNS解析,直到找到第一个成功解析的为止。 ``` strict-order ``` 2. 使用listen-address配置项,指定dnsmasq监听的IP地址。可以将其设置为127.0.0.1,表示只监听本地回环地址。 ``` listen-address=127.0.0.1 ``` 3. 使用address配置项,进行泛域名解析。例如,如果要将所有以.horizontall.htb结尾的域名解析到10.10.11.105,可以添加以下配置: ``` address=/horizontall.htb/10.10.11.105 ``` 请注意,以上配置可以根据你的实际需求进行修改。完成配置后,保存并关闭dnsmasq.conf文件。然后,重新启动dnsmasq服务,使配置生效。 这样,当你访问任何以.horizontall.htb结尾的域名时,它们都会被解析到10.10.11.105。请确保将这些配置添加到正确的dnsmasq配置文件中,并且重启dnsmasq服务以使配置生效。 #### 引用[.reference_title] - *1* *2* *3* [使用dnsmasq让本地hosts泛解析](https://blog.csdn.net/qq_44881113/article/details/120607698)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值