Have you ever heard about DNS zones? If you have been in the hosting world for some time, then you probably have, but it is ok if you didn’t hear about this term. In a DNS system, we can find different domain names that have DNS settings of their own. These settings are what we know as DNS records, and to properly manage them a DNS zone is created.
Usually, we will have a DNS zone for each domain, and that zone will contain important records and settings related to our domain, which would include for example A records, TXT records, etc. This means, of course, that the subdomains will be stored in the DNS zone, but is also possible for a subdomain to have its own DNS zone if we want.
What is a DNS Zone?
A DNS zone, to put it simply, is a portion of the DNS system. Inside this DNS zone, all the DNS records of a domain are stored.
Like we were saying, this includes records like A records, TXT records, MX records and so on. If you ever need to modify the DNS records of a domain, you will need to edit the DNS zone file, because that’s where the data is stored. In the case that you need to add a record o delete a record, then the same file will have to be edited.
For convenience and to keep an order, the best option is to keep all the records of a domain in the same DNS zone, though is possible to keep certain records, like A records (subdomains for example), in a DNS zone that is completely independent of the main domain’s DNS zone.
In this case, is important to make sure that the subdomain is not present in the domain’s zone because this could create a conflict and lead to errors, like the subdomain not working properly, for example.
DNS Zone file
What is the DNS zone file exactly? To put it simply, the DNS zone file is where the data of the DNS Zone is the file, so we can say that the DNS zone and the DNS zone file is one and the same. In this file, the DNS records of our domain are stored. Each line of this file will contain one and only DNS record, it can’t contain two records or more. If we place two records in the same line, the DNS zone will not work properly, so remember to never do this.
And what kind of records can be used in a DNS zone file? All kinds of DNS records, of course, that’s the file’s purpose. It’s very important to keep a certain format when we are editing a DNS zone. First, we must specify the data portion of this record. In the case of an A record, this would be the name of the subdomain.
Then we have to set a TTL, for example, 3600. After that comes the DNS class, which in most cases will be the usual IN, but there’s also another class known as CH.
Next we have the kind of records, for example, A, TXT, MX, SRV, etc. and last but not least we have the host, also called destination. In some cases, for the MX records, for example, we can have additional fields like Priority between the DNS type and the host.
Example of DNS Zone file
Below, we have an example of a DNS zone file from a cPanel server. For this case, the important data like real domain names and IPs have been replaced. We have all the necessary records for a DNS zone to properly work, starting of course with the SOA record, then we have NS records, a few A records for the main domain and subdomains, an MX record for the email, a CNAME record so the subdomain www always point to the same IP of the domain, and a TXT record too.
; cPanel first:184.108.40.206 (update_time):1496160099 Cpanel::ZoneFile::VERSION:1.3 hostname: myserver.mydomain.com latest:220.127.116.11 ; Zone file for mydomain.com $TTL 14400 mydomain.com. 86400 IN SOA dns1.hostingprovider.com. contact.hostingprovider.com. ( 2017053000 ;Serial Number 3600 ;refresh 7200 ;retry 1209600 ;expire 86400 ) mydomain.com. 86400 IN NS dns1.hostingprovider.com. mydomain.com. 86400 IN NS dns2.hostingprovider.com. mydomain.com. 3600 IN A 18.104.22.168.5 localhost 3600 IN A 127.0.0.1 mydomain.com. 3600 IN MX 0 mail.mydomain.com. mail 3600 IN A 22.214.171.124.5 www 3600 IN CNAME mydomain.com. ftp 14400 IN A 126.96.36.199.5 mydomain.com. IN TXT "v=spf1 +a +mx +ip4:188.8.131.52.5 ~all" _dmarc 14400 IN TXT "v=DMARC1; p=none"
DNS Zone management
What is the DNS Zone management? This kind of management includes different tasks related to the DNS zone file, like editing DNS records, adding new records and deleting existing records. A proper management of the DNS zone is important to keep it working.
If the wrong data is inserted in the zone, then it won’t work as expected and it could lead to errors when we try to access a website, send an email, etc. Always check twice before making changes in a DNS zone, make sure the host is right, the TTL, the DNS class, the data field and the type of record, and also verify that there is only one record per line, never place two records on the same line.
Depending on the system you are using to store DNS zone files, you can edit them through a control panel or using a Terminal app. In the case of control panels like cPanel, you will have a graphic interface to edit and manage your DNS zone according to your needs.
This will very helpful to add records, modify records or delete records stored in the DNS zone.
If there is no graphic interface, then you have to login into the server that hosts the DNS zone and edits the file manually. For this task, tools like nano are very helpful, though you will have to edit the DNS zone file manually like any plain TXT file, which, in the end, is what a DNS zone is.