Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 703
  • Last Modified:

Configure bind with multiple domains

Hi guys,
I have a domain name that connect to a zone file example.com.db, I have been asked to add another domain name on the same BIND server, in that case I have to create another zone file.  Some of my questions might be relevant:
- does each nameserver has to have a different public domain?
ns1. example.co.uk 62.x.x.1
ns2. example.co.uk 62.x.x.2
ns1. example.com 62.x.x.3
ns2. example.com 62.x.x.4

OR they can have same IP addresses as follow:
ns1. example.co.uk 62.x.x.1
ns2. example.co.uk 62.x.x.2
ns1. example.com 62.x.x.1
ns2. example.com 62.x.x.2



zone "example.co.uk" {
            type master;
            files "master/example.com.db";
      };
zone "example.com" {
            type master;
            files "master/example.net.db";
      };

0
rawandnet
Asked:
rawandnet
  • 5
  • 5
1 Solution
 
Chris DentPowerShell DeveloperCommented:

> does each nameserver has to have a different public IP?

No.

You don't even need to change the name server name for each zone. e.g.
; example.co.uk
@   IN SOA  ns1.example.com.  hostmaster.example.com.  ( Stuff )

    IN NS   ns1.example.com.
    IN NS   ns2.example.com.

bob IN A    1.2.3.4

Open in new window

Chris
0
 
rawandnetAuthor Commented:
Following is my main zone file for example.co.uk:

$ORIGIN example.co.uk.
$TTL 86400 ; seconds
@           IN SOA  example.co.uk. hostmaster.example.co.uk. (
                                20101028   ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                10800      ; minimum change to 600
                                )

                        IN NS           ns1.example.co.uk.
                        IN NS           ns2.example.co.uk.
                        IN MX 0         exch01.example.co.uk.
                        IN MX 10       exch02.example.co.uk.
@                       IN A            77.92.69.228
ns1                     IN A            63.207.201.100
ns2                     IN A            63.207.201.101
exch01               IN A            63.207.201.18
exch02               IN A            63.207.201.19
www                 IN A            77.92.69.228
autodiscover      IN A            63.207.201.118
webmail              IN A            63.207.201.118
exch01               IN A            63.207.201.116
exch02               IN A            63.201.192.166
www.exch02    IN CNAME        exch02.example.co.uk.


I do need these records to be under example.com, don’t you think that I have to create another zone file as follow:
$ORIGIN example.com.
$TTL 86400 ; seconds
@           IN SOA  example.com. hostmaster.example.com. (
                                20101028   ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                10800      ; minimum change to 600
                                )

                        IN NS           ns1.example.com.
                        IN NS           ns2.example.com.
                        IN MX 0         exch01.example.com.
                        IN MX 10       exch02.example.com.
@                    IN A            77.92.69.228
ns1                  IN A            63.207.201.100
ns2                  IN A            63.207.201.101
exch01            IN A            63.207.201.18
exch02            IN A            63.207.201.19
www              IN A            77.92.69.228
autodiscover   IN A            63.207.201.118
webmail           IN A            63.207.201.118
exch01            IN A            63.207.201.116
exch02            IN A            63.201.192.166
www.exch02 IN CNAME        exch02.example.com.

if this sin't correct; can you please rearrange it to merge both together, and tell me if some one asked for webmail.example.com. how do they find it if the zone file is under example.co.uk?
0
 
Chris DentPowerShell DeveloperCommented:
It's not quite correct, your SOA record is wrong. But you can declare the name servers like that if you wish, equally, you can declare them once and use the same across all zones.

For example:
$ORIGIN example.co.uk.
$TTL 86400 ; seconds
@           IN SOA  ns1 hostmaster (
                                20101028   ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                10800      ; minimum change to 600
                                )

              IN NS           ns1
              IN NS           ns2
              IN MX 0         exch01
              IN MX 10       exch02

              IN A            77.92.69.228

ns1           IN A            63.207.201.100
ns2           IN A            63.207.201.101
exch01        IN A            63.207.201.18
exch02        IN A            63.207.201.19
www           IN A            77.92.69.228
autodiscover  IN A            63.207.201.118
webmail       IN A            63.207.201.118
exch01        IN A            63.207.201.116
exch02        IN A            63.201.192.166
www.exch02    IN CNAME        exch02

Open in new window

And example.com:
$ORIGIN example.com.
$TTL 86400 ; seconds
@           IN SOA  ns1.example.co.uk. hostmaster.example.co.uk. (
                                20101028   ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                10800      ; minimum change to 600
                                )

              IN NS           ns1.example.co.uk.
              IN NS           ns2.example.co.uk.
              IN MX 0         exch01
              IN MX 10        exch02

              IN A            77.92.69.228

exch01        IN A            63.207.201.18
exch02        IN A            63.207.201.19
www           IN A            77.92.69.228
autodiscover  IN A            63.207.201.118
webmail       IN A            63.207.201.118
exch01        IN A            63.207.201.116
exch02        IN A            63.201.192.166
www.exch02    IN CNAME        exch02

Open in new window

Or you could just use the first zone file for all zones (given the similarity), as long as the names within the zone are relative (not absolute, e.g. ns1 instead of ns1.domain.com.).

Which name is used depends on named.conf, the zone name is inherited from there, not explicitly listed in the zone file itself.

Chris
0
Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

 
rawandnetAuthor Commented:
sorry for asking and repeating question, I am still confused.
from your example i sill need two zone file. and under named.conf i have to add
zone "example.co.uk" {
            type master;
            files "master/example.co.uk";
      };
zone "example.com" {
            type master;
            files "master/example.comnet.db";
      };


and if new record nned to be added, i would have to add it under both zone files?
0
 
Chris DentPowerShell DeveloperCommented:

You could just have the first zone file (this one):
; example.master.db
$TTL 86400 ; seconds
@           IN SOA  ns1 hostmaster (
                                20101028   ; serial
                                10800      ; refresh (3 hours)
                                900        ; retry (15 minutes)
                                604800     ; expire (1 week)
                                10800      ; minimum change to 600
                                )

              IN NS           ns1
              IN NS           ns2
              IN MX 0         exch01
              IN MX 10        exch02

              IN A            77.92.69.228

ns1           IN A            63.207.201.100
ns2           IN A            63.207.201.101
exch01        IN A            63.207.201.18
exch02        IN A            63.207.201.19
www           IN A            77.92.69.228
autodiscover  IN A            63.207.201.118
webmail       IN A            63.207.201.118
exch01        IN A            63.207.201.116
exch02        IN A            63.201.192.166
www.exch02    IN CNAME        exch02

Open in new window

Then you can have this definition for the zones in named.conf:
zone "example.co.uk" {
            type master;
            files "master/example.master.db";
};

zone "example.com" {
            type master;
            files "master/example.master.db";
};

Open in new window

Note that I removed the $ORIGIN statement, you can't have that one and have it work. $ORIGIN will inherit from named.conf, so it will work as is.

Then you only have to maintain one zone file.

Chris
0
 
rawandnetAuthor Commented:
It works thanks. But how can I deal with sub domains.

$ORIGIN stud.example.co.uk.
stud.example.co.uk.     IN MX 0         studexch01.stud.example.co.uk.
stud.example.co.uk.     IN MX 10        studexch02.stud.example.co.uk.
studexch01              IN A            62.201.202.16
studexch02              IN A            62.201.202.17

changed it to:

$ORIGIN stud.example.
stud.example.           IN MX 0         studexch01.stud.example
stud.example.           IN MX 10        studexch02.stud.example
studexch01              IN A            62.201.202.16
studexch02              IN A            62.201.202.17

errors I am getting:
named-checkzone example.org db.example.internal
db.example.org.internal:45: ignoring out-of-zone data (stud.example)
0
 
Chris DentPowerShell DeveloperCommented:
If you want it in both domains, you just have to think relative and leave the $ORIGIN alone :)
stud             IN MX 0   studexch01.stud
stud             IN MX 10  studexch02.stud
studexch01.stud  IN A      62.201.202.16
studexch02.stud  IN A      62.201.202.17

Open in new window

The existing origin (example.com or example.co.uk) will be applied to the records in either case as none of them are terminated with a period (.).

Chris
0
 
rawandnetAuthor Commented:
It is all good.  Do you think this is right way to do or better having two zone files?  How this is been done normally.  Does it have any disadvantages?
0
 
Chris DentPowerShell DeveloperCommented:
I use the same approach on my public DNS server, a single zone for for multiple domains. There's nothing wrong with doing it that way, and if you out-grow it you can always split down into two files again.

Chris
0
 
rawandnetAuthor Commented:
Amazing support,
thank you Chris.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now