#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,664
    Rep Power
    171

    About /etc/hosts file


    Hi Devshed.


    According to an article
    A User opens a web browser and tries to connect to www.google.com. The operating system not knowing the IP Address for www.google.com, asks the ISP's DNS Server for this information.


    The ISP's DNS Server does not know this information, so it connects to a Root Server to find out what name server, running somewhere in the world, know the information about google.com.


    The Root Server tells the ISP's DNS Server to contact a particular name server that knows the information about google.com.


    The ISP's DNS Server connects to Google's DNS server and asks for the IP Address for www.google.com.


    Google's DNS Server responds to the ISP's DNS server with the appropriate IP Address.


    The ISP's DNS Server tells the User's operating system the IP Address for google.com.


    The operating system tells the Web Browser the IP Address for www.google.com.


    The web browser connects and starts communication with www.google.com.
    So Domain Name System converst human readable names like google.com to IP addresses. This is called domain resolution. Right?

    Now there is also another way of doing this. There is a file called hosts located in /etc and wecan use that to resolve domains (alternative way to DNS).

    An example:

    I want my computer to go to gmail.com instead mail.yahoo.com. So I chaget the /etc/hosts file to :

    74.125.237.117 mail.yagoo.com

    Correct? If wrong please correct me. I am pretty sure it is correct because it is woking on my Macbook like this.


    Question:

    1 - What is this in hosts file
    ::1 localhost
    fe80::1%lo0 localhost


    2 - Why are these in hosts file, what do these do?
    127.0.0.1 localhost
    255.255.255.255 broadcasthost


    3 - True or False: If a website is listed in etc/hosts file, none of the steps above take place and it directly goes to the ip provided by hosts file.

    Thank you
    Last edited by English Breakfast Tea; October 19th, 2013 at 05:38 PM.
  2. #2
  3. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,947
    Rep Power
    4033
    Originally Posted by English Breakfast Tea
    1 - What is this in hosts file
    ::1 localhost
    fe80::1%lo0 localhost
    They are the IPv6 versions of 127.0.0.1, ie your local loopback address.

    Originally Posted by English Breakfast Tea
    2 - Why are these in hosts file, what do these do?
    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    The first is there to let you type in 'localhost' rather than having to type 127.0.0.1. The second is the same, just with the broadcast address, though I've never actually seen that entry in a hosts file before.

    Originally Posted by English Breakfast Tea
    3 - True or False: If a website is listed in etc/hosts file, none of the steps above take place and it directly goes to the ip provided by hosts file.
    Depends on if the app in question uses the hosts file or not. Some don't and always query a DNS server (eg the dig/host commands in linux).
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,664
    Rep Power
    171
    Originally Posted by kicken
    They are the IPv6 versions of 127.0.0.1, ie your local loopback address.



    The first is there to let you type in 'localhost' rather than having to type 127.0.0.1. The second is the same, just with the broadcast address, though I've never actually seen that entry in a hosts file before.
    Hi;

    Before I reply I mention that 127.0.0.1 simply shows the localhost no problems.

    Now I read about ipv6, I understand the point. I can't access fe80::1%lo0 or ::1 on my browser. 127.0.0.1 takes me to local host but not ipv6 versions.
    This address uses a network port which is normally used for purposes other than Web browsing. Firefox has cancelled the request for your protection.


    255.255.255.255
    Unable to connect

    Firefox can't establish a connection to the server at 255.255.255.255.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer's network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
  6. #4
  7. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,947
    Rep Power
    4033
    Originally Posted by English Breakfast Tea
    Now I read about ipv6, I understand the point. I can't access fe80::1%lo0 or ::1 on my browser. 127.0.0.1 takes me to local host but not ipv6 versions.
    Because of the :'s in IPv6 addresses, the host IP has to be within [] in the URL. Eg: http://[::1]/
    As for the fe80::1, see: http://superuser.com/questions/241642/what-is-the-relevance-of-fe801lo0-localhost-in-etc-hosts



    255.255.255.255
    http://en.wikipedia.org/wiki/Broadcast_address

    You do not connect to a broadcast address. It is a special address that is used to send a packet to all devices on the network.
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo