Define a domains addresses sole in terms of another
Chris Buxton
cbuxton at menandmice.com
Mon Jul 9 21:50:40 UTC 2007
You cannot do exactly what you are describing. For example:
$ORIGIN example2.com.
@ SOA [data...]
NS ns.example1.com.
NS ns0.example1.com.
NS ns0.example1.net.
MX 10 mail.example1.com.
www CNAME www.example1.com.
ftp CNAME www.example1.com.
mail CNAME mail.example1.com.
webmail CNAME mail.example1.com.
This works, but is missing the A record named "example2.com.". 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 1.2.3.4
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...]
NS ns.example1.com.
NS ns0.example1.com.
NS ns0.example1.net.
MX 10 mail.example1.com.
A 1.2.3.4
www A 1.2.3.4
webmail A 1.2.3.4
ftp A 1.2.3.4
mail A 1.2.3.4
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 1.2.3.4/mail A 4.3.2.1/' /path/to/master/
zone-files
Or, using perl:
perl -pi -e 's{^mail A 1.2.3.4}{mail A 4.3.2.1}' /path/to/master/zone-
files
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 ns.example1.com. system.admin.example1.com. (
> 1132657947 ; Serial
> 10800 ; Refresh
> 3600 ; Retry
> 604800 ; Expire
> 86400 ) ; Minimum
>
> example1.com. IN NS ns.example1.com.
> example1.com. IN NS ns0.example1.com.
> example1.com. IN NS ns0.example1.net.
>
> ns.example1.com. IN A 1.2.3.4
> example1.com. IN A 1.2.3.4
>
> www IN CNAME example1.com.
> webmail IN CNAME www
> ftp IN CNAME www
> mail IN CNAME www
>
> example1.com. IN MX 10 mail.example1.com.
>
> As there are many other parked domains, plus TLD variations of
> example1.com,
> it would be useful to define their recs soley in terms of the
> above. In
> other words,
> where 1.2.3.4 appears in these slave domains I really want something
> like example1.com,
> 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
> --------------------------
> http://www.phonewebcam.com
> john.steel at phonewebcam.com
>
>
More information about the bind-users
mailing list