Correctly writing a Zone File for a nameserver
I need to write a zone file for a new company domain. Let's say the company owns company.com and I need to write a zone file for 2 domains play1.playground.company.com and play2.playground.company.com . When defining the zone file Origin line, do I need to put in the whole FQDN play1.playground.company.com. or just play1.playground is enough? Will the following zone file work out?
$ORIGIN play1.playground.company.com.
$TTL 3600
@ IN SOA ns hostmaster ( 1614244859 7200 3600 1209600 3600 )
@ IN NS ns
@ IN A 1.1.1.1
@ IN MX 10 mail
ns IN A 10.0.0.2
mail IN A 10.0.0.1
www IN CNAME play1.playground.company.com.
wwwtest IN CNAME www
$ORIGIN
defines how unqualified names in your zone file should be completed.
You can use anything and even redefine $ORIGIN
to change that substitution behavior for subsequent records in the same zone file.
But that will probably lead to a complete mess.
$ORIGIN
should be fully qualified and end in . dot.
By convention $ORIGIN
should be set to zone name that zone file belongs to and that is what Bind will do when it is not explicitly defined.
See also https://www.zytrax.com/books/dns/ch8/origin.html
Afterthought: I have also seen zonefiles where $ORIGIN
is set to only the dot .
.
That has the result that effectively no substitution takes place. That forces an zone administrator to always use FQDN's everywhere and means you can't use the @
shorthand but also prevents situations such as the example below where a missing full stop after what was intended as an FQDN results in a CNAME record pointing to play1.playground.company.com.play1.playground.company.com.
$ORIGIN play1.playground.company.com.
www IN CNAME play1.playground.company.com
I don't know if doing that makes a lot more sense but it does make both the record with and without the terminating .
behave identical and as a sloppy zone administrator expects :
$ORIGIN .
www.play1.playground.company.com IN CNAME play1.playground.company.com
www.play1.playground.company.com. IN CNAME play1.playground.company.com.