{"id":13587616,"url":"https://github.com/angela-d/autohosts","last_synced_at":"2025-10-13T06:11:47.151Z","repository":{"id":45106937,"uuid":"147154675","full_name":"angela-d/autohosts","owner":"angela-d","description":"Automate hosts file updates on Linux and MacOS.  Block Firefox telemetry, Google snooping and web trackers at the root.","archived":false,"fork":false,"pushed_at":"2023-02-25T17:39:13.000Z","size":627,"stargazers_count":86,"open_issues_count":3,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-31T05:43:15.990Z","etag":null,"topics":["adblocking","bash","bash-script","debian-packages","firefox-telemetry","hosts","hostsfile","linux","macos","macos-app","macos-application","privacy","privacy-enhancing-technologies","privacy-protection","privacy-tools","safari","tracking-protection"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angela-d.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-09-03T05:14:35.000Z","updated_at":"2025-08-01T13:51:45.000Z","dependencies_parsed_at":"2024-02-13T21:53:12.481Z","dependency_job_id":"0786a0b9-d232-44b2-9034-255285bb12f6","html_url":"https://github.com/angela-d/autohosts","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/angela-d/autohosts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fautohosts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fautohosts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fautohosts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fautohosts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angela-d","download_url":"https://codeload.github.com/angela-d/autohosts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angela-d%2Fautohosts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013949,"owners_count":26085430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adblocking","bash","bash-script","debian-packages","firefox-telemetry","hosts","hostsfile","linux","macos","macos-app","macos-application","privacy","privacy-enhancing-technologies","privacy-protection","privacy-tools","safari","tracking-protection"],"created_at":"2024-08-01T15:06:17.333Z","updated_at":"2025-10-13T06:11:47.146Z","avatar_url":"https://github.com/angela-d.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Auto Update Ad-blocking Hosts file on Linux and Mac Systems\n\nAutomate hosts file updates on Linux-based and MacOS systems.\n\n![Linux](./img/linux.png)\n![Mac](./img/mac.png)\n\n## v3.1.0 Changes\n\n- Nothing of interest to Linux users\n- Use LaunchAgents instead of cron (Mac)\n- [MDM helper scripts](./mac-mdm-deployment/) added to repo for mass deployment\n\n### Purpose of Hosts Files\nHosts 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.\n\nWhich means any traffic that would have left your system for that destination, is sent inward, to your localhost and then abandoned.\n\nDespite what some may suggest, hosts files are not \"1980s technology\" and still very useful today, as an additional *layer* of security.\n\nHosts file are a useful redundancy when coupled with ad blockers like [uBlock Origin](https://github.com/gorhill/uBlock) and [uMatrix](https://github.com/gorhill/uMatrix) - while debugging or 'Temporarily Allow All on this Site' with [Noscript](https://noscript.net/) can open you up to underlying attacks or privacy intrusions.\n\n- If you're a Safari user and want a pretty pre-made GUI for your adblocking, try [AdGuard](https://adguard.com/en/blog/adguard-safari-extension.html) - *note that this app is a plugin for Safari only; if you want cross-browser blocking, they have paid options, or you can use something like Autohosts for free (this very repo!).*\n\n**In-browser filters won't protect you if the [browser itself](https://spyware.neocities.org/articles/firefox.html) is [phoning home](https://dustri.org/b/mozilla-is-still-screwing-around-with-privacy-in-firefox.html).**\n\nIf you have an up-to-date hosts file, the risk is severely lessened.\n\n**Auto Hosts** will automate the setup process for maintaining an up to date hosts file, by:\n - Installing a weekly cronjob to pull fresh/updated copies of hosts lists (default is every Sunday at 7:22pm)\n - (Default custom_filters and firefox-includes) source appends Facebook trackers, Linkedin ads, Google fonts, Firefox telemetry and other harvester sites that curated lists for whatever reason, have not added to their blacklists\n - Refreshes DNS to instantiate the re-routed changes (Mac Only)\n - If [Devdom](https://notabug.org/angela/devdom) is installed, append all local virtualhosts (*if it is installed* - it is -not- a requirement!  Autohosts does a conditional check to ensure your dev environment doesn't break **if** you're using Devdom.  Read the code.)\n - Uninstall offers the ability to revert to a fresh hosts file and undo any changes made by Autohosts; a backup will be copied to /tmp\n - Add custom blacklists, whitelists and host sources from ~/autohosts on your desktop\n\n## Who Should Use Autohosts?\nIf you are frequently mobile, your privacy-hardened installs of Pi-Hole, OpenWRT or DD-WRT on your home router will not protect you.  Autohosts will shield you while on the go, independent of whose network you logon to.\n\nLikewise, not everyone has the means to flash custom router firmware or the skill necessary to do so.  Autohosts can fill that gap.\n\n\n## Installing:\n![Install](./img/install.png)\n\n### Firefox Snooping list, originally by user LocalFigurez\nFor 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](firefox-includes).  A few of which, some Firefox users have noticed seem to phone home even when the setting is toggled off in about:config.\n\n### Custom filters\nYou 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!\n\n### Whitelisting\nIf the upstream list curators block a domain you want to see, add it to `~/autohosts/whitelist` and run `sudo autohosts`\n\nBe sure to add nothing other than the domain(s) you want to whitelist to this file!  I added 3 examples to the default whitelist file; you can regex it (TLD domain with no prefix or suffix, to whitelist subdomains, too: `example`) or supply a full TLD: `www.example.com`\n\n## To Install\nDebian-based Linux distros:\n```bash\ngit clone https://github.com/angela-d/autohosts.git \u0026\u0026 cd autohosts \u0026\u0026 sudo apt install ./autohosts.deb\n```\n\nMacOS or non-Debian-based Linux distros:\n```bash\ngit clone https://github.com/angela-d/autohosts.git \u0026\u0026 cd autohosts \u0026\u0026 sudo ./autohosts\n```\nThat's it !\n\n***\n## To upgrade an existing install\nTo see which version you're running on your system: `grep \"VERSION=\" /etc/autohosts.conf`\n\n\n### Non-Debian-based distros or MacOS:\nDue to structural changes in the codebase, an uninstall and reinstall is recommended (unless installed via deb).  You can do this without losing your custom filters.\n```bash\ngit clone https://github.com/angela-d/autohosts.git /tmp/autohosts \u0026\u0026 cd /tmp/autohosts \u0026\u0026 cp ~/autohosts/custom_filters /tmp/custom_filters\n```\nOnce installation completes, restore your custom filters:\n```bash\nrm ~/autohosts/custom_filters \u0026\u0026 mv /tmp/custom_filters ~/autohosts/custom_filters\n```\n\n### Debian users\nSimply download the latest .deb \u0026 run (in the directory where you put the download):\n```bash\napt install ./autohosts.deb\n```\nto upgrade to the latest version.\n***\n\n## Adding Custom Blacklists or Whitelists\n- These files can be edited in your favorite text editor; command-line modifications are not necessary!\n\nCustom filters are loaded to your home directory:\n\n\n| Filter Option  | ![Linux](./img/linux.png) Linux File Location | ![Mac](./img/mac.png) Mac File Location|\n| ------------- |:-------------:| :-----:|\n| **Blacklist**      | `~/autohosts/custom_filters` or `/home/your_username/autohosts/custom_filters` | `~/autohosts/custom_filters` or `/Users/your_username/autohosts/custom_filters` |\n| **Whitelist**      | `~/autohosts/whitelist` or `/home/your_username/autohosts/whitelist`      |   `~/autohosts/whitelist` or `/Users/your_username/autohosts/whitelist` |\n| **Hosts List Curator** | `~/autohosts/hosts_source` or `/home/your_username/autohosts/hosts_source` | `~/autohosts/hosts_source` or `/Users/your_username/autohosts/hosts_source` |\n\n\n\n\n### Choosing Hosts Curators\nUse as many as you'd like, to strengthen your filtering.  Though it would be wise to keep the total to a reasonable amount; as there is not currently any duplicate removal, so the potential for unneeded overhead is certain.\n\nList each curator on a separate line in `~/autohosts/hosts_source` - do not add any comments or whitespace to this file - just a list of the [**raw**](https://github.com/StevenBlack/hosts/blob/master/hosts?raw=true) hosts source.  (ie. the plain-text filters).\n\nWhen an update is ran, Autohosts will probe each curator to ensure the list is responding with a 200/OK response, so the potential for indexing garbled junk to your hosts file is severely lessened.\n\n\n### Adjust the cron time\nIf 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:\n```bash\nsudo crontab -e\n```\nand modifying the dates to suit.\n\nCron legend:\n```html\n* * * * * = minute, hour, day of month, month, day of week (0 = Sunday, 6 = Saturday)\n```\n(`*` = *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!)\n\nUninstalling:\n\n![Install](./img/uninstall.png)\n\n**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.\n\n### Alternative uses with Hosts files\n- If you're running DD-WRT, you can add a cron to pull a [hosts file for your entire network](https://github.com/angela-d/brain-dump/blob/master/networking/dd-wrt.md) or load [Pi-Hole](https://pi-hole.net/) to a Raspberry Pi.\n- OpenWRT also has [network-based adblocking](https://github.com/angela-d/brain-dump/blob/master/networking/openwrt-site-blocking.md) capabilities.\n- Rooted Android devices can utilize hosts files, too; simply load the hosts file via `adb push` to `/etc/hosts`\n- If you have to use Windows, [Unified Hosts Autoupdate](https://github.com/ScriptTiger/Unified-Hosts-AutoUpdate) offers similar capabilities to Autohosts, in a Windows environment\n\n### Troubleshooting\nIf it appears autohosts isn't blocking anything, your browser likely has imposed DoH / DNS Over HTTPS on you.\n\n***\n\n**If you'd like to disable DoH:**\n\nVivaldi or Chrome / Chromium:\n\n- Enter `chrome://flags` in your address bar and find: `Secure DNS lookups` \u003e toggle to disable\n\nFirefox:\n\n- Enter `about:preferences` on your address bar and in the search box, enter `dns` \u003e Settings \u003e scroll to the bottom and un-tick `Enable DNS over HTTPS`\n\n### Known Bugs / To Fix\nmanpage on Debian isn't seen.  No manpage at all for non-Debian installs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangela-d%2Fautohosts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangela-d%2Fautohosts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangela-d%2Fautohosts/lists"}