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!
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).
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.
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.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With