Shortening HOSTS dead-endpoints further

General discussion about web technology.
Post Reply
Tom T.
Field Marshal
Posts: 3620
Joined: Fri Mar 20, 2009 6:58 am

Shortening HOSTS dead-endpoints further

Post by Tom T. »

For those who choose to use a HOSTS file service as a blocker of annoying and/or reported malicious sites, I saw an interesting tip recently that shrinks the file even further, while still giving immediate parsing as "invalid" without attempting further resolution.

The tip was to set the blocked-sites destination to "0". Just plain zero, nothing else. No decimals.

If you have 15,000 entries, that knocks about 120 Kb off of 0.0.0.0, and another 30k off of 127.0.0.1.
Compared to 255.255.255.0, that's 180Kb of file less to parse.

NOTE: Tip said it was only for Windows, only up through XP and Server 2003, and would not work on Vista+. IDK. Works fine on XP:

Code: Select all

C:\WINDOWS\system32>ping 0

Pinging 0.0.0.0 with 32 bytes of data:

Destination specified is invalid.
Destination specified is invalid.
Destination specified is invalid.
Destination specified is invalid.

Ping statistics for 0.0.0.0:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\WINDOWS\system32>ping www.doubleclick.net

Pinging www.doubleclick.net [0.0.0.0] with 32 bytes of data

Destination specified is invalid.
Destination specified is invalid.
Destination specified is invalid.
Destination specified is invalid.

Ping statistics for 0.0.0.0:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Since doubleclick is one of those that is mapped to 0, apparently 0 alone gets parsed as 0.0.0.0 -- with the same immediate, internal "invalid'" message.

Guess: Without the decimals, possibly assumes that 0 is a binary (not decimal octet) address, being 000....000 (32 zeros)?

WFM so far. No guarantees. Undocumented. Use at your own risk, or not at all.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: Shortening HOSTS dead-endpoints further

Post by Thrawn »

On my (Ubuntu Linux) workstation, I get the following results:
  • 0.0.0.0 - pings 127.0.0.1 (and succeeds, because I have local services)
  • 0 - pings the real site
  • 1.1.1.0 - tries to ping, but times out waiting for a reply.
Can't seem to see any option that will abort immediately.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: Shortening HOSTS dead-endpoints further

Post by Thrawn »

What might work even better is to put multiple hostnames on one line?

Code: Select all

0.0.0.0 doubleclick.net google-analytics.com tribalfusion.com invitemedia.com ...
Maximum line length is 255 characters, though, IIUC. Still, that could probably fit a dozen hosts per line. Anyone want to write a batch/shell script to automate this?
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0
User avatar
GµårÐïåñ
Lieutenant Colonel
Posts: 3369
Joined: Fri Mar 20, 2009 5:19 am
Location: PST - USA
Contact:

Re: Shortening HOSTS dead-endpoints further

Post by GµårÐïåñ »

I've said this before and I say again, be careful using 0.0.0.0 as on some router/LAN configurations, that will be a default escape route and will have full internet access. I have been argued with on this subject but if anyone knows network or does some reading on the subject knows what I mean. Its often considered a default route.
~.:[ Lï£ê ï§ å Lêmðñ åñÐ Ì Wåñ† M¥ Mðñê¥ ßå¢k ]:.~
________________ .: [ Major Mike's ] :. ________________
Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
Post Reply