3

Is it possible to configure a domain-depentant nameserver for address-resolution (e.g. resolv.conf)?

e.g.

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

I am using a modern Debian.

5

You can’t do this with only resolv.conf, but with an intermediary DNS forwarding daemon such as Dnsmasq (packaged in Debian as dnsmasq and related packages).

With Dnsmasq, you’d configure Dnsmasq itself with the list of servers:

server=/abc.com/1.2.3.4
server=/cba.com/4.3.2.1
server=1.4.2.3

and tell it not to look at resolv.conf:

no-resolv

Then you’d change your resolv.conf so it points to the Dnsmasq daemon, by removing all the nameserver entries therein. You’d also need to ensure that any DHCP setup doesn’t overwrite resolv.conf.

2

Yes. It's been possible for a quarter of a century. What you are looking for is split horizon DNS service, and it is not done by fiddling with /etc/resolv.conf. That configuration file dictates stuff to the DNS client library that is (usually) built into the C library that applications programs link to. That library is simple and does not do complex decisions like working out where to send different queries to based upon their question sections.

It's done by fiddling with the (machine-local or site-local) resolving proxy DNS server that the DNS client libraries are configured to talk to. In concrete terms: The /etc/resolv.conf settings point applications to a resolving DNS proxy server listening on (say) a socket bound to the IPv4 address 127.0.0.1, and that server is configured, in ways that are specific to the server software, to enact query resolution in the appropriate way. That proxy DNS server, or even the content DNS server(s) that it in its turn talks to, is where all of the split-horizon mechanism resides.

  • In ISC's BIND, this is done with conditional forwarding or with stub zones.
  • In Daniel J. Bernstein's dnscache this is done with servers/domain files.
  • In dnsmasq, this is done in yet another way. As too systemd-resolved. And so forth.

So install one of these server softwares (Debian even having some of them pre-packaged) on your Debian machine, configure the DNS client libraries to use it, and configure it to do split-horizon DNS.

Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.