大网数据广告活动
服务器运维问答

DNS Proxy/cache that query multiple DNS, ignore NXDOMAIN

· 52CE 我爱测

The question is as follow: how can I set up a DNS proxy/cache that queries in a strict order a series of DNS servers (of which some might be unavailable), and that does not stop on the first NXDOMAIN answers. Context: The place I…

问题原文

原帖链接 · Tiller · CC BY-SA 4.0

The question is as follow: how can I set up a DNS proxy/cache that queries in a strict order a series of DNS servers (of which some might be unavailable), and that does not stop on the first NXDOMAIN answers.

Context:

The place I work for has a main domain: company.com, and 2 VPNs: vpn1 and vpn2. They are not identical: vpn2 allows you to connect to more services than vpn1. vpn1 is not needed when connected to vpn2 basically.

Some sub-domains are available from the internet: open.company.com Some are only available from vpn1 and vpn2: internal.company.com Some are only available from vpn2: private.company.com

Now, vpn1 has a DNS server: dns1 and vpn2 has a different DNS server: dns2; each with its own configuration.

The issue is: some services that are accessible from VPN1 (and therefore VPN2) are configured in dns1, but not in dns2.

And the bigger problem is that when dns2 is asked, it answers with NXDOMAIN.

So I'm looking for a way to ask the DNS in this specific order: dns2, dns1, 8.8.8.8, but without stopping on the first NXDOMAIN answer.

I tried with DNSMasq and the "all-servers" parameter, it has 2 issues:

  1. I think (I haven't tested) that if the NXDOMAIN from dns2 arrives before the answer from dns1, the query will fail
  2. Some sub domain are resolved by both dns1 and dns2, but when connected to vpn2, the IP configured in DNS2 should be used.

I've looked at dnsmasq, bind, and other random DNS proxies, but without any luck so far.

Note: obviously, I can't update the configuration of DNS1/DNS2. I'm looking for a solution that would run on my laptop (ubuntu)

Any idea? Thanks

已采纳解答

原帖链接 · eltrai · CC BY-SA 4.0

I don't think you can natively get this behaviour from any dns proxy, as it goes agains the spirit of DNS (a DNS server is not supposed to lie using a NXDOMAIN).

My advice would therefore be to actively filter out those false answers from DNS2 so that your proxy only sees the ones from DNS1 and has no ambiguity.

This can be done by adding a rule in the firewall, filtering on only DNS answer paquets that contain the NXDOMAIN flag (and come from DNS1). Then keep your dnsmasq configuration with the all-servers parameter.

See iptables drop negative DNS responses for a way to filter the DNS answers.

Note that if you have the reverse issue (DNS1 answering first with NXDOMAIN for something that exists in DNS2), you can also filter out those answers. However, this would mean that in case of a real non-existent domain, you'll get no answer from any DNS and likely timeout. I'm guessing from your context it's not a big issue but, if so, you'd better only delay the NXDOMAIN answers, as was also done in the linked post, though it is a more complex setup.

Good luck.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-07-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。