2 domains in 1 zone file...how?

Mathias Körber mathias at koerber.org
Thu Jan 25 18:23:05 UTC 2001


> If I have domain-a.com and domain-b.com that both point to the same ip =
and
> website, is there a way to combine zone files for both domains in=20
> bind 8?  I
> cannot find any reference to this in the O'Reilly book on bind.

You can do that, though it is not encouraged.
You can only do this on the master/primary for both zones.
Never point the backup files for two slave/secondary zones to the same
file. And never share a file between a master/primary and=20
slave/secondary zone. Never.

You can also not do this if you are using dynamic update, as the =
nameserver
would re-qrite the zonefile and would likely mess things up.

But if you use this only for static zones on the common master server, =
it
is doable (just not recommended)..

>=20
> If someone is doing this, could you post a sample zone file if =
possible?
>=20
> Would it look something like this...?

No. You'd use '@' to mean 'the current zone' and make as much
use of the fact that the $ORIGIN (which is also the zone unless
specifically set) is appended to names not ending in a '.':

>=20
> ******************zone file**************************
>=20
> ; Data file of hostnames in this zone (domain-ab.zone).
> ;
> ????            IN      SOA     ns1.domain.com. root.ns1.domain.com. (

No:=20
  @               IN      SOA     ns1.domain.com. root.ns1.domain.com. (

>                 2001012211  ; Serial
>                 10800       ; Refresh - 3 hours
>                 3600        ; Retry - 1 hour
>                 604800      ; Expire - 1 week
>                 86400       ; Minimum - 24 hours
>            )
> ;
> ; Primary and secondary name servers for this zone
> ;
> domain-a.com     IN      NS      ns1.domain.com.
> domain-b.com     IN      NS      ns1.domain.com.

No, just say:
  @			 IN      NS      ns1.domain.com.

you also listed the same server twice. You need a second
NS record pointing to ns2:
			  IN     NS      ns2.domain.com.

> ;
> ; SMTP mail exchanger
> ;
> domain-a.com.   IN      MX      10 ns1.domain.com.
> domain-b.com.   IN      MX      10 ns1.domain.com.
> domain-a.com.   IN      MX      100 ns2.domain.com.
> domain-b.com.   IN      MX      100 ns2.domain.com.
> domain-a.com.   IN      A       192.192.192.1
> domain-b.com.   IN      A       192.192.192.1

No, replace this with:

  @               IN      MX      10 ns1.domain.com.
                  IN      MX      100 ns2.domain.com.
                  IN      A       192.192.192.1



> ;
> ; Addresses for canonical names and aliases
> localhost               IN      A               127.0.0.1
> loopback                IN      CNAME           localhost

> ;
> $ORIGIN domain-a.com.
The $ORIGIN is not required as it would be set for each zone =
automatically
when loading that zone from the file.

> www                     IN      A               192.192.192.1
> ;ftp                    IN      CNAME           www

Thus you also don't need this block at all:

> ;
> $ORIGIN domain-b.com.
> www                     IN      A               192.192.192.1
> ;ftp                    IN      CNAME           www
> ;

In short, when named loads domain-1.com from this file, '@' means =
'domain-a.com'
and when it loads domain-b.com, it means domain-b.com.

I would again like to say that using the same file is not a good idea,
but you could create a file like this and copy it. It can have the
same contents but actually exist twice under two different names.
Sharing one file makes changes easier if the two zones *always* lok
the same, but makes it very difficult if there is supposed to be
any diffrence in the zonedata. Thus you in the long term fare better =
with
two files.

regards




More information about the bind-users mailing list