Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does my web browser resolve Domain Names?

I'm developing a network application which should be capable of contact DNS servers.

I was wondering what would be the best way to do it. And browsers came to my mind.

For example, how Firefox or Chrome resolve the Domain names i put in the URL bar?

I mean, i type http://www.google.com, how does it know that has to make a TCP request to the IP 209.85.195.104?

Thanks!

like image 526
santiagobasulto Avatar asked Dec 08 '10 20:12

santiagobasulto


People also ask

How does browser know which DNS server?

Host File Check: If the domain name is unable to be resolved, the browser will check your hosts file for a DNS entry. Get the recursive DNS servers:If there's no entry in the hosts file, the browser will check the default DNS server (specified via your computer's network settings).

What resolves domain names to IP addresses?

DNS keeps the record of all domain names and the associated IP addresses. When you type in a URL in your browser, DNS resolves the domain name into an IP address. In other words, DNS is a service that maps domain names to corresponding IP addresses.

How does name resolution work?

The Internet's DNS system works much like a phone book by managing the mapping between names and numbers. DNS servers translate requests for names into IP addresses, controlling which server an end user will reach when they type a domain name into their web browser.


2 Answers

Here is a good comic that describes how your browser resolves host names:

http://www.labnol.org/internet/comic-how-browser-works/18086/

Your environment should be able to handle host name resolution for you. Is there a reason you would need to implement this yourself?

like image 147
jthompson Avatar answered Sep 27 '22 20:09

jthompson


In the simplest scenario, browsers would use a function such as gethostbyname() to resolve names to addresses. However, this function is not always implemented in such a way that's convenient for a browser (it usually blocks until it gets an answer).

Browsers today are starting to use "DNS prefetch", where the browser will send DNS requests directly to a DNS server as the page is loading, to resolve addresses before the user clicks on the next link. That way, the user doesn't have to wait for name resolution when they click, and the browsing experience appears faster.

like image 37
Greg Hewgill Avatar answered Sep 27 '22 20:09

Greg Hewgill