Automate hosts file updates on Linux and MacOS.
angela 161c566ffc deb installer | 5 years ago | |
---|---|---|
autohosts-2.0.0 | 5 years ago | |
img | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
autohosts | 5 years ago | |
autohosts.deb | 5 years ago | |
custom_filters | 5 years ago | |
firefox-includes | 5 years ago | |
prior-v2-uninstall | 5 years ago | |
uninstall-authohosts | 5 years ago |
Automate the hosts file process with cronjobs.
Hosts files will reroute unwanted traffic from ad farms, behavioral tracking firms and malware sites to a blackhole; routing to 0.0.0.0 (localhost; your PC) when a request is made to a URL on the blacklist.
Which means any traffic that would have left your system for that destination, is sent inward, to your localhost and then abandoned.
Despite what some may suggest, hosts files are not "1980s technology" and still very useful today, as an additional layer of security.
Hosts file are a useful redundancy when coupled with ad blockers like uBlock Origin and uMatrix - while debugging or 'Temporarily Allow All on this Site' with Noscript can open you up to underlying attacks or privacy intrusions.
In-browser filters won't protect you if the browser itself is phoning home.
If you have an up-to-date hosts file, the risk is severely lessened.
Auto Hosts will automate the setup process for maintaining an up to date hosts file, by:
For those of us who want our browser to behave like a browser and not a GPS anklet, this list will prove useful by blocking a plethora of tracking URLs. A few of which, some Firefox users have noticed seem to phone home even when the setting is toggled off in about:config.
You can easily append any domain you want to blacklist directly from your home directory. Your custom preferences will be stored with each subsequent update - set it and forget it!
Debian-based Linux distros:
git clone https://github.com/angela-d/autohosts.git && sudo apt install ./autohosts.deb
MacOS or non-Debian-based Linux distros:
git clone https://github.com/angela-d/autohosts.git && cd autohosts && sudo ./autohosts
To see which version you're running on your system: grep "VERSION=" /usr/local/bin/autohosts
Due to structural changes in the codebase, an uninstall and reinstall is necessary. You can do this without losing your custom filters.
git clone https://github.com/angela-d/autohosts.git /tmp &&
cd autohosts &&
cp ~/autohosts/custom_filters /tmp &&
sudo ./prior-v2-uninstall
Run your preferred method of installation to get v2.0.0. Once installation completes, restore your custom filters:
rm ~/autohosts/custom_filters &&
mv /tmp/custom_filters ~/autohosts
Custom filters are loaded to your home directory:
Linux:
~/autohosts/custom_filters
or /home/your_username/autohosts/custom_filters
MacOS
~/autohosts/custom_filters
or /Users/your_username/autohosts/custom_filters
If your computer is not powered on when the cron is scheduled, you'll miss the update. Ensure the cronjob is set for a time when you're most likely to have it on. You can adjust it by running:
crontab -e
and modifying the dates to suit.
Cron legend:
* * * * * = minute, hour, day of month, month, day of week (0 = Sunday, 6 = Saturday)
(*
= every, so 5 straight stars is equal to every minute of every hour of every day and every month.. which you should never run while pulling 3rd party content!)
Uninstalling:
Note: Because this script has to modify /etc/hosts
- it needs elevated privileges (running as root or a sudo user). Scripts that require elevated privileges should be read and analyzed so you know what's being done to your system! Read the source code of this script (and any others requiring such permissions) before you install.
adb push
to /etc/hosts