DNS:可能依赖于域的解析?

chr*_*s01 3 dns resolv.conf

是否可以为地址解析配置依赖于域的名称服务器(例如 resolv.conf)?

例如

nameserver 1.2.3.4 for any domain abc.com
nameserver 4.3.2.1 for any domain cba.com
nameserver 1.4.2.3 for anything else
Run Code Online (Sandbox Code Playgroud)

我正在使用现代 Debian。

Ste*_*itt 5

您不能只使用resolv.conf,而是使用中间 DNS 转发守护程序,例如Dnsmasq(在 Debiandnsmasq和相关软件包中打包)。

使用 Dnsmasq,您可以使用服务器列表配置 Dnsmasq 本身:

server=/abc.com/1.2.3.4
server=/cba.com/4.3.2.1
server=1.4.2.3
Run Code Online (Sandbox Code Playgroud)

并告诉它不要看resolv.conf

no-resolv
Run Code Online (Sandbox Code Playgroud)

然后你会改变你的resolv.conf指向 Dnsmasq 守护进程,通过删除nameserver其中的所有条目。您还需要确保任何 DHCP 设置都不会覆盖resolv.conf.