0

My domain provider's config tool doesn't seem to support what I'm trying to do and I'm unsure of the proper BIND syntax for the below - any pointers appreciated!

I've got separate physical production servers and staging servers and I'd like domain.org to point to production, and staging.domain.org to point to the staging server + have m/www/api prefixes for each server.

Here's what I think I need in my zone file for domain.org:

@ 10800 IN A $production-IP
staging 10800 IN A $staging-IP
api 10800 IN CNAME domain.org
api 10800 IN CNAME staging.domain.org.
m 10800 IN CNAME domain.org.
m 10800 IN CNAME staging.domain.org.
www 10800 IN CNAME domain.org.
www 10800 IN CNAME staging.domain.org. 

But I wonder if that's still ambiguous for BIND or if these are just a bunch of duplicate records?

Thanks!

Bantamug
  • 101

3 Answers3

1

All names that do not end with . are qualified by the current domain setting. If that's domain.org your proposed configuration will look like this:

domain.org 10800 IN A $production-IP
staging.domain.org 10800 IN A $staging-IP
api.domain.org 10800 IN CNAME domain.org.domain.org.
api.domain.org 10800 IN CNAME staging.domain.org.
m.domain.org 10800 IN CNAME domain.org.
m.domain.org 10800 IN CNAME staging.domain.org.
www.domain.org 10800 IN CNAME domain.org.
www.domain.org 10800 IN CNAME staging.domain.org.

I suspect that's not what you want. You can try either of these instead, but neither will really save you very much:

Option 1

domain.org 10800 IN A $production-IP
staging.domain.org 10800 IN A $staging-IP
api 10800 IN CNAME domain.org.
m 10800 IN CNAME domain.org.
www 10800 IN CNAME domain.org.
api.staging 10800 IN CNAME staging.domain.org.
m.staging 10800 IN CNAME staging.domain.org.
www.staging 10800 IN CNAME staging.domain.org.

Option 2

$ORIGIN domain.org.
@ 10800 IN A $production-IP
api 10800 IN CNAME domain.org.
m 10800 IN CNAME domain.org.
www 10800 IN CNAME domain.org.

$ORIGIN staging.domain.org.
@ 10800 IN A $staging-IP
api 10800 IN CNAME staging.domain.org.
m 10800 IN CNAME staging.domain.org.
www 10800 IN CNAME staging.domain.org.
roaima
  • 1,591
  • 14
  • 28
0

IMHO your syntax is incorrect.... this is the right syntax:

@ 10800 IN A $production-IP
staging 10800 IN A $staging-IP
api 10800 IN CNAME domain.org
api.staging 10800 IN CNAME staging.domain.org.
m 10800 IN CNAME domain.org.
m.staging 10800 IN CNAME staging.domain.org.
www 10800 IN CNAME domain.org.
www.staging 10800 IN CNAME staging.domain.org.

(your can see that you defined api, m, and www twice pointing to different places... when you read these syntax, api by itself --and not dot after it, really reads api.mydomain.org... when you have api.staging --not dot at the end, what you are "saying" is api.staging.mydomain.org.)

Also... your TTL is 3 hours (10800... seconds;) in the "old times" that was OK... in my dns servers I use no more than 30 minutes, with not a terrible load on the server :)

Cheers!

Marcos

0

You need different left-hand-side labels to support the prefixed names for production and staging. As written there's no way to distinguish m etc between the two, because you've created two entries for m.domain.org, etc.

The simplest method is to use the $ORIGIN directive twice, combined with @ to reference the current origin:

$TTL 10800        ; to avoid repetition
$ORIGIN domain.org.
@   IN A $production-IP
api IN CNAME @
m   IN CNAME @
www IN CNAME @

$ORIGIN staging   ; NB - implicitly adds current $ORIGIN
@   IN A $staging-IP
api IN CNAME @
m   IN CNAME @
www IN CNAME @
Alnitak
  • 21,191
  • 3
  • 52
  • 82