Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How can I set up Linux to use a different DNS server for a certain domain?

Right now I have a multiple nameservers defined in my /etc/resolv.conf but they are all used for all lookups.

What I would like to do is specify which domain server is used for which toplevel domain, eg.

nameserver .com
nameserver .local.site
nameserver *

Is there a way to do this on Linux ?

share|improve this question

marked as duplicate by Diogo, Journeyman Geek, Simon Sheehan, iglvzx, Hello71 Jul 17 '12 at 0:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@grawity: My question is not about setting up a nameserver, but about letting clients selectively choose a nameserver. –  Gene Vincent Feb 20 '12 at 13:08
That's exactly what the other question is about. Setting up a nameserver (say, bind) just happens to be one of the easiest ways to do it. You can tell it "ask about .com, ask about * using forwarders{} blocks. –  grawity Feb 20 '12 at 14:30

1 Answer 1

up vote 1 down vote accepted

It is standard practice to have, for a group of domains, one master and several secondaries that perform zone-transfers from the master. In other words, I wouldn't do it that way.

In practice you would perform that configuration in the DNS demon's configuration files - look up zone delegation.

resolv.conf is for the client end, the client should be told by any nameserver which nameserver to refer to for queries about specific domains. You should absolutely not try to configure knowledge about domain delegation into the client configuration.

Example of a DNS config with private and public DNS resolution

options {
        directory "/var/named";
        forward only;                      // ISP doesn't permit bypass
        forwarders {;; };  // ISP's DNS servers

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };

zone "example.com" IN {
        type master;
        file "example.com";
        allow-update { none; };

zone "0.0.10.in-addr.arpa" IN {
        type master;
        file "10.0.0";
        allow-update { none; };

zone "129.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.129";
        allow-update { none; };

In this case, the file "example.com" contains names and addresses of computers that are not visible to the outside world. The public internet sees a completely different set of DNS servers for example.com (provided by ISP of domain host/registrar) which have completely different records. You have to duplicate the external records in your internal zone file but usually these are few (maybe just an A record for www.example.com).

Other internal DNS servers would be simple secondaries of this primary for all the same zones.

The forwarders directive does the "redirection" you seek. All internal computers have resolv.conf's that point only to the internal DNS servers. It is those servers that provide information about both of the separate internal and external worlds. Internal computers do not need to know anything about this internal/external division of DNS namespace.

share|improve this answer
I mainly want to redirect non-public domains to another server, not just the well known top-level donains. –  Gene Vincent Feb 20 '12 at 11:47
@GeneVincent see updated answer –  RedGrittyBrick Feb 20 '12 at 12:06

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