Solved

Configure bind with multiple domains

Posted on 2011-02-17
10
694 Views
Last Modified: 2012-05-11
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
Comment
Question by:rawandnet
  • 5
  • 5
10 Comments
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34914210

> 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
 

Author Comment

by:rawandnet
ID: 34914785
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
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34914880
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
 

Author Comment

by:rawandnet
ID: 34915363
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
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 34915412

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:rawandnet
ID: 34936851
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
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34936866
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
 

Author Comment

by:rawandnet
ID: 34936986
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
 
LVL 70

Expert Comment

by:Chris Dent
ID: 34937118
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
 

Author Closing Comment

by:rawandnet
ID: 34958493
Amazing support,
thank you Chris.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now