Question:

Briefly explain how HOSTS files and DNS servers work, including examples?

by  |  earlier

0 LIKES UnLike

Briefly explain how HOSTS files and DNS servers work, including examples?

 Tags:

   Report

4 ANSWERS


  1. Every computer in an ethernet network has an IP address. As humans we aren't very good at remembering numbers like 10.3.27.34. We find it much easier to remember that the printer at 10.3.27.34 is called Gutenberg or HP6840 or Arthur. So we need a way to gave 10.3.27.34 a nice name.

    In early system that was done by adding a line to the /etc/hosts file with

    10.3.27.34 Gutenberg

    The problem with that is that it works well when you have 15 machines connected. But as soon as you start to get more that 200 machines it becomes a monster PITA. If you replace your HP6840 with a new Epson printer called Caxton at 10.3.23.35 then all users have to update their hosts file. Two hundred updates later you have two hundred happy users who can print on the new Epson printer called Caxton.

    Now expand the network to 2000 machines and the problem grows exponentially. It also gets worse because more things change more frequently as the network gets larger. At 20,000 machines using a hosts file (with 20,000 records on each machine) becomes so error prone as to be unworkable.

    That's where DNS comes in. It's a distributed system where everyone can find everyone else (how many machine are on the big wild Internet?) but without the misery of constant and frequent updates to a large file. And without the performance penalty of reading 20,000 records to find the one you're looking for.

    So what we do is break the network into subnets and give the subnet a DOMAIN NAME SERVER. So, as an example, I'll have is so 10.1.1.0 to 10.1.1.255 becomes room101.mydomain.co.uk and 10.1.2.0 to 10.1.2.255 becomes room102.mydomain.co.uk. (That could be london.mydomain.co.uk and manchester.mydomain.co.uk or anything else that makes sense to my organisation.)

    The DNS for each example subnet only has to look after the local 253 machines. And the names for those are defined in one place. The DNS for mydomain.co.uk only needs to know that the DNS for room101.mydomain.co.uk runs on the server at 10.1.1.27 and the DNS for room102.mydomain.co.uk runs on the server at 10.1.2.57.

    When a user at fred.room101.mydomain.co.uk wants to connect to a printer at caxton.room102.mydomain.co.uk they ask the DNS at 10.1.1.27. "Hello, can you find caxton.room102.mydomain.co.uk". That DNS goes to the DNS at 10.x.y.z that runs mydomain.co.uk and asks "Hello where is room102.mydomain.co.uk", it gets the answer "It's at 10.1.2.57". It then goes to 10.1.2.57 and asks "Hello, where is caxton.room102.mydomain.co.uk" and gets the answer "It's at 10.1.2.65".

    (I've ignored co.uk and uk and the internet root servers in that example.)

    When a machine gets replaced or moved or a new one is installed you simply update the local DNS and reload the zone file.

    There is a little more complexity when you move outside your local domain.

    When you want to find http://answers.yahoo.com your machine asks your local DNS "Hello where is answers.yahoo.com". It replies "I'll ask yahoo.com". But it has to ask "com" "Where is yahoo.com?" first and before that has to ask the root server "Where is com?". With caching it can reply "it was z.y.x.w" last time I asked.

    There's some interesting tools like DIG that will show this stuff happening.

    If you really want to understand it get a copy of "DNS and Bind" published by O'Reilly. It's an excellent book and required reading if you want to configure this stuff.


  2. They make it so you can type things other that IP (Internet Protocol) addresses into the address bar of your web browser by looking up the IP address for the site you typed in.

    For example, you type in: www.google.com

    A DNS (Domain Name System) server looks in its stash of corresponding host names/IP addresses and sees that www.google.com is the domain name for the IP address 72.14.207.99

    The hosts file is located at "%SystemRoot%\system32\drivers\etc\hosts... by default in most versions of Windows, and at /etc/hosts by default in Linux.

    The hosts file is looked at first, if the site you typed into the address bar is in the hosts file, the computer uses that entry. If not, it sends the request to a DNS server.

    Entries in the hosts file have the format of the IP address, one or more whitespace characters (and maybe tab characters), and then the host that the IP address refers to.

    Example:

    127.0.0.1     localhost

    The hosts file is not (necessarily) always looked at when you type a site into the address bar. For example, a Windows (I am not sure about Linux) system affiliated with a domain/proxy **(not sure, could be one, the other, or both) will bypass the hosts file, even if it includes an entry for a given site.

    In theory, you can speed up your internet connection by typing the information into the hosts file for sites you visit.

    Also, it can be used for pranks. Type the following into the hosts file of an unsuspecting friend:

    64.233.167.147    yahoo.com

    209.191.93.52    msn.com

    207.68.172.246    google.com

    Then, have them try to go to yahoo.com, msn.com, and google.com!

    (To undo the prank, remove the three lines of text you added.)

    I hope this helps/helped!

    (Sorry it was so long...)

  3. do your own homework

  4. DNS servers translate domain names (e.g. example.com) into IP addresses (e.g. 10.1.2.3). TCP/IP (the Internet's technology, sorta) uses IP addresses, but you wouldn't want to memorize IP addresses, now would you?

    When you try to access a domain name (say, visit a website), your computer runs an nslookup - it asks the DNS server what its IP is. Then it knows where to get the data from.

    The hosts file (/etc/hosts on linux-based machines, c:\winnt\win32\drivers\etc\hosts) are domain name / IP address dictionaries just like DNS servers, only they sit on your computer.

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions