2ndalpha / gasmask

Hosts file manager for OS X
3.73k stars 252 forks source link

Accelerate and Reduce Host File Sizes #37

Open TraderStf opened 9 years ago

TraderStf commented 9 years ago

I have read several articles about reducing the host file, here is a summary.

Using 0 is

An additional way to reduce the host file size is by grouping several hostnames on one single line.

Obviously, removing duplicate hostnames, empty lines, useless spaces or tabs, and comments will also help.

An example:

127.0.0.1         localhost
255.255.255.255   broadcasthost
::1               localhost
fe80::1%lo0       localhost

# Comment here
127.0.0.1      host1
127.0.0.1      host2
127.0.0.1 host3
127.0.0.1 host4
192.168.2.7    testa#test for john
192.168.2.7  testserverb
0 adstat.com # naughty tracker
0 mk1.adstat.com
0 mk2.adstat.com
0 mk3.adstat.com
0 mk4.adstat.com
0 mk5.adstat.com
0 mk6.adstat.com
127.0.0.1      host2 #look a duplicate

This host file becomes, by using all these technics including the 9 limit:

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
0 host1 host2 host3 host4 adstat.com mk1.adstat.com mk2.adstat.com mk3.adstat.com mk4.adstat.com
0 mk5.adstat.com mk6.adstat.com
192.168.2.7 testa testserverb

The first file is reduced by almost 55 %.

When you have a host file of 2617 KB, that makes a huge difference, it is reduced by ~44 %. For a huge host file, take a look at http://sourceforge.net/projects/adzhosts/

WARNING

Have a nice day.

TraderStf commented 9 years ago

UP :+1: , for using "0" instead of "127.0.0.1"

mrchief commented 5 years ago

You can use the list from something like https://github.com/StevenBlack/hosts which uses 0 instead of 127.