Link to home
Start Free TrialLog in
Avatar of rawandnet
rawandnet

asked on

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";
      };

Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


> 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
Avatar of rawandnet
rawandnet

ASKER

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?
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
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?
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
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
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?
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
Amazing support,
thank you Chris.