3

Can I configure resolv.conf to use a specific nameserver for a domain?

e.g.:

nameserver internal.thekelleys.org.uk 192.168.1.1
nameserver 192.168.0.1

I don't want to list *.test.com in /etc/hosts; I don't want to install a DNS server locally (dnsmasq -S /internal.thekelleys.org.uk/192.168.1.1); and I don't want the internal.thekelleys.org.uk DNS server to serve other domains.

Jayen
  • 1,827
  • 3
  • 16
  • 27

2 Answers2

3

This is indeed a common use case when one has more than one network cnnection, e.g. an internet connection (for the generic traffic) and a vpn connection (just for traffic to a company or remote site).

This is a valid example for the question of the OP. I know no operating system (excluding OSX as I've learned above) which can handle this problem from stock. Having linux, one solution may be using dnsmasq with resolvconf. Resolvconf keeps track on all the different domains and namserver and generates a cfg for dnsmasq. Dnsmasq includes this cfg. The local system then uses dnsmasq as nameserver.

In a more static scenario, one could spare resolvconf and use dnsmasq, only.

And yepp, this is a necro thread, but hence there is no advance in the last 3 years, I resurrect it to get the focus back on this quite old, but still unsolved problem.

DaTemp
  • 31
  • 1
  • to add to the answer above, install dnsmasq, setup resolve.conf to use 127.0.0.1 and add lines in /etc/dnsmasq.conf such as: server=/domain1.com/DNS_Server_IP – DerekC Dec 24 '14 at 10:39
2

You can't. The resolver is not designed that way. You'd have to write your own resolver and either preload it into your applications or use NSS to have it examined first.

Ignacio Vazquez-Abrams
  • 45,019
  • 5
  • 78
  • 84
  • 1
    could i add this feature to the resolver and submit a patch? is this part of libc? – Jayen Oct 31 '11 at 07:06
  • I recommend not screwing with the existing resolver. And with NSS, there's no need to anyway. – Ignacio Vazquez-Abrams Oct 31 '11 at 07:16
  • Errr actually that would be a useful adition. Something along the lines os OS X where you can create a `/etc/resolver/example.com` and then `example.com` will be resolved thru the nameservers specified in that file... – Martin M. Oct 31 '11 at 12:35
  • And further *I do recommend fiddling with stuff!*. Without people screwing around there won't be any progress! – Martin M. Oct 31 '11 at 12:37