What is a zone file?
Zone files are extremely important in allowing the Internet to work. As just one example of how useful they are, they help all Internet users to easily navigate to websites.
All websites have an IP address, which looks like 188.8.131.52. If you know the IP address, you can head straight to the website. But there's a couple of problems with this. Firstly, websites have a habit of moving around, and each time this happens you would have to note down the new IP address. If you didn't, you wouldn't be able to find the website. Secondly, most people find that remembering an IP address is pretty difficult. Instead, website names such as google.com are a lot easier to remember. So what we do is give an IP address an easy to remember nickname (called a hostname) and allow anyone who knows the hostname to be diverted to the IP address. This is one common function of a zone file – to act as a record of the IP address that a hostname should divert to.
There's also the added bonus that we can change the IP address of the website, but keep the hostname the same. We just need to update the IP address in the zone file so that anyone who knows the hostname will be directed towards the new IP address.
That is just one function of the zone file. They are also used for routing email, allowing email sent to your domain to be routed to the correct place. When you host your website with Gradwell we provide you with full access to your zone file. We'll set a basic one up for you, but you're free to create a custom one that is more suited to your needs if you wish.
Understanding a basic zone file
To view the zone file currently in use on your domain, login to your hosting control panel and click on Primary DNS in the left hand menu. If you have more than one domain hosted with Gradwell, click on View alongside the one you wish to view the zone file for.
Creating a custom zone file
You cannot edit the default zone files we provide for you, however if you wish, you can create a custom zone file, allowing you to make advanced changes. In all cases you can copy one of the default zone files allowing you to make minor changes.
In your hosting control panel, click on Manage zone files in the left hand menu. Then click on Add DNS zone, which will appear underneath.
Enter a name for the new zone file, and select an existing zone file to copy. Copying an existing file ensures that all the basic settings will be in place when you start editing your zone file (if anything important is missing, you'll discover very quickly that things don't work as you expect!)
Which DNS record type should I use?
Managing zone files can be confusing at first. However, if you take a moment to learn about the different resource record types you use to setup your zone file then you will find life a lot easier.
Resource records are the building blocks of a zone file, and there are several types. Each is used for a particular task, so you simply need to work out what you want to do, and then select the correct record type for that purpose.
|A||Address record||Used for mapping a hostname to an IPv4 address. It allows people to use an easy to remember website name rather than a difficult to remember IP address||You must always us a 32-bit IP address, for example 184.108.40.206|
|AAAA||IPv6 address record||Similar to an A record, except you'd use this if mapping a hostname to an IPv6 address||You must always use a 128-bit IP address, for example 3ffe:1900:4545:3:200:f8ff:fe21:67cf|
|CNAME||Canonical name record||Use if you want to map a hostname to another hostname||You must always specify another hostname and not an IP address|
|MX||Mail exchange record||Use to specify a mail server that will accept emails sent to that domain||All MX records should be in the format of <NUMBER> <HOSTNAME>. You should not use IP addresses. For more information see working with MX records|
|NS||Name server record||Allow you to delegate a subdomain to another name server, in effect allowing another domain to manage the subdomain for you||You must use a hostname, and not an IP address|
|PTR||Pointer record||Often used for reverse DNS, allowing someone who knows an IP address to see what your host/domain is||You must use a hostname, and not an IP address|
|SRV||Service locator||Allows you to define the location of servers for specified services||
SRV records are the only type of record that allow underscores.
You enter values in the Name field in the format of _<SERVICE>._<PROTOCOL> or _<SERVICE>._<PROTOCOL>.hostYou enter values in the Data field in the format of <PRIORITY> <WEIGHT> <PORT> <HOSTNAME>
|TXT||Text record||Allows you to enter human readable text into the zone file|
When working with zone files, you will need to understand the importance of full stops. If you enter a word in the Name field, your domain will automatically be entered on the end. For example, if you typed news into the Name field along with an IP address in the Data field, and your domain is example.com, this IP address would be used when someone attempted to find news.example.com
This makes managing your zone file a lot easier.
It's important to know that your domain will also be added to any hostnames in the Data field unless you add a full stop to tell the zone file not to. Adding a full stop is also known as making it a fully qualified domain name. To help make a bit more sense of this, let's look at an example.
Let’s say you had an FTP server. However, it runs on a server in a different domain to your main example.com domain. You might want to create a memorable name, such as ftp.example.com to make it easier to find.
So you need to put an instruction in your zone file that says that if anyone tries to find ftp.example.com then they will be redirected to another server, specimen.com
You might try to setup a CNAME record, knowing that this allows you to map one hostname to another. In your zone file select CNAME as the record type, enter test in the Name field and specimen.com in the Data field. At first glance this might appear fine, but when you test it in your web browser it doesn’t work. You’ll probably see a “page not found” error message similar to the one below.
If you remember, your zone file will automatically add your domain name to any hostnames you enter. This saves you the effort of having to add it constantly. However, in this case it's also adding your domain (example.com) to the end of specimen.com
So your web browser is actually trying to find specimen.com.example.com, which doesn’t exist.
To solve this problem, you simply need to add a full stop to specimen.com. This tells the zone file that there's no need to add your domain name to the end of it.
A simple way to remember this rule is that:
If the hostname you want to use is in the same domain, you don’t add a full stop. If the hostname you want to use isn’t in the same domain, you need to add a full stop at the end.
Please note that IP addresses must not have a full stop added at the end. You also should place fully qualified domain names in the Name column of your zone file.
MX records are used to specify a name server to send any emails received for that domain. Zone files are flexible enough to allow you to enter more than one mail server, which is useful if one of your mail servers is unavailable for any reason. If this happens, the other mail server that you have specified will be tried.
However, for this to work you do need to put them in order, specifying which one you would like to be tried first (also know as the preference number). To do this you enter the following information alongside the MX record:
A number.... followed by a space.... then the hostname.
To add another mail server, you simply use a different number at the start. The record with the smallest number will be used first. If that mail server cannot be reached, the record with the next lowest number will be tried next, and so on.
It is important to know that you cannot use IP addresses in MX records.If for whatever reason you want to do this, you will first have to create a new A record, and in that A record enter the IP address. Let's look at a worked example.
If you wanted to use the IP address 220.127.116.11, you would first need to create an A record and enter a unique Name for it (for example, mail), with the IP address in the Data field.
Then create the MX record, using the name field after the preference number, for example 10 mail. An example of this is shown the in screenshot below.
You can also see in the screenshot that we have a secondary mail server in the zone file, which finishes with a full stop. For more information on this please see The importance of full stops.
You will usually see * (asterisks) in zone file records. These work as wildcards. These allow the matching of requests for non-existent domain names. Let’s say that your domain is example.com, and somebody types in socks.example.com into their web browser. You haven’t defined the sub-domain of socks in your zone file. However, you have setup the following wildcard:
This means that the person will instead be sent to the IP address 18.104.22.168. If however you eventually add an A record for a socks subdomain, then this record would be used for someone attempting to navigate to socks.example.com
A wildcard can only be used at the start of the hostname, for example you could enter *.dev in the Name field. You cannot enter dev.*
What’s the @ symbol for?
In zone files, the @ symbol simply means “current domain”, and makes managing a zone file easier. So if your domain is example.com this will be used whenever you see the @ symbol in the name column.