I came across this article by Erik Kangas, President, Lux Scientiae and thought it worthy of a post because it explains how Domain Name sand DNS works in pretty friendly way – all credit to Erik Kangas.
To understand what Domain Name Service (DNS) is and how it is used, it is best to start with an example: John Sample wishes to register and setup his web site and email. Here are the steps involved:
A DNS Example
1. Registration of the Domain: John goes to some company, such as LuxSci, and finds a domain name that he likes and which isn’t taken by someone else. He then registers it, paying a fee for one or more years. What does this registration actually buy him? It depends on the company he registered at and for what exactly he signed up; however, it usually only means that John has now leased the domain name for some period of time. He doesn’t actually “own” it, he just has the sole right to use it for some period of time, after which he has the right to renew his lease.
Note that when you register a new domain name [say at Lux Scientiae], it will take 0-24 hours for that domain to become live and functional on the Internet. If you register it elsewhere, it may take longer.
2. Sign up for web and/or email hosting: John then contacts some company, such as LuxSci, to order hosting. A hosting company provides the computers on which John’s web site files will reside and/or which will accept email for John at his new domain name.
What is missing? DNS. Registration of the domain gave John a “name” on the Internet; obtaining web or email hosting services gives him an “address” — the Internet addresses of the computers owned by LuxSci that will be handling John’s web and email needs. What is missing is a connection between the name and the addresses.
I like to make the analogy that DNS is like a “phone book” for domain names. It contains entries that indicate which computer address corresponds to which domain name (and vice versa). You probably use DNS all the time and don’t even know it! Whenever you type an address such as “http://google.com” into your web browser, the web browser uses DNS to find out the numerical address(es) of the computers that handle Google’s web site; it then uses these addresses to connect to those computers to get the web site files.
Thus, anyone who has a domain name needs DNS services. These services are usually provided by your web or email hosting company because they know their computer addresses, and should be in a position to update your DNS settings for you if any of their computer’s addresses needs to be changed I.e. LuxSci will manage your DNS settings for any or all of your domains for you.
You may be able to manage your DNS settings yourself if, for example, your domain registration company provides this service to you, or if you use a company like EasyDNS (of which LuxSci is a partner and whose services LuxSci offers at a discount to its members).
3. Transfer your domain. If your web hosting company is going to take care of your DNS settings for you, you need to give them control over these settings. This means telling your domain registrar (Register.com in this example) what servers your web hosting company is using for your DNS…. your web hosting company will tell you what to say.
DNS Summary
Now you should have a rough picture of the complexity involved in managing a domain name — there are at least 3 sets of computers involved!
One set belongs to your domain name registrar. They keep track of what domains are registered, who owns them, and what computers manage the DNS settings for each of these domains. (This information is stored in a big database called the “whois” database).
One set belongs to the company that manages the DNS settings for your domain. These computers understand what computer addresses correspond to what domain names. Other computers, like your web browser, can ask them to look up the name for an address, or vice versa.
The third set belongs to your web and email hosting company. On these computers, your web site files are stored and your email is delivered. There are almost always different computers than the ones that handle the DNS lookups.
Mail Exchange (MX) Records
An “MX Record” is a DNS entry that indicates what server(s) handle the email messages for your domain. These can be, and usually are, different servers than those than handle your web site. “MX” stands for “Mail Exchange”. Typically, you will have 2 or more MX records for your domain. One is primary; the others are secondary and will queue your email temporarily if your primary email server is down, forwarding it to your primary server when it comes back up. We strongly recommend using 2 or more different MX records.
Subdomains
If John Sample registered “sample.com”, then he really can have any number of domain names, as long as they each end in “sample.com”. I.e. “john.sample.com”, “x1234.sample.com”, and “www.xqy.apple.sample.com” are all domains that John has a right to setup and use because he has registered “sample.com”. These are all called “subdomains” because you cannot register them individually, but get them if you register the normal domain “sample.com”. Subdomains are created when entries for them are made in the DNS settings for your domain.
You can configure your DNS settings to use any addresses you wish for web and email for any of your subdomains. Your DNS provider should allow you to do this as a matter of course. However, your web or email hosting provider will probably charge you extra for the use of additional web sites (for each subdomain) or additional email domains.
If your subdomain is configured to point to another domain name or subdomain name, rather than to a computer’s address, it is known as an “alias” or a “CNAME”.
DNS Propagation: Time-To-Live (TTL)
The “Time-To-Live” or TTL is an important DNS setting that you should be aware of when you want to change your DNS name to address settings or to change the company that manages your DNS. A TTL is roughly the time, measured in minutes, hours, or days, that it can take for any change in your DNS settings to take effect all throughout the Internet. A small setting such as 20 minutes will cause all your settings to propagate across the Internet in about 20 minutes or so, a large setting can result in the changes taking days to be noticed. A typical default setting can be 6 to 24 hours! Clients for whom LuxSci manages their DNS generally have their TTLs set to 3 hours, unless they request otherwise. Note that the TTL is also the time it will take for changes in the TTL to take place…!
Why are your changes not instantly available? The answer reflects the clever way in which DNS works. Your changes ARE available instantly on the actual computers that manage your DNS. However, they aren’t the only computers that give out DNS information to the world — there are hundreds of thousands or even millions of these DNS servers around the world. How would an end user know to ask your particular DNS server for your particular address? That would require another type of “phone book”! No. Instead, an end user just asks their nearest DNS server for your address. This DNS server is probably owned by their Internet Service Provider. If this DNS server knows your DNS information, it tells the end user. If it doesn’t know, it effectively asks your server, tells the end user and stores a copy of the information in case someone asks again.
This distributed method of looking up DNS information is good because it is fast and minimizes the work your DNS servers have to do. It has the drawback that the other DNS severs have stale information whenever you change the data on your servers. To compensate, you can set the TTL on your DNS settings. Effectively, if a DNS server has information that is older than its TTL, the DNS server doesn’t trust that the data is accurate and goes to get a fresh copy. This is why the time it can take your DNS changes to propagate across the Internet is approximately the TTL settings you have made for your domain.