The A, AAAA, and CNAME resource records
Authoritative name servers use the domain's zone file to translate names into IP addresses. The A and AAAA resource records map IP addresses with names. These records are also known as host records. You need to create host records for all resources available inside the domain. If you don't add a host record for the resource available within the domain, you cannot access it. Let's understand why this would happen.
- To access a resource, you need the resource's IP address.
- You can get the resource's IP address only from the authoritative name server.
- The authoritative name server uses the zone file to tell the resource's IP address.
- In the zone file, a host record maps a name and the IP address.
- Since you did not add a host record for the resource, the authoritative name server fails to resolve the resource name into the IP address. Without knowing the IP address of a resource, you can not access it.
Adding or creating the A and AAAA records
A host record uses the following syntax.
name TTL class resource-record-type IP address
The following image shows the zone file of the example.com domain. It contains four host records.

Let's understand the above records field-by-field.
The name Field
This field defines the name of the host or service whose IP address you want to make publicly accessible. There are two methods to specify a name in this field. These methods are FQDN and relative. In the FQDN method, you type the complete name of the host or service. It includes the names of all parent domains. It always ends with a dot. In the relative method, you type only the hostname or the short name of the host or service. You don't need to add the parent domain's name to it. It never ends with a dot.
Regardless of the method you use to specify the name in this file, DNS always processes the given name in the FQDN format. If you specify an FQDN name, it uses the name as it is. If you provide a relative name, DNS converts it into the FQDN name using the $ORIGIN directive's value.
The $ORIGIN directive is variable. Administrators use it to save the domain's name. In our example zone file, all host records are defined using the relative name. To convert these names into FQDN names, DNS will use the $ORIGIN directive's value.

The TTL Field
This field defines how long other name servers and resolver systems can cache this record. After this time, they need to fetch this record again. If you leave this field empty, DNS uses the value of the $TTL directive. The $TTL directive defines the default TTL value. If you leave the TTL field empty in any record, it uses the $TTL directive's value in that field.

The class type Field
This field defines the class type of this record. There are three classes: IN, CH, and HS. Currently, only the IN class is used. The CH and HS classes were used when the Internet was an in-house project in the MiT lab. CH stands for CHAOS. It is an MIT LAN protocol. HS stands for Hesiod. It is an information service used at MIT. IN stands for the Internet that we use today.
The resource-record-type Field
This field defines the type of record. The A record maps an IPv4 address with the name of a host or a service. The AAAA record maps an IPv6 address with the name of a host or a service.
The IP address Field
This field defines the IP address we want to map with the name specified in the name field. There are two types of IP addresses: IPv4 and IPv6. The resource type A maps an IPv4 address with the domain name, whereas the resource type AAAA maps an IPv6 address.
In our example zone file, we mapped IPv4 addresses with names. If we map IPv6 addresses with names, the file will look like the following.

Mapping multiple IP addresses with a name
You can map multiple IP addresses to the same name. This feature allows you to run the same service on multiple hosts. Generally, administrators run critical services on more than one host for backup and redundancy purposes. For example, they can run a web service on two or more hosts. In that case, they must map their IP addresses with the web service.
Let's understand this feature through our example. Currently, in our example, the web service is available only on the host 192.168.0.3. Suppose we configure the web service on two additional servers whose IP addresses are 192.168.0.9 and 192.168.0.10. In that case, we need to add two more A records for these hosts.

If you map multiple IP addresses with the same name, DNS provides an IP address for the name in a round-robin or random order. You can define this order by configuration directives.
Mapping multiple names with a single IP address
You can also map more than one name with a single IP address. You can use this feature when you run multiple services on the same host. For example, if you have a small website and use only a few email addresses for management and communication purposes, you can run the mail, web, and FTP services on the same server. This setup allows you to save the cost of additional servers.
Let's understand this feature through our example. Currently, in our example, all services are available on individual servers. Suppose we configure the mail, web (www), and FTP services on a single server whose IP address is 192.168.0.2. In this situation, we must map these services with the IP address 192.168.0.2.

The CNAME resource record type
The CNAME resource record type assigns an alias to the name of an existing host or service. It uses the following syntax.
alias-name TTL class resource-record-type canonical-name
In the above syntax, the TTL and class fields have the same meanings as the TTL and class fields have in the host records.
The alias-name field defines the name you want to use for the existing name specified in the canonical-name field.
The resource-record-type field defines the record type. The value CNAME indicates this record is an alias name for the existing name.
The canonical-name field defines the name you want to use to access the alias name specified in the alias-name field. This record type is used when you want to access a service or a host from another name. You can also use this record to hide your internal network structure from external users.
Let's understand it through our example. Suppose we run the web service on a host called myWebServer. In this situation, we can map the name www (web service) with the name myWebServer. After this, DNS will translate the name www into the IP address of myWebServer. Users will access the web service running on the IP address of myWebServer by using the name www.
The following image shows how to add a CNAME for the web service in our example zone file.

Addressing a website with or without www
Generally, administrators configure a web server to serve websites with and without the www. This setup needs a CNAME record in the zone file for the web service. To achieve this goal, add a host (A) record for the domain name and then configure the www as the alias name for that domain name.
Let's understand this through our example. In our example, the domain name is example.com. It hosts a website we want to access using both names: www.example.com and example.com.
In this case, first, we will create a host record for the domain name. Then, we will configure www as the alias name for the domain name.
The following image shows how to add both records.

A zone file only translates names into IP addresses. It does not run or provide any other service. If you add an alias name for a service, you must configure that service to respond on both canonical (actual) and alias names. In the previous example, you must configure the webserver to respond to both names: www.example.com and example.com.
Conclusion
DNS uses zone files to translate names into IP addresses. Zone files use resource records to map names and IP addresses. There are various types of resource records. In this tutorial, I explained how to create and manage A, AAAA, and CNAME resource record types.
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
By ComputerNetworkingNotes Updated on 2025-10-02