Once you have registered your domain name and set up the nameservers, you need to configure your zone file. A zone file is the authoritative record of all entries for your domain. The zone file consists of a header called the Start Of Authority (SOA), which contains things like the default Time To Live (TTL), and the email address of the responsible person. It is best to accept the defaults unless you know what you are doing with this.
The body of the zone file then contains multiple records that tell the DNS server which IP addresses to serve, where your email servers are, and where your nameservers are, amongst other things. This tutorial will explain what each of those entries means. We will cover NS, A, CNAME, MX, TXT, SPF and SRV records briefly. Please see the separate tutorials on SPF, MX and SRV records for more details. This overview tells you what each record does, the basic format, and some specific points to be aware of. Here is an example of DNS Zone file:
The first section is the SOA and we won't cover that in any further detail here. Below this is the records starting with "mydomainname.com. NS record." We will cover each type of record as listed in this example zone file.
The NS record
The NS record is a list of authoritative name servers for this domain. The domain needs this record to tell the DNS system which name servers are authoritative. Other name servers can provide the response but without this entry, they can not be considered an authority. The format is:
Each domain should have at least 2 of these entries.
A and AAAA Records
These two records are the Address records for IPv4 and IPv6. These give the actual physical IP address of the server relating to the relevant hostname. In the above example you can see the following 4 lines:
This is telling anyone looking up either mydomainname.com or www.mydomainname.com that the IPv4 address is 126.96.36.199 and the IPv6 address is 4001:41d0:2:80c4::. For instance, when you type www.mydomainname.com into your web browser, the web browser will do a DNS lookup and one of these two IP addresses will be returned. The browser will then connect to that IP address and send the request. It is a bit like a telephone directory enquirer where you will request the phone number of a person and then you will dial that number. The A and AAAA records are the key to the whole system. Other records rely on these. For instance, the MX records which we will cover next do not point to an IP address they point to hostnames. Without those hostnames having an A or AAAA records they would not work.
The MX record stands for Mail eXchange. This gives a list of one or more mail servers that are available to receive an email for this domain along with a priority to use. In the above example, we only have 1 MX record with a priority of 10. If we had 2 MX records with a priority of 10 and 20, the lower the value the higher the priority. A sending mail server will attempt to contact the server with the highest priority first and will move to the lower priority ones if the first fails. The MX record shouldn't point directly to an IP address, it should point to a hostname such as mail.mydomainname.com or mx10.mydomainname.com. You will then need to add an A or AAAA record for each hostname.
TXT records hold plain text. They perform no direct DNS service, however, they are very important for services such as Domain KEY and SPF.
SPF stands for Sender Policy Framework. It is an anti-spam measure that allows you to tell the world which servers and IP addresses are allowed to send emails on behalf of this domain. Other mail servers can look this up when they receive an email and if the sender is not in the SPF list they can assume it is a forged sender and either reject it or mark it as spam. We will cover this topic in more detail in a separate tutorial.
The SRV record is short for Service record and announces what services a domain provides and the hostnames of those services. An SRV record has the descriptor first, which is an underscore followed by the name of the service. This is then followed by a dot (.) and another underscore then the protocol, another dot and finally the domain name.
After this, there is a priority, a weight, and finally a hostname. The priority is used for load balancing or prioritization of a particular host. If multiple hosts have the same priority then the weight is used to decide which to serve.
For the standardized services, there is rarely need for an SRV record but for things like load balancing and resilience it can be very useful. It is also used for things like mail submission and authorization servers which won't necessarily use standardized hostnames. In our example above we use mail.mydomainname.com, but this could quite easily have been split into smtp.mydomainname.com, imap.domainname.com, and submission.domainname.com. You would use the SRV records to notify client software which hostnames are available for each service. Please see our full tutorial on this subject for more in-depth details. As you can see DNS is relatively straightforward, however, some of the more specialized fields do require a bit of study to understand. Please see our tutorial on SPF, SRV and MX records.