They said it couldn't be done. They said you couldn't install a large HOSTS file on a machine which has the DNS Client service running because it tends to slow down the machine.
They were wrong!
I have a HOSTS file with nearly 170,000 blocked sites on a Celeron XP Home machine with no slowdown except at bootup. There is a 4 or 5 second delay when the HOSTS file is read and cached. After that, everything is faster because DNS lookups are cached and the HOSTS file does not have to be accessed constantly.
How, you say? By putting multiple HostNames on the same line! So far, I have been able to put a maximum of nine HostNames on one line. This page describes the format of the HOSTS file in detail:
http://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.files/doc/aixfiles/hosts.htmA sample line from my HOSTS file looks like this:
Code:
127.0.0.1 antispyware2008.name antispyware2008.org antispyware2008a.com antispyware2008buy.com antispyware2008c.com antispyware2008purchase.com antispyware2008soft.com antispyware2008y.com antispywareadaware.com
It sure took a long time to edit the file and put nine HostNames on each line, though. Just kidding! I have custom awk scripts to manage my HOSTS file and the part that does the work looks like this:
Code:
BEGIN{
printf "127.0.0.1 localhost localhost.localdomain\n"
# add your favorite sites here:
printf "212.56.95.253 hosts-file.net www.hosts-file.net forum.hosts-file.net\n"
}
/^127/||/^0/{
lcase=tolower($2)
if (lcase=="localhost"||lcase=="localhost.localdomain") {next}
if (lcase in j) {next}
j[lcase]
a[++i]=lcase
if (i==9){
printf "127.0.0.1 %s %s %s %s %s %s %s %s %s\n",a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]
i=0
}
}END{
if (i>0){
printf "127.0.0.1"
for (k=1;k<=i;k++) {printf " %s",a[k]}
printf "\n"
}
}
Now, what do I win for this amazing discovery??

Edit: fix coding error
Edit: remove unnecessary line of code