The TTL and ORIGIN directives in the zone file
DNS saves its database in zone files. A zone file stores records of a particular domain in simple text format. Zone files use variables for seamless management and administration. The DNS system uses the term directive for a variable. If you are familiar with any programming language, you can easily understand the purpose of a directive in the zone file. It does the same thing a variable does in the programming language. In simple words, a directive is a zone file's variable.
A directive starts with a dollar sign. It stores value. DNS replaces a directive with its value when it processes the zone file. There are two primary directives: $TTL and $ORIGIN.
$TTL
This directive is mandatory. It defines a default Time to Live (TTL) value for resource records. All resource records have the TTL field. If you want to use a specific TTL value for the record, you can configure its TTL field. To use the default TTL value for a record, leave the record's TTL field empty. While processing records, DNS uses the default TTL value in all blank TTL fields.
DNS service includes the TTL value in each record it serves from this file. Other DNS servers and resolver systems that receive a record served from this file use the TTL value to cache the record. For example, if the TTL value of a record is one day, resolver systems and other DNS servers can cache the record for one day. After that, they must have to retrieve the same record again.
The following image shows how the DNS service uses the $TTL directive's value to configure the resource records' TTL value.

By default, the TTL directive accepts time value in seconds. If you want to specify the time in other formats, you must use related keywords. These keywords are m for minutes, h for hours, d for days, and w for weeks.
The following examples set this directive's value to 2 days in different formats. You can use whatever format you like.
$TTL 172800 ; 2 days in seconds 60 * 60 * 24 * 2 $TTL 2880m ; 2 days in minutes 60 * 24 * 2 $TTL 48h ; 2 days in hours 24 * 2 $TTL 2d ; 2 days
$ORIGIN
DNS uses a zone file to translate names into IP addresses. There are four ways to define a name in the zone file. You can specify a fully qualified domain name, a relative name, a single @ character, and a blank space.
- If you use an FQDN name, DNS uses it as it is.
- If you use a relative name, DNS uses the $ORIGIN directive's value to convert it into the FQDN name.
- If you use a single character @, DNS uses the value of the $ORIGIN directive.
- If you use a blank space or leave the field empty, DNS uses the value of the name field of the previous record. If that is not available, it uses the value of the $ORIGIN directive.
The $ORIGIN directive defines the domain or zone name. You can use it anywhere in the zone file. DNS uses it to convert all relative names appearing after it into FQDN names. The zone file considers all names that do not end with a dot as relative names. An FQDN (fully qualified domain name) ends with a dot and denotes the complete name. The following image shows how the DNS service uses the $ORIGIN directive's value to convert relative names into FQDN names.

You can use this directive multiple times. In that case, DNS will use a directive's value until it finds the succeeding directive.
The following examples show how DNS processes this directive.
$ORIGIN example.com. ; It defines the value of this directive to example.com. ; The following is a resource record. It uses a relative name to define the host www www IN A 192.168.2.2 ; DNS will read and process the above hostname name as www.example.com. $ORIGIN test.com; It defines the new value of this directive to test.com ; The following is another resource record. It uses a relative name to define the host ftp ftp IN A 192.168.2.5 ; DNS will read and process the above hostname name as ftp.test.com.
This $ORIGIN directive is optional. If you do not set its value, DNS uses the domain or zone name configured in the named.conf file as the default value of this directive to process all records. For example, if you use relative names in the file without configuring this directive, DNS uses the domain or zone name configured in the named.conf file to convert them into FQDN names.
This tutorial is part of the following tutorial series on DNS server concepts and configurations.
Chapter 01 How to configure DNS Server in Linux
Chapter 02 DNS Basic Concepts, Fundamentals, and Terminology
Chapter 03 DNS Server and Query Types Explained
Chapter 04 The /etc/hosts, /etc/resolv.conf, and /etc/nsswitch.conf files
Chapter 05 The dig command on Linux
Chapter 06 The nslookup command on Linux
Chapter 07 Change or specify the DNS server to the nslookup command
Chapter 08 DNS zone File Format
Chapter 09 The TTL and ORIGIN directives in the zone file
Chapter 10 Types of resources records in zone files
Chapter 11 The SOA Record Explained in the DNS zone file
Chapter 12 The NS Record, Glue record, and Lame Delegation
Chapter 13 The MX record in a zone file explained
Chapter 14 The a, aaaa, and cname DNS record types
Chapter 15 The pointer (PTR) record and Reverse mapping Explained
Chapter 16 How to configure a caching-only name server
Chapter 17 How to configure DNS Forwarding and a forwarder name server
Chapter 18 How to configure a primary or master authoritative name server
Chapter 19 How to configure a secondary or slave authoritative name server
Chapter 20 How to configure reverse mapping on DNS name servers
Author Laxmi Goswami Updated on 2025-10-04