当configuration中的域名被查询为CNAME时,dnsmasq响应来自上游的错误IP地址

在我们公司的局域网上,我们使用dnsmasq服务器覆盖了我们办公室内可用的主机的DNS。 例如在我们的/etc/dnsmasq.d/lan.conf有:

 address=/foo.example.com/192.168.1.2 

在公共DNS外部,foo.example.com映射到一个不同的IP地址,比如说1.2.3.4。 当在局域网上,客户端应该总是得到这个资源的本地IP地址,因为外部公共IP不能正确地从LAN路由。

我们所看到的是,有时我们的局域网上的客户端会尝试访问foo.example.com。 这是由于他们从dnsmasq获取foo.example.com的公共IP地址。

他们第一次查询bar.example.com时会发生这种情况。 bar.example.com作为CNAME在公共DNS中:

 bar.example.com CNAME foo.example.com 

我们在dnsmasq日志中看到的是:

 query[A] foo.example.com from <client> config foo.example.com is 192.168.1.2 query[A] bar.example.com from <client> forwarded bar.example.com to <upstream DNS> reply bar.example.com is <CNAME> reply foo.example.com is 1.2.3.4 

dnsmasq在查询foo.example.com的CNAME后,用外部IP地址回应,而不是用内部IP地址回应。 客户端获取foo和bar的IP地址都是错误的。 客户端然后可以不连接到任一。

一个解决方法是将每个可能的CNAME放入dnsmasq的configuration中。 有没有一个更一般的解决这个行为的dnsmasq?