Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to setup BIND so that it catches any and all requests made to it, and points them to a specific set of NS servers, and a specific A record.

I have around 500 domains, and I'm adding new ones at the rate of 10-15 a day, so I don't want to explicitely add a zone for every domain.

My current setup is: in my named.conf, I have a view (named external) with the following zone in it:

zone "." {
        type master;
        file "ext.zone";
};

This matches all requests.

ext.zone is:

$TTL    3600
@       IN      SOA     . root.nsdomain.com. (
                              1         ; Serial
                         3600         ; Refresh
                          300         ; Retry
                         3600         ; Expire
                         300 )        ; Negative Cache TTL


        IN      NS      ns1.nsdomain.com
        IN      NS      ns2.nsdomain.com

ns1     IN      A       1.2.3.4
ns2     IN      A       1.2.3.5

*.      IN      A       1.2.3.6

so, the goal is: for all NS requests, return ns1.nsdomain.com and ns2.nsdomain.com for all A requests, except where its ns1.nsdomain.com or ns2.nsdomain.com, return 1.2.3.6. For ns1.nsdomain.com return 1.2.3.4, for ns2.nsdomain.com return 1.2.3.5.

This almost works, the only problem is that when I do a dig, I get:

dig @localhost somedomain.com

; > DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 > @localhost somedomain.com
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; opcode: QUERY, status: NOERROR, id: 37733
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;somedomain.com.                        IN      A

;; ANSWER SECTION:
somedomain.com.         3600    IN      A       1.2.3.6 // as expected

;; AUTHORITY SECTION:
.                       3600    IN      NS      ns1.nsdomain.com. // expected, I don't know if the "." at the start is bad, though.
.                       3600    IN      NS      ns2.nsdomain.com. // see above.

;; ADDITIONAL SECTION:
ns1.nsdomain.com.  3600    IN      A       1.2.3.6 // not expected, this should be 1.2.3.4
ns2.nsdomain.com.  3600    IN      A       1.2.3.6 // not expected, this should be 1.2.3.5

How do I fix this? Am I doing something horrible? Is there a better way to do this?

Thanks!

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Your origin for the zone is "." per your configuration. You are creating records for "ns1." and "ns2." instead of "ns1.nsdomain.com." and "ns2.nsdomain.com." Since "ns1.nsdomain.com" and "ns2.nsdomain.com" aren't defined, they are matched by the wildcard.

EDIT: here's an edit of your config and zone:

zone "nsdomain.com." {
        type master;
        file "ext.zone";
};

ext.zone:

$TTL    3600
@       IN      SOA     ns1 root (
                              1         ; Serial
                         3600         ; Refresh
                          300         ; Retry
                         3600         ; Expire
                         300 )        ; Negative Cache TTL


        IN      NS      ns1
        IN      NS      ns2
        IN      A       1.2.3.6


ns1     IN      A       1.2.3.4
ns2     IN      A       1.2.3.5

*      IN      A       1.2.3.6

Everything in the zone is relative to the zone name in the named configuration, so adding a second zone just points to the same file:

zone "newnsdomain.com." {
    type master;
    file "ext.zone";
};
share|improve this answer
    
I decided to try specifying the full domain in the RRs, so I changed: ns1 IN A 1.2.3.4 to ns1.nsdomain.com. IN A 1.2.3.4, this didn't work. Now all my requests return the SOA instead of NS/A. –  Jon Wu Jan 31 '11 at 11:13
    
Can you update or add the new zone? –  Cakemox Jan 31 '11 at 11:16
    
I added a new zone for nsdomain.com, and left the old "." zone alone. in the nsdomain.com zone, I added your ext.zone (renamed to nsdomain.zone). Now requests for any domain except nsdomain.com work like they're supposed to, they return ns1.nsdomain.com/ns2.nsdomain.com with the correct IPs(1.2.3.4/1.23.5). But, any requests for nsdomain.com itself return the SOA and no valid response :(. Close! –  Jon Wu Jan 31 '11 at 11:24
    
You need to explicity add an A record for the apex. The wildcard doesn't cover that. I'll update my example. –  Cakemox Jan 31 '11 at 11:27
    
Thanks, that works! Why do you haveto specify the A bit twice in this zone, but not in the "wildcard" zone (zone ".", my original ext.zone)? Got any good links to read up on this stuff? Thanks again! –  Jon Wu Jan 31 '11 at 11:33

Based on your configuration ns1.somedomain.com is 1.2.3.4 and ns2.somedomain.com is 1.2.3.5. You have to configure the NS server name resolution in the nsdomain.com zone to get the proper IPs.

I hope I make myself clear. Come back to me if you need more info.

share|improve this answer
    
So I should add another zone for nsdomain.com, and set up the NS/A there for nsdomain.com? –  Jon Wu Jan 31 '11 at 11:14
    
So if you have 2 zones like somedomain.com and nsdomain.com you have to setup the nsdomain related info in the proper zone. Short answer is yes, you have to set up another zone. –  Istvan Jan 31 '11 at 12:13

DNS wildcards are evil mostly, so avoid using'em.

so I don't want to explicitely add a zone for every domain.

There're lots of ways to go — from shell scripting till SQL-based DNS-servers.

share|improve this answer
    
Why would be DNS wildcard evil? It is not evil at all.... –  Istvan Jan 31 '11 at 12:12
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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