Page 1 of 1

Shortening HOSTS dead-endpoints further

Posted: Sun Apr 08, 2012 7:33 am
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.

Re: Shortening HOSTS dead-endpoints further

Posted: Tue Jun 19, 2012 10:57 am
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.

Re: Shortening HOSTS dead-endpoints further

Posted: Sat Jun 23, 2012 10:14 am
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?

Re: Shortening HOSTS dead-endpoints further

Posted: Sat Jul 28, 2012 10:13 pm
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.