How Websites WorkHow Websites Work - HomeWeb Page Content Web Protocols Web Addresses How DNS Works RelatedCreate a Website2 Ways to Create Websites Make Your Own Website Web Building Skills HTML Tutorial HTML Codes & Generators Web Hosting Tutorial FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
How DNS WorksWhat is DNS?DNS stands for Domain Name System. A domain name is the unique name that is assigned to a website. DNS is the system that enables this to work. When you build a website, you also register a domain name. Then, you point the domain name to your website. In most cases this is done via the control panel of your web host or domain name registrar and you don't need to know what happens "behind the scenes". Having said this, once you've configured your domain name, there are some DNS tricks you can use when developing your website. This article explains how DNS works and how you can use it to assist in your web development. What is a DNS Server?For a domain name to be assigned to a website, it first needs to be added to a DNS server. A DNS (Domain Name System) server is a large database containing each domain name and its corresponding IP address. For example, if the domain name "google.com" resolves to the website at 64.233.167.99 the DNS server holds this information. Furthermore, there are many thousands of DNS servers worldwide. These are located with hosting companies and other organizations. These DNS servers actually keep in synch with each other. This way, your hosting company only needs to add your domain name to it's own DNS server. Then gradually, (usually within 48 hours), the DNS entry is "propogated" to the other DNS servers around the world. In most cases, you can add/update a DNS entry using the control panel of your domain name registrar/web host. How does my Browser find the right Website?When you type a URL/web address into your browser, several things occur behind the scenes to bring you the correct web page. The first thing your web browser needs to do is translate the domain name into the IP address of a website. Doing this enables it to locate the correct website. Once it's found the correct website, it can then download the web page, along with it's associated files (images, CSS files, etc). When you type a URL into your browser, it uses the following steps to locate the correct website:
Overriding DNS Entries with your Hosts FileOccasionally, you might want your own browser to resolve a domain name to a different webiste to the real one. You might ask "Why on earth would I want to do that?" Well, this can sometimes be useful when redeveloping your website. You could upload your changes to a "staging" server so that you can test the new version before it goes live. This way, you could browse the new version using the real URL, while the rest of the world continues to see the old version. The easiest way to this is to modify your hosts file. Your hosts file is a file that probably already exists on your computer. It acts as a mini-DNS server. Any changes to it only affect your computer. Here's an example of the hosts file that comes with Microsoft Windows:
In the above example, only one line actually does anything - the last line. The other lines are just comments. The last line in this example maps the ip address 127.0.0.1 to localhost (the local computer). Therefore, whenever you type localhost into your browser, it will display the default local website on your computer (if any). For a local website to display, it would have previously been configured via your local web server. To learn more about web servers, check out the web server tutorial.
Here's an example of a modified hosts file:
Notice how I've added one line. This adds a (fictitious) domain name to an IP address. The bit after the The new line tells the browser to resolve "my-test-site.com" to "64.233.167.99". So even if that domain name really exists (and points to another IP address somewhere in the world), your browser will use 64.233.167.99 instead. This is because (as mentioned previously), your browser checks your hosts file first (before any DNS servers). If it finds an entry in your hosts file, it will use that and won't look any further. Overriding DNS Entries with a Local DNSAnother way of overriding a DNS entry is to use a local DNS server (for example, your company's DNS server). Doing this allows you (or your organization's Network Administrator) to override DNS settings for the whole company or selected employees. Because employees' browsers check the local DNS server before any others, employees will see the website as specified in the local DNS server. If required, employees can override the local DNS setting by modifying their hosts files. Alternatively, the Network Administrator could control this at the network level. Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|