mail us  |  mail this page

contact us
training  | 
tech stuff  | 

The DOT in a Zone File

Sometimes you need it, sometimes you don't. At first glance, and even at the fourth glance, it seems confusing.

It is not. The rule is simple and we call it the ORIGIN substitution rule.

If there is a dot at the end of a name in a resource record or directive, the name is qualified and if it contains the whole name including the host then it is a Fully Qualified Domain Name - FQDN. In this case the name as it appears in the RR is used unchanged.

If there is NO dot at the end of the name (a.k.a. label(s) in DNS jargon), the name is unqualified and DNS software adds the value of the last or only $ORIGIN directive. Unqualified names can appear on left-hand names, right-hand names or both. In the absence of an $ORIGIN directive the zone name from the named.conf file for this zone is used to synthesize an $ORIGIN directive. The fragment below illustrates this using A records and CNAME records.

With implicit $ORIGIN statement: In the zone fragment below an implicit $ORIGIN directive is created from the zone file name as noted. In general this is bad practise for two reasons. First, the file is not self-referencing - you need to know information from another source - in this case the zone name for which this file is being used which is defined in the named.conf file (for BIND). Second, it is not readily apparent what value is being substituted. At 3 A.M. when working under stress to bring back service it may not be so apparent. All to save typing a few characters. Just not worth it.

; zone file fragment for example.com
; the named.conf file contains 'zone "example.com"'
; there is no $ORIGIN statement and therefore one is synthesized
; name in the line below is expanded to joe.example.com.
joe               IN      A      192.168.254.3 
; line below - www.example.com. aliased to joe.example.com.
www               IN      CNAME  joe 
; next line is functionally the same as line above
www.example.com. IN      CNAME  joe.example.com.
; and so is this line
www               IN      CNAME  joe.example.com.
; the name in this record defaults to example.com
; assuming it was placed at the zone apex 
                  IN      A      192.168.254.3
; and could have been written as 
example.com.      IN      A      192.168.254.3
; OR
@                 IN      A      192.168.254.3

Easy really!

With explicit $ORIGIN statement: In general, we always suggest that you use an $ORIGIN directive in every zone file because it makes understanding the effects of the above substitution rule much simpler. Here are the same examples as above but with an explicit $ORIGIN directive in the zone file.

; zone file fragment for example.com
$ORIGIN example.com.
....
; name in the line below is expanded to joe.example.com. by adding $ORIGIN
joe               IN      A      192.168.254.3 
; line below - www.example.com. aliased to joe.example.com.
www               IN      CNAME  joe 
; next line is functionally the same as line above
www.example.com. IN      CNAME  joe.example.com.
; and so is this line
www               IN      CNAME  joe.example.com.
; the name in this is record defaults to example.com
; assuming it was placed at the zone apex 
                  IN      A      192.168.254.3
; and could have been written as 
example.com.      IN      A      192.168.254.3
; OR
@                 IN      A      192.168.254.3

Dots before the eyes: Some more examples:

; zone file fragment for example.com 

$ $ORIGIN must terminate with a DOT ALWAYS
$ORIGIN example.com
; in the above case the dot is missing from the $ORIGIN
; using the substitution rule this will give a substitution value of
; example.com.example.com.


; In A RR's the right hand expression is an address not a label
; thus expansion will be applied to the left hand label but not
; the right hand side
joe               IN      A      192.168.254.3 
; line above expands to - joe.example.com. IN A 192.168.254.3

Reverse Mapping Zone Files: A tad messier:

; zone file fragment for 2.168.192.IN-ADDR.ARPA
$ORIGIN 2.168.192.IN-ADDR.ARPA.
....
1      IN PTR joe.example.com.
; In the above case the left hand value is a name (or label) not an address
; and therefore subsitution is applied giving
; 1.2.168.192.IN-ADDR.ARPA.  IN PTR joe.example.com.
; which maps 192.168.2.1 to the host name joe.example.com

; and if you wrote the above PTR like this
1      IN PTR joe
; it will expand to 
; 1.2.168.192.IN-ADDR.ARPA.  IN PTR joe.2.168.192.IN-ADDR.ARPA.
; which is probably not what you intended


Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.

Pro DNS and BIND by Ron Aitchison

Contents

tech info
guides home
dns articles
intro
contents
1 objectives
big picture
2 concepts
3 reverse map
4 dns types
quickstart
5 install bind
6 samples
reference
7 named.conf
8 zone records
operations
9 howtos
10 tools
11 trouble
programming
12 bind api's
security
13 dns security
bits & bytes
15 messages
resources
notes & tips
registration FAQ
dns resources
dns rfcs
change log

Creative Commons License
This work is licensed under a Creative Commons License.

If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C STANDARDS COMPLIANT browser such as Firefox

Search

web zytrax.com

Share

share page via facebook tweet this page

Page

email us Send to a friend feature print this page Decrease font size Increase font size Display full width page

Resources

Systems

FreeBSD
NetBSD
OpenBSD
DragonFlyBSD
Linux.org
Debian Linux

Software

LibreOffice
OpenOffice
Mozilla
GitHub
GNU-Free SW Foundation
get-dns

Organizations

Open Source Initiative
Creative Commons

Misc.

Ibiblio - Library
Open Book Project
Open Directory
Wikipedia

Site

CSS Technology SPF Record Conformant Domain
Copyright © 1994 - 2017 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by super.net.sg
web-master at zytrax
Page modified: October 21 2015.