As a web developer and designer I often get asked the same question over and over again, how does a website actually work? I mean when you type the domain name in how does it find the right website? Well I thought that this blog would be a good place to try explain it in simple terms how it works.
Firstly for all you true techies out there there will be in accuracies in my description here, but what I am trying to do is to simplify the process and enable people to understand how it works and not necessarily all the little ins and outs.
Lets start at the end where the website is stored. Web sites are stored on something called a server. This is essentially just a computer that is connected to the Internet. This server has an address, just like your house has an address so that you can find it. In fact every device that is connected to the internet has an address called an IP (Internet Protocol) address. At a very basic level if you type that address of the server which holds a website into your browser you will be able to access the website. An example is the IP address 18.104.22.168 which will take you to the Google homepage.
The trouble is, that we are not very good at remembering numbers. Think about our mobile phones. If your anything like me I can’t even remember my wife’s phone number never mind every web sites IP address that I want to visit. Therefore to get around this we use servers called Domain Name Systems in order to convert these numbers into what we call domain names. Examples of popular domain names are google.com, yahoo.com and bbc.co.uk. Each country in the world is assigned what is known as a top level domain (basically the bit after the last dot) to use to giving out domains for website in their country. You can find a list of all the world’s top level domains (TLDs) in this Wikipedia Article.
So what happens when we launch our internet browser (Internet Explorer, Firefox or perhaps Safari on the Mac) and then type in the domain name that we want? How do we end up in the correct location? How is that the domain name resolved to the correct IP address in order to take us to the correct server that holds the website for that domain name?
Every website will have a server that control the domain name entires for that website address. What this essentially means is there is one location that tells others which domain name equates to which IP address. This server is called a ‘Nameserver’ and this can be set from the control panel of the domains registrar, which is the company you bought your domain name from. So lets take a look at what happens when we type in a domain name into our browser.
We are going to assume that the website you are requesting is a brand new, never been seen before site and it lives at thisdomain.com. Your browser will send a request to whoever is your Internet Service Provider (ISP) to see if its Domain Name System (DNS) server knows which IP address to find thisdomain.com on. As the site is brand new it won’t know and therefore it will then go to another DNS server and ask it. It will keep doing this until one of these DNS servers (the Nameserver for thisdomain.com) will respond with the correct answer. This is then relayed back to your ISP DNS server which notes down or remembers the location. This means that the next time you visit the site it will happen straight away as the first server you visit in the chain knows the correct IP the resolve. The website is then display to you in your browser.
Of course sometimes website changes their servers for which they are hosted on. A common example of this is if you change your hosting provider. Therefore there is always a period of anything up to 48 hours for the new DNS records (to tell the DNS server of your ISP the new IP address of thisdomain.com) to propagate around the world to all the DNS servers that are in use.
The good news is, is that all of this fancy DNS resolving is done without the user having to know anything except the domain name that you are looking for. Everything else is done by the servers that are part of the chain of getting you to the correct server (IP address) which contains the website you have requested.