A tip to cut down the Hosts file

Discussion in 'other software & services' started by Hungry Man, Apr 8, 2012.

Thread Status:
Not open for further replies.
  1. Hungry Man

    Hungry Man Registered Member

    Joined:
    May 11, 2011
    Posts:
    9,146
    If any of you are on older systems with a large hosts file this can reduce RAM size a lot for you (same size for everyone, but modern machines won't see a difference.) The hosts file is loaded into RAM and read so this could potentially effect DNS loads and there should be no downsides (though you do have to do this manually - it takes a second. There could be issues with things like SpyBot S&D etc.) If you're using Windows 2000 you may not be able to use 0 and instead will need to use 0.0.0.0.

    MVPS Original Size: 601.7kB

    Replacing 127.0.0.1 with 0.0.0.0 reduces the size of the MVPS Hosts file to 572.9kB
    Replacing 127.0.0.1 with 0 reduces the size of the MVPS Hosts file to 486kB (~120kB less)

    You can also remove things like #[Tracking Cookie] and other #'d areas to save ~10kB.

    You can also attach multiple hosts to an IP
    Code:
    0  admigo.ru data.admigo.ru apps.admission.net appcache.admission.net
    You can eliminate ~2/3rds of the 0s by stacking them on each line. Without a script to automate this it'll take ages though.

    Just thought it was interesting that you can cut it down to nearly 1/2 its size. I don't know what the maximum number of hosts to an IP you can do, but there's probably a fair amount of memory to be saved. I've fit as many as 8 hosts to one IP.
     
    Last edited: Apr 8, 2012
  2. kupo

    kupo Registered Member

    Joined:
    Jan 25, 2011
    Posts:
    1,121
    HostsMan can do that, afaik the maximum is 9 hosts in one IP.
    from here -http://forum.abelhadigital.com/viewtopic.php?f=8&t=4&sid=1505a71024bfb07d91b9ac2467660cb0
     
  3. Hungry Man

    Hungry Man Registered Member

    Joined:
    May 11, 2011
    Posts:
    9,146
    Cool, thanks.

    It uses 127.0.0.1 though. Switching to 0 will save 1/6th of the size.
     
  4. kupo

    kupo Registered Member

    Joined:
    Jan 25, 2011
    Posts:
    1,121
    Does 0 works with Windows 7?
     
  5. Hungry Man

    Hungry Man Registered Member

    Joined:
    May 11, 2011
    Posts:
    9,146
    Not sure. I've only tested on Linux. 0.0.0.0 is still smaller than 127.0.0.1.
     
  6. JimboW

    JimboW Registered Member

    Joined:
    Oct 22, 2010
    Posts:
    280
    Nope. 0 doesn't work on Win7.

    Another reason to use 0.0.0.0 on top of size reduction is that it can actually speed things up. 0.0.0.0 blocks the connection straight away where as 127.0.0.1 trys to make a connection having to go through the loopback interface.

    Optimization with HostsMan and using 0.0.0.0 results in a Hosts file size of just 305kb.
     
  7. elapsed

    elapsed Registered Member

    Joined:
    Apr 5, 2004
    Posts:
    7,076
    Yeah HostsMan is definitely the best way to automatically optimize it. But a HOSTS file for ad/tracking blocking in general is sub-par. No ability for special allow rules to prevent site breakage and no ability to prevent 1st party ads/tracking.
     
  8. m00nbl00d

    m00nbl00d Registered Member

    Joined:
    Jan 4, 2009
    Posts:
    6,623
    You're late to the party. :D And, it's also possible to have Spybot S&D populate hosts file entries with 0.0.0.0 as well. You need to create a registry key.

    HKEY_LOCAL_MACHINE\SOFTWARE\Safer Networking Limited\Tweaks

    Then, create a REG_SZ entry, and name it HostsBlockIP. Then give it a value of 0.0.0.0.

    Note: I got this info from Spybot's Wiki website. So, I don't know whether or not it works as it claims. :)
     
    Last edited: Apr 8, 2012
  9. JimboW

    JimboW Registered Member

    Joined:
    Oct 22, 2010
    Posts:
    280
    Or add takeownership to the right click context menu (comes in handy) Make .reg file

    [HKEY_CLASSES_ROOT\*\shell\runas]
    @="Take Ownership"
    "NoWorkingDirectory"=""

    [HKEY_CLASSES_ROOT\*\shell\runas\command]
    @="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
    "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

    [HKEY_CLASSES_ROOT\Directory\shell\runas]
    @="Take Ownership"
    "NoWorkingDirectory"=""

    [HKEY_CLASSES_ROOT\Directory\shell\runas\command]
    @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
    "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

    Take ownership of Hosts so you can save and use the built in Notepad feature, Edit->Replace->127.0.0.1->0.0.0.0->Replace all

    Spybot, Hosts, it's like going back in time lol :D :p
     
    Last edited: Apr 8, 2012
  10. vasa1

    vasa1 Registered Member

    Joined:
    May 1, 2010
    Posts:
    4,417
    Never took a liking to the hosts file business. It's too all or none for my liking.
     
  11. xxJackxx

    xxJackxx Registered Member

    Joined:
    Oct 23, 2008
    Posts:
    9,012
    Location:
    USA
    Same here. Too much hassle for too little return. As stated though 0.0.0.0 beats 127.0.0.1 EXCEPT for localhost. Make sure to never change that from 127.0.0.1 or programs that use the local loopback will fail.
     
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.