11

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.example.com
        IN      NS      ns2.example.com

ns1     IN      A       192.0.2.4
ns2     IN      A       192.0.2.5

*.      IN      A       192.0.2.6

so, the goal is: for all NS requests, return ns1.example.com and ns2.example.com for all A requests, except where it is ns1.example.com or ns2.example.com, return 192.0.2.6. For ns1.example.com return 192.0.2.4, for ns2.example.com return 192.0.2.5.

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

dig @localhost somedomain.example

; > DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 > @localhost somedomain.example
; (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.example.                        IN      A

;; ANSWER SECTION:
somedomain.example.         3600    IN      A       192.0.2.6 // as expected

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

;; ADDITIONAL SECTION:
ns1.example.com.  3600    IN      A       192.0.2.6 // not expected, this should be 192.0.2.4
ns2.example.com.  3600    IN      A       192.0.2.6 // not expected, this should be 192.0.2.5

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

10

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

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

zone "example.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       192.0.2.6


ns1     IN      A       192.0.2.4
ns2     IN      A       192.0.2.5

*      IN      A       192.0.2.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 "example.net." {
    type master;
    file "ext.zone";
};
  • 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
0

Based on your configuration ns1.example.com is 192.0.2.4 and ns2.example.com is 192.0.2.5. You have to configure the NS server name resolution in the example.com zone to get the proper IPs.

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

  • 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
-4

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.

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.