What is DNS?
The Domain Name System (DNS) is one of the systems that make the internet as we know it possible. The DNS is most often equated to a telephone directory. It translates human-readable hostnames and URIs to machine-readable IP addresses. It is because of this system that a user can browse to the address www.google.com and be directed to the correct servers, which are identifiable only by their IP addresses, which are in not directly related to the URIs which point to them.
A domain's zone file (the complete table of that domain's DNS records) consists of a number of Resource Records (RRs). Each RR, or DNS record, will be of s certain type, and will ultimately translate URIs to IPs.
RRs include the following data: Hostname, Type of record, Address/content, Priority, and TTL.
- Hostname: The fully qualified domain name being pointed or defined.
- Type: The are various types of RR, which will be covered in more detail below. Some types are A, CNAME, and MX.
- Address/Content: The address to which the hostname should be translated. Depending on the type of record, this address can be a domain name, or an IP. Some records don't need an address at all: TXT records for instance can contain any text.
- Priority: Usually encountered when there are multiple MX records, priority specifies in which order the various addresses should be tried. If the first address is unavailable, the query is performed again, using a less prioritised address. The highest priority record will have the lowest priority value, and these need only be relative, not sequential. For example, if a domain has 3 MX records, they can be prioritised in order from most to least important with the values 1, 2, and 3; 10, 20, and 30; 100, 300, and 500, and so forth. If a record is the only one of its kind, as does not need to be prioritised, the value is set to 0.
A domain's zonefile (complete DNS list) always starts with the Start Of Authority record (SOA).
- The SOA contains:
- The name of the host where the file was created (the primary nameserver)
- The email address of the administrator for that domain (the @ in the address must be replaced with a dot)
- The serial number of that zone file (this can be any number, but it must be increased by 1 every time the DNS is changed).
Icon manages the SOA record automatically, but here is an example of what an SOA record looks like:
|imaginet.co.za||SOA||ns1.imaginet.co.za dns-admin.imaginet.co.za 2012011300||3600|
The Name Server (NS) Record specifies the autoritative nameserver for that domain. One domain can have a number of nameservers. Here is an excerpt from the imaginet domain's zone file:
An A Record translates a domain name to an IP. The "A" is for "Address".
- When browsing to www.imaginet.co.za, your browser will need to be directed to the server which hosts the Imaginet website. This server's IP is 126.96.36.199. The A record will therefore look as follows:
- If we want the website to be accessible whether or not the www is entered, there will need to be an A record for the domain name without the www:
- When browsing to printer.imaginet.co.za you will need to be directed to the printer, not the website. The printer's IP is 192.168.100.141. That record will therefore be:
CNAME records translate one hostname to another. "CNAME" is short for "canonical name". If a hostname has a CNAME record, it is not allowed to have any other DNS records, as any others will be overridden by the CNAME.
- If we wanted our website to be accessible via www.imaginet.co.za, site.imaginet.co.za, web.imaginet.co.za, and shop.imaginet.co.za, we woould need to create the following DNS records:
- Best practice dictates that a CNAME should not be pointed to another CNAME (or to any other record type which does not point to an IP). More info on DNS best practice can be found in various RFC, including RFC 1912.
The characteristic information in an MX record is the fully qualified domain name of a mail host and a preference value. The host name must map directly to one or more address record (A, or AAAA) in the DNS, and must not point to any CNAME records.
When an e-mail message is sent through the Internet, the sending mail transfer agent queries the Domain Name System for MX records of each recipient's domain name. This query returns a list of host names of mail exchange servers accepting incoming mail for that domain and their preferences. The sending agent then attempts to establish an SMTP connection to one of these servers, starting with the one with the smallest preference number, delivering the message to the first server with which a connection can be made. If no MX records were present, the server falls back to A, that is to say, it makes a request for the A record of the same domain.
- For domains hosted by Imaginet, the MX records are pointed to default-mx.imaginet.co.za, which in turn translates to the IP of our mail server.
- Many clients make use of Google to host their mail. In this case, the client will have a number of MX records, all pointing to various Google servers. These records will be prioritised differently. The following example uses the imaginet domain. This is how imaginet.co.za's MX records would look if we hosted our mail with Google: