Help me understand how name servers

Status
Not open for further replies.

watdahel

Golden Member
Jun 22, 2001
1,661
12
81
www.youtube.com
I registered my domain with Namecheap and currently using their DNS servers. I have a free web hosting account with company ABC. My confusion is how does typing the address on the web browser send me or anyone to my website at ABC? How does it all work? From my understanding, my ISP's DNS servers first checks their list and if it fails will then randomly check other DNS servers in the internet until it finds a server where the URL typed in the browser is listed? That DNS will then send the website to the browser?
 

dinkumthinkum

Senior member
Jul 3, 2008
203
0
0
The DNS is a massively distributed, hierarchical mapping of names to IP addresses (which can be directly used to route packets).

There are root nameservers which have known, fixed IP addresses. These are consulted to find the nameservers for the top level domain (.com, .net, ...). The TLD nameservers know about the nameservers of the next level of domain names (e.g. the nameservers of YourDomain.com). So when you set up your domain name you told them to use the nameservers of Namecheap. You informed the nameservers of Namecheap of your IP address. By following the hierarchy other nameservers can eventually come to Namecheap's servers, which provide the answer.

Of course, much of this work is cached, so to avoid a lot of unnecessary network traffic. Typically a name mapping is cached for about a day. That is why it can take a day before web-surfers can find your website, when it is moved to a new IP address.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
The DNS is a massively distributed, hierarchical mapping of names to IP addresses (which can be directly used to route packets).

There are root nameservers which have known, fixed IP addresses. These are consulted to find the nameservers for the top level domain (.com, .net, ...). The TLD nameservers know about the nameservers of the next level of domain names (e.g. the nameservers of YourDomain.com). So when you set up your domain name you told them to use the nameservers of Namecheap. You informed the nameservers of Namecheap of your IP address. By following the hierarchy other nameservers can eventually come to Namecheap's servers, which provide the answer.

Of course, much of this work is cached, so to avoid a lot of unnecessary network traffic. Typically a name mapping is cached for about a day. That is why it can take a day before web-surfers can find your website, when it is moved to a new IP address.

Then once your web browser has the correct IP address of the server hosting the website it creates an HTTP request which contains a piece of header information that tells the server what hostname you are looking for, in other words the url you typed in up to the first /. It sends the request to the web server and then the server uses that information to know which website to send back to the web browser.
 

watdahel

Golden Member
Jun 22, 2001
1,661
12
81
www.youtube.com
All name servers eventually will have the same records right? For example, initially only Namecheap DNS servers know about my website. Eventually, DNS servers all over the world will mirror the contents of the Namecheap server and vice versa?
 

slashbinslashbash

Golden Member
Feb 29, 2004
1,945
8
81
All name servers eventually will have the same records right? For example, initially only Namecheap DNS servers know about my website. Eventually, DNS servers all over the world will mirror the contents of the Namecheap server and vice versa?

I think walking you through the steps will help you understand a bit better.

1. I type the name of your website - example.com - into my browser. My browser initiates a lookup with my Operating System, which contacts my preferred DNS server. I can either program the IP address of this DNS server into my OS, or program it into my router, or let my router pick it up automatically from my ISP when the router/gateway gets its IP address from the ISP upon connecting. Usually there will be a caching DNS server maintained by my ISP not too far away, in terms of network jumps, from my connection. Let's assume this is the caching server used in this case.

2. If the caching server has recently looked up the DNS entry for example.com, it already has it cached. It sends it back down the line to your browser. Done.

3. If the caching server does not have this DNS entry in its cache, it will look to the TLD server for the TLD in question. TLD = Top Level Domain. .com is a TLD, .net is a TLD, .us is a TLD, etc. These TLD servers keep track of EVERY domain under the TLD, but they don't keep track of the actual IP address for example.com; they only know which nameservers are considered authoritative for example.com. In this case, you are using Namecheap's DNS servers as your authoritative DNS servers for example.com. The TLD servers send the IP addresses for Namecheap's DNS servers back to your ISP's caching server, which then sends a request to those Namecheap DNS servers for the location of example.com, which should be answered promptly and forwarded back to your PC (and cached by your ISP's caching server for 24 hours, 48 hours or whatever time limit is specified by the Namecheap servers).

4. Finally, having obtained the IP address for example.com, your browser initiates the HTTP request for the website at example.com.

So... no, all the nameservers in the world will not ever have a copy of your info (unless your website is extremely successful like google, yahoo, etc.). Whenever a user visits your website, their local caching DNS server (and any intermediate caching servers up through the ISP's hierarchy) will cache the results for the specified time to live (TTL). Once the TTL is up, the result is deleted and will have to be queried again from the TLD server, which points to your nameserver and not the site itself.

Of course, that is just the "official" version of how DNS works. I would bet that most big ISP's basically try to keep a live cache of pretty much all the big TLD servers, at least the ones relevant to their country of origin. I also think it's likely that most big ISP's have several layers of DNS cache hierarchy (lots of servers close to end-users, which deal directly with fewer servers higher up that maintain bigger caches), so no one server gets hit too hard at one time.
 
Status
Not open for further replies.