$ORIGIN defines a base value from which 'unqualified' name (those without a terminating dot) substitutions are made when processing the zone file.
The @ symbol is a short-hand for the $ORIGIN in zone files.
Using the short-hand @
or the full name example.com.
is therefore equivalent.
$ORIGIN can be specified explicitly in the zone file, but is often implied from the zone name as specified in the Bind configuration file:
// named.conf file fragment
zone "example.com" in{
type master;
file "example.com.zone";
};
and
; example.com.zone file fragment
; no $ORIGIN present and is synthesized from the zone name in named.conf ==> example.com
....
@ IN NS ns1.example.com.
; ns1.example.com. is the name server for example.com.
@ IN MX 10 mx1.example.com.
; mx1.example.com. is the primary mailserver name for example.com.
....
$ORIGIN uk.example.com.
; explicitly define or "reset" $ORIGIN to uk.example.com.
; doing this mid-way in a zone-file is not common practice anymore (if it ever was)
; but it will keep a large single zone-file somewhat more readable.
@ IN NS ns2.example.com.
; functionally identical to
; uk.example.com. IN NS ns2.example.com
; ns2.example.com. is the name server for uk.example.com.
A third option, is that a line in a zone file that starts with neither a hostname, the zone name or the @ shorthand for the zone origin, becomes a continuation of the record above.
@ IN MX 10 mx1.example.com.
IN MX 20 mx2.example.com. ; another record for the @ record above
IN NS ns1.example.com. ; yet another record for the @ record above
IN NS ns2.example.com. ; and a 3rd continuation for the @ record above
is also equivalent to:
@ IN MX 10 mx1.example.com.
example.com. IN MX 20 mx2.example.com.
IN NS ns1.example.com. ; NS record for the example.com. record above
; the continuation can be to set different
; record types for the same resource record name
example.com. IN NS ns2.example.com.
www IN A 10.9.8.7
IN A 192.168.0.1 ; or set multiple (round-robin) records when
; continuing with the same record type.