Craig Francis


DNS

Before we begin, DNS stands for 'Domain Name System'... hopefully that will cure your curiosity, and now you can forget it, as nearly everyone says DNS by spelling out the letters.

This article is aimed at teaching the basics of how DNS works. Although it is a very simple system, it is quite difficult to explain, so if you have any questions or can suggest any improvements, please let me know.

Domain names

Every computer that connects to the internet has an IP address... even your computer has the IP address '44.223.94.103'.

The IP address works a little bit like a postal addresses... perhaps this is over simplifying it, but if you took the IP address 192.168.1.25, the first bit (192) could be seen to specify the country, the town (168), followed by the street (1) and finally the computer (25)... but please be aware that this is not really how computers use the IP address, this is a metaphor, and if you told a geek this is how it works, they would walk away in disgust.

Anyway, its all very well having these IP addresses, but you certainly could not tell someone to visit your website by going to:

http://172.31.2.62

What we really need is something that is easy to remember... how about something like:

https://www.craigfrancis.co.uk

Its the bit after the 'http://' that we call the domain name.

The NS, A and MX records

Every domain name has one or more resource records associated with it... for now, I am only introducing them, so don't expect them to make sense just yet.

Perhaps the most important of these records is the 'NS' record, it provides a list of name servers for a domain.

When a domain name is being resolved, it is the 'A' record which provides the IP address... this is otherwise known as the address record.

And finally there is the 'MX' record, these are used when sending emails. The records themselves contain a list of mail exchange servers which typically the use 'A' record like 'mail.domain.com'.

There are more, but you don't need to worry about them... and keep smiling, this should make sense soon.

Sub domains

The domain names we use on a daily basis are really a collection of domains joined together with dots, for example:

www.google.co.uk

The main domain is uk, and is refereed to as the top-level domain.

The co is a sub-domain of the uk domain, in this case it is also known as a second-level domain.

We can also go though the rest of the chain to say that google is a sub-domain of the co.uk, and that www is a sub-domain of google.co.uk

Resolving a domain name

Or in other words... converts a human readable domain name to an IP address.

Continuing with our example domain name:

www.google.co.uk

We start with the first domain, uk. We need to find out information about it, which we can do by asking one of the 13 well known root name servers.

Part of the information we can get from one of these root name servers is the 'NS' record for the co sub-domain.

With this 'NS' record, we get an IP address for a Nominet name server, this is because they are the domain name registry in the United Kingdom for the uk domains.

By talking to the Nominet name server, we can get another 'NS' record for the google sub-domain. Like before, this is an IP address for a name sever, but in this case its owned by Google.

Talking to the Google name server, we can now find the 'A' record for the www sub-domain.

It is this 'A' record that holds the magic an IP address that we wanted.

Resolving in the real world - websites

Its all very well saying that is how domain names are resolved (converted) to IP addresses... but how does that work in the real world.

How about loading a webpage in your favourite browser (e.g. Firefox)?

When you type 'http://www.google.co.uk/' into your browsers address bar, a number of things happen:

  1. The browser extracts the domain name from the URL, in this example it gets www.google.co.uk.
  2. The browser asks the computer's operating system for the IP address of www.google.co.uk.
  3. The computer's operating system looks at its list of DNS servers, and asks the first one for the IP address of www.google.co.uk. Typically this DNS server is hosted by your ISP.
  4. The DNS server converts the domain name into an IP address, by following the above procedure. It then
  5. The DNS server returns the result to the computer's operating system, and remembers it for later (cache).
  6. The computer's operating system tells your browser this IP address, and remembers it for later (cache).
  7. Your browser then asks this IP address for the web page.

Resolving in the real world - email

The same kind of procedure is used when you send emails... everything before and including the '@' sign is removed, to leave the domain name.

The computer's operating system is then asked for the IP address, which the mail-server uses to send the email.

The only difference from the browser example is that the 'MX' record is used to get a list of mail exchange servers.

The cache

You may have noticed that during the above example, after the IP address was returned, the DNS server and the computer's operating system remembered the result.

The idea of this cache, is so that the next time your browser needs the IP address, it does not need to spend lots of time asking questions over the network, instead the operating system can give a quick response... or, if the operating system does not know, then the DNS server should be pretty quick, without the need to do any real querying for the details.

Moving to a new host

One of the drawbacks to the cache is when the DNS information needs to be changed.

The usual reason for this is when you are moving a website to a new server, which uses a different IP address... as it can take about 3 days for the change to come into effect (due to the cache). This will mean that during this transition time, there will be people loading the website from two different IP addresses.

This is not usually a problem for a flat (non-interactive) website. But if you have something like a members database, you could have all sorts of versioning problems... i.e. old and new data on both websites.

So one way to transfer a website to a new server with different IP address, is to setup the new server so that the website is loaded by default when someone types the IP address into a browser window.

Then, when you are happy everything is ready, close the website, transfer any member database etc, update the configuration on the old server so that it redirects to the new IP address, then update the DNS.

After a few days, if the access log on the old server is not showing any recent activity, then it can be shutdown.

Ownership

First of all, ownership works down from domain to sub-domain... so for example, if you had ownership over 'domain.com', you have the ability to administer sub-domains like 'www.domain.com', but you cannot move up and create sub-domains under 'com'.

For most domain names, they must be registered with a known registrar, who would be able to perform the relevant setup, so that anyone who queries the root name servers will eventually get back to your DNS server.

Although, in most cases, the registrar will provide you with a free DNS server for you to use.

For most domain names, you can find out the current owner by looking at the WHOIS data... dnsstuff.com is a good website to return these details.

When it comes to transferring your domain name to a different registrar, it seems that there this is a different procedure for each domain name type... so you might need to do your homework.

Transferring domains - com

The '.com' top-level domain is currently operated by VeriSign.

You start a transfer by going to your new registrar, and follow their transfer instructions... This sends an email to the current 'administrative contact' of the domain name, with some simple instructions to follow, which includes the use of an authorisation code.

One this has been done, the transfer can take place and the new DNS server will probably be put into use... it is advisable to note down the DNS setup before the transfer, then afterwards setup the new DNS server with the same config - remember those 'MX' records though!

Transferring domains - uk

The '.uk' top-level domain is currently operated by Nominet.

Each of these domain names has an ISP tag which denotes who is the current registrar - so from Nominets perspective, the domain name is owned by the registrar, and it is up to them to assign it to a particular customer.

You start a transfer by asking the current registrar to change the ISP tag to the one used by the new registrar. When they do this, the request is sent to Nominet who updates the ownership.

The final task, in the case of most registrars, is to login to their members area and complete the transfer by assigning it to your account - it is technically possible for someone else to steal the domain, however it is very unlikely that anyone will either know, or be able to guess that the transfer is taking place.

Like with the '.com' transfer process, you will most likely be using the DNS server provided by the new registrar, so make sure you get a copy of the setup before the transfer from the old DNS server - including those 'MX' records!

Any feedback would be greatly appreciated, I don't include comments due to the admin time required, but if you email me, I will reply and make appropriate updates. Also, if you would like to take a copy of this article, please read the terms this article is released under. This article was originally written Tuesday 6th March 2007 and was updated on Wednesday 7th March 2007.