Results 1 to 6 of 6

Thread: Help Utilizing Hosts File

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Help Utilizing Hosts File

    Over the past few weeks, I've been reading up on some information on using a hosts file in parallel with DNS lookups. However I'm still not able to find out any real pertinent information on the actual file itself.

    One thing I'm not very clear on is the syntax of the file itself. The default hosts file for Windows 7 shows two entries that are commented out.

    127.0.0.1 localhost loopback
    ::1 localhost

    Which I understand that 127.0.0.1 is the local ethernet port (you ping this to test the internal functionality of the port). Now I've also been told, and have seen examples, of rerouting ad-sites to the localhost IP so that the sites' DNS doesn't resolve to it's intended IP address, instead resolving to the localhost IP. So, with that in mind, I'm assuming that the following syntax

    127.0.0.1 www.someadsite.com

    states that when your web browser attempts to resolve the DNS for www.someadsite.com, it looks to the hosts file first and resolves the DNS there (which would mean that www.someadsite.com would resolve to localhost). Am I reading this correctly? That the hosts file is essentially a "key-value" listing?

    If this is the case, then my next question would be how to utilize it in practical scenarios. You can use the hosts file to potentially speed up lookups by explicitly stating that some site is hosted at some IP but whenever I seem to try and implement this, it never works. IE either states that it can't find the web page (I'm told this happens when the site has multiple IP addresses) or it just simply stalls and stays at a blank tab.

    Any information on this topic would be greatly appreciated.
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Help Utilizing Hosts File

    Hosts file is a concept that today causes more trouble than good because it is frequently hijacked by spyware/adware that reroutes traffic from your intended visit to their own. Some years ago I happened to catch one of those that rerouted all my visits to Google to a page that looked exactly like Google Search but gave false results on the first page.

    As for DNS, that info can change a lot and the DNS server is there to resolve hosts IP address. If you're looking to block ads a good browser extension/addin would be a better choice.

  3. #3
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Help Utilizing Hosts File

    Yes, you got the syntax right.

    It'd only speed it up the 'first time', it's then going to be cached in your normal OS DNS cache, and likely your router/modem's DNS cache, and also by your local ISP's DNS cache. DNS has a trickle-down effect. And often these get updated and the upstream DNS servers fail to promptly notify downstream client/servers. Resulting in a DNS conflict where an IP has expired for a domain, but your PC doesn't know it yet. Lots of servers don't necessarily have static IPs, and I'd avoid using the HOSTS file for anything beyond convenience. Great for blocking 'popular' ad servers that are dedicated solely to serving obnoxious bandwidth wasting ADs.

    Baja_yu, as a programmer it should be trivial for you to check each line of the file for either 127.0.0.1 or a comment(#) programmatically.

    I also strongly disagree that browser-level ad-blocking is sufficient, let alone a better choice. At best it's a supplement to HOSTS style and PeerBlock(highly recommended, BTW, as this blocks based on IPs, not DNS resolutions) style blacklists.

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Help Utilizing Hosts File

    I use PeerBlock (and PeerGuardian before that) but I don't think browser ad-blocking is insufficient. Why? I'm not particularly concerned with speed, I have a good Internet connection. The reason I use ad blockers is not speed but simply to remove the clutter from pages.

  5. #5
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    Re: Help Utilizing Hosts File

    Quote Originally Posted by baja_yu View Post
    I use PeerBlock (and PeerGuardian before that) but I don't think browser ad-blocking is insufficient. Why? I'm not particularly concerned with speed, I have a good Internet connection. The reason I use ad blockers is not speed but simply to remove the clutter from pages.
    Or changing specific keywords into annoying 'pop-up links'....

  6. #6
    Hyperactive Member
    Join Date
    May 2006
    Posts
    365

    Re: Help Utilizing Hosts File

    Hello,

    As someone who's host file is over 1MB in size I shall explain how I use it and why I use it the way I do.

    I use the hosts file to explicilty block my computer from attempting to resolve a DNS to an IP address. I know that I do not want access to that web site.
    I mostly download a pre-built Hosts file from mvps.org and then add to it. I mainly use it to block advertising sites, which invariably speeds up the throughput of the data I want access to.

    I do not use it for ip to dns as ip addresses change, leaving the location of the ip to dns location in a text file quite irritating. For the most cases the browser will manage the ip to dns resolving by storing this data in history, only deleting the 'key pairs' if the site is not visited for a long time.


    Kind regards

    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width