Define a domains addresses sole in terms of another

Chris Buxton cbuxton at
Mon Jul 9 21:50:40 UTC 2007

You cannot do exactly what you are describing. For example:

@	SOA	[data...]
	MX	10
mail	CNAME
webmail	CNAME

This works, but is missing the A record named "". You  
cannot replace such an A record with a CNAME record, because a CNAME  
record may not have the same name as any other record (except certain  
DNSSEC-related records). So, to complete the example:

@	A

So this does not completely achieve your stated goal.

Another approach to solving this problem is what Stephane Bortzmeyer  
suggested: Use just one zone file for all your virtual domains. That  
way, if you need to change the web server's (mail server's) address  
across all zones, you can edit the one file and reload all those  
zones. You could then eliminate all your CNAME records (since CNAME  
records can be tricky and should be avoided unless you're confident  
in your understanding of them), like this:

@	SOA	[data...]
	MX	10
www	A
webmail	A
ftp	A
mail	A

Note, no $ORIGIN statement - you're relying on BIND's default origin  
of the zone name, which is specified in named.conf and not  
(necessarily) in the zone file itself.

Or you could simply ignore the problem. Create all your zones as  
normal, with IP addresses sprinkled throughout as normal. Then, if  
you need to change an address, use sed or perl. For example, to just  
change the address of the 'mail' A record, assuming you always use  
tabs between fields and omit class and TTL fields:

sed -i ".bak" 's/^mail	A	A' /path/to/master/ 

Or, using perl:

perl -pi -e 's{^mail	A}{mail	A}' /path/to/master/zone- 

Someone with a better grasp of regular expressions (or more time on  
their hands) than I could construct a more flexible search.

Chris Buxton
Men & Mice

On Jul 9, 2007, at 5:08 AM, John Steel wrote:

> Say I have this definition:
> $TTL    86400
> @       IN      SOA (
>                         1132657947      ; Serial
>                         10800   ; Refresh
>                         3600    ; Retry
>                         604800  ; Expire
>                         86400 ) ; Minimum
>             IN NS
>             IN NS
>             IN NS
>          IN A
>             IN A
> www                              IN CNAME
> webmail                          IN CNAME   www
> ftp                              IN CNAME   www
> mail                             IN CNAME   www
>             IN MX  10
> As there are many other parked domains, plus TLD variations of  
> it would be useful to define their recs soley in terms of the  
> above. In
> other words,
> where appears in these slave domains I really want something
> like,
> and no IP addresses. The point is during server moves etc I would only
> need to update the
> 1 record, rather than all the individual ones as at present. Is this
> possible please?
> Thanks.
> -- John
> --------------------------
> john.steel at

More information about the bind-users mailing list