默认会直接替换系统 hosts 文件,有自定义条目需先备份;定期更新需自行配置 systemd timer;误杀域名需加入 allowlist 并向原始 blocklist 作者反馈
hblock
hectormMIT活跃维护用 Shell 脚本生成 hosts 文件,把广告、追踪和恶意域名解析到黑洞地址,从 DNS 层面提升上网隐私与安全。
Improve your security and privacy by blocking ads, tracking and malware domains.
curl -o /tmp/hblock 'https://raw.githubusercontent.com/hectorm/hblock/v3.5.2/hblock' && echo 'fd73aca7ddeeb0308ac265d4b2689ab84a9a82e03f9af19fd134a56a286a1a1b /tmp/hblock' | shasum -c && sudo mv /tmp/hblock /usr/local/bin/hblock && sudo chown 0:0 /usr/local/bin/hblock && sudo chmod 755 /usr/local/bin/hblockREADME 未说明,纯 shell 脚本,不涉及 GPU 或显存
用 POSIX shell 脚本聚合多源广告与恶意域名,生成 hosts 文件拦截连接
用 Shell 脚本生成 hosts 文件,把广告、追踪和恶意域名解析到黑洞地址,从 DNS 层面提升上网隐私与安全。
核心能力
- 从多个来源汇总广告、追踪与恶意域名
- 生成 hosts 文件及其他多种格式
- 兼容 POSIX 的 shell 脚本,依赖极少
- 提供 systemd timer 定期自动更新
- 支持通过 allowlist 临时放行误杀域名
容易踩的坑
- v3.5.2最新正式版2026-10-31 · 2026-10-31 14:15 UTC
What's Changed
- fix: Github Actions kept failing due to missing package by @securitysteven in https://github.com/hectorm/hblock/pull/182
- Bump actions/checkout from 4 to 5 in the github-actions-all group by @dependabot[bot] in https://github.com/hectorm/hblock/pull/186
- Bump actions/checkout from 5 to 6 in the github-actions-all group by @dependabot[bot] in https://github.com/hectorm/hblock/pull/191
- Fix subdomain filtering for domains containing hyphens by @pasqualtroncone in https://github.com/hectorm/hblock/pull/204
- Bump actions/checkout from 6 to 7 in the github-actions-all group by @dependabot[bot] in https://github.com/hectorm/hblock/pull/199
New Contributors
- @securitysteven made their first contribution in https://github.com/hectorm/hblock/pull/182
- @pasqualtroncone made their first contribution in https://github.com/hectorm/hblock/pull/204
Full Changelog: https://github.com/hectorm/hblock/compare/v3.5.1...v3.5.2
- v3.5.12025-03-12 · 2025-03-12 19:30 UTC
查看更新说明
Full Changelog: https://github.com/hectorm/hblock/compare/v3.5.0...v3.5.1
- v3.5.02024-10-22 · 2024-10-22 20:52 UTC
查看更新说明
What's Changed
- feat: hblock can now retry multiple times with the -n or --retry option by @federicotorrielli in https://github.com/hectorm/hblock/pull/167
New Contributors
- @federicotorrielli made their first contribution in https://github.com/hectorm/hblock/pull/167
Full Changelog: https://github.com/hectorm/hblock/compare/v3.4.5...v3.5.0
- v3.4.52024-05-29 · 2024-05-29 22:58 UTC
查看更新说明
Full Changelog: https://github.com/hectorm/hblock/compare/v3.4.4...v3.4.5
- v3.4.42024-01-24 · 2024-01-24 18:54 UTC
查看更新说明
Full Changelog: https://github.com/hectorm/hblock/compare/v3.4.3...v3.4.4
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
What is this for?
hBlock is a POSIX-compliant shell script that gets a list of domains that serve ads, tracking scripts and malware from multiple sources and creates a hosts file, among other formats, that prevents your system from connecting to them.
:warning: hBlock by default replaces the hosts file of your system, consider making a backup first if you have entries you want to preserve.
Installation
hBlock is available in various package managers. Please check the PACKAGES.md file for an up-to-date list.
The latest available version can also be installed manually by running the following commands:
curl -o /tmp/hblock 'https://raw.githubusercontent.com/hectorm/hblock/v3.5.2/hblock' \
&& echo 'fd73aca7ddeeb0308ac265d4b2689ab84a9a82e03f9af19fd134a56a286a1a1b /tmp/hblock' | shasum -c \
&& sudo mv /tmp/hblock /usr/local/bin/hblock \
&& sudo chown 0:0 /usr/local/bin/hblock \
&& sudo chmod 755 /usr/local/bin/hblock
Additionally, a systemd timer can be set to regularly update the hosts file for new additions.
Usage
The default behavior of hBlock can be adjusted with multiple options. Use the --help option or check the hblock.1.md file for the
full list.
Nightly builds
Nightly builds of the hosts file, among other formats, can be found on the hBlock website.
Temporarily disable hBlock
Sometimes you may need to temporarily disable hBlock, a quick option is to generate a hosts file without any blocked domains by running the following command:
hblock -S none -D none
I found a false positive, what should I do?
It's possible that sometimes one of the hBlock sources includes a domain that shouldn't be blocked, in those cases the best way to proceed is to temporarily add said domain to the allowlist and report the problem to the original blocklist author. This way it will also be automatically removed from hBlock within 24h.
To find which blocklist is behind a false positive you can clone the hMirror project and search for that domain. Although please note that not all hMirror blocklists are used by default in hBlock, an updated list of the sources used can be found in the SOURCES.md file.