LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Choosing DNS server based on domain being queried (https://www.linuxquestions.org/questions/linux-networking-3/choosing-dns-server-based-on-domain-being-queried-758647/)

xtc 09-30-2009 06:19 AM

Choosing DNS server based on domain being queried
 
Hi,

I've setup a BIND 9 server that sits in multiple subnets and serves different views based on which subnet the query came from. This is working fine.

Now I have a Debian client that sits in two of these subnets and I'd like it to choose which DNS server IP to use based on the domain name in the query, i.e. host.domain would be looked up using DNS server defined for the first network interface, whereas host.foobar.domain would use a different DNS server defined for the second network interface. How should I go about doing this? Resolvconf apparently lets you define dns-nameservers and dns-servers on a per-interface basis, but I can't find any good documentation about how this actually works.

abarclay 09-30-2009 10:16 AM

I don't believe there is any way to do what you want using only the resolv.conf. I think the easiest solution is to run a caching only name server on your Debian client, then point your client to itself, then use selective forwarding to forward the query to the correct name server.

You'd need to put the following in your named.conf

zone "domain" IN {
type forward;
forwarders {10.0.0.1;};
};

zone "foobar.domain" IN {
type forward;
forwarders {10.0.1.1;};
};

Alternatively, you could setup both your existing name servers to forward queries to each other.

Hope this helps,
Andy

xtc 10-01-2009 06:01 AM

Thanks, that solution worked perfectly.

I wonder though if this could have been done using resolvconf package (not resolv.conf file). If you define dns-nameservers and dns-search for an interface using resolvconf, does it automatically know to look for those domains using that interface, or does it simply try appending those suffixes as with resolv.conf search option? In the latter case, how does resolvconf decide which interface to use for sending the queries?

abarclay 10-01-2009 10:21 AM

I just did some research on the resolvconf package as I was not familiar with it.
There is some information here:
http://en.wikipedia.org/wiki/Resolvconf
and the man page is here:
http://www.clab.it/cgi-bin/man/man2html?resolvconf+8

It appears that the sole purpose of that program is to re-write the resolv.conf based on what interfaces are present on your computer, so this would NOT work for your situation. The only thing that resolvconf would do is deal with situations when you have multiple programs that tend to configure resolv.conf - perhaps you run two dhcpclient programs (one for each interface) and perhaps you also have ppp running to support your connection to the Internet.

The only configuration for resolvconf seems to be the interface-order file. If you look at the man page here:
http://www.clab.it/cgi-bin/man/man2h...nterface-order

You can see that it only supports interface name and not domain name in order to choose which name server to use.


All times are GMT -5. The time now is 02:16 PM.