Basic DNS

Basic DNS

Introduction

DNS (Domain Name System) is the default name resolution system. It is the service that translates readable and memorable domain names into the IP addresses needed in TCP/IP networks. Whether you're accessing a web site or sending email, your computer uses a DNS server to look up the domain name you're trying to access. The proper term for this process is DNS name resolution.

Small networks

For smaller networks using Linux, hostname resolution can be done using the /etc/hosts file. This file maps hostnames to IP addresses. On Windows systems the hosts file can be located at %SystemRoot%\system32\drivers\etc\

%SystemRoot% = C:\Windows is the standard installation default.

Why do we need DNS?

With larger networks like the internet with billions of IP addresses a scalable, distributed system is required.

DNS is a standard protocol that forms part of the TCP/IP protocol suite.

The DNS server has a database containing mappings between user-friendly domain names representing network resources and their IP address required for communication.

There are various implementations of DNS, one of the most popular for Linux systems is BIND (Berkeley Internet Name Domain).

DNS Hierarchy

At the top of the DNS hierarchy are the DNS root servers beneath the root there are the gTLD (Generic Top Level Domain) servers and the ccTLD (Country Code) servers. Under the TLD servers comes the authoritative DNS server for a particular domain.

For the controlcode.co.uk example these are the 123-reg name servers.

Name resolution example

The DNS resolver starts by reading the URL from right to left, starting with .co.uk

As it happens all .co.uk domains are managed through Nominet so the first DNS resolution request is sent to their servers.

The DNS resolver requests the name servers for controlcode.co.uk. Currently 123-reg is the domain registrar for controlcode.co.uk

The DNS resolver then send a resolution request for developers.controlcode.co.uk to the 123-reg name servers ns.123-reg.co.uk or ns2.123-reg.co.uk

A CNAME record is configured for the subdomain developers so another resolution request will be submitted for the .com TLD.

Finally the IP address for Google Sites will be resolved.

Zone files

A zone file is a text file that describes a DNS zone. A DNS zone is a subset, often a single domain, of the hierarchical domain name structure of the DNS. The zone file contains mappings between domain names and IP addresses and other resources, organized in the form of text representations of resource records.

Entries

Your actual domain name is not used in your DNS settings. Instead, you use the @ symbol to indicate the domain name, in this case controlcode.co.uk

A wildcard DNS record is a record in a DNS zone that will match requests for non-existent domain names. This is generally entries that are not specified in the DNS settings. A wildcard DNS record is specified by using the * symbol. The exact rules for when a wild card will match are specified in RFC 1034. A common mistake is assuming that a wildcard will apply to all hosts in the zone. A wildcard will apply only to names in the zone which aren't listed in the DNS at all.

Types

A records also known as Address records are used to point a domain name at a specific IP address.

CNAME records also known as Canonical name record are an alias to another name.

In the example above for the subdomain name developers, the DNS resolver will check and resolve the ghs.googlehosted.com domain name for the IP address. In this example Google Sites is configured separately to resolve to the /site/controlcodelimited content setup.

TXT records can be used to add arbitrary text into a DNS record. This type of DNS record can be used to verify domain ownership with Google Apps.

MX records also known as Mail Exchange records are used to direct mail at the correct mail server.

Subdomains

These are sub divisions of a domain name. The most commonly used is www however any name can be used, in this example developers is used as a subdomain for software development related content. This example also shows how a subdomain can use a different host by setting up a CNAME record.

Name servers

A name server controls the DNS records for a domain and allows the owner to decide where their website and email are hosted. These are the servers that implement the name service resolution and are setup to perform the DNS resolution for your domain name. This is where the zone file is stored containing your DNS records. Most domain registrars will provide the ability to change name server entries and normally offer at least 2 name servers to point to.

Useful links

Google guide to DNS

Google Public DNS

Google Cloud DNS

RFC1034

dig