hblock

hectormMIT活跃维护

用 Shell 脚本生成 hosts 文件,把广告、追踪和恶意域名解析到黑洞地址,从 DNS 层面提升上网隐私与安全。

Improve your security and privacy by blocking ads, tracking and malware domains.

v3.5.2发布于 2026-10-31 14:15 UTC2,010star +2 / 7 天117fork同步于 2026-11-10 17:47 UTC

怎么上手

由 README 提炼,执行前请确认
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
硬件要求按 README 说明

README 未说明,纯 shell 脚本,不涉及 GPU 或显存

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 POSIX shell 脚本聚合多源广告与恶意域名,生成 hosts 文件拦截连接

用 Shell 脚本生成 hosts 文件,把广告、追踪和恶意域名解析到黑洞地址,从 DNS 层面提升上网隐私与安全。

核心能力

  • 从多个来源汇总广告、追踪与恶意域名
  • 生成 hosts 文件及其他多种格式
  • 兼容 POSIX 的 shell 脚本,依赖极少
  • 提供 systemd timer 定期自动更新
  • 支持通过 allowlist 临时放行误杀域名

容易踩的坑

默认会直接替换系统 hosts 文件,有自定义条目需先备份;定期更新需自行配置 systemd timer;误杀域名需加入 allowlist 并向原始 blocklist 作者反馈

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v3.5.2
  1. v3.5.2最新正式版2026-10-31 · 2026-10-31 14:15 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/hectorm/hblock/compare/v3.5.1...v3.5.2

  2. v3.5.12025-03-12 · 2025-03-12 19:30 UTC
    查看更新说明
  3. v3.5.02024-10-22 · 2024-10-22 20:52 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/hectorm/hblock/compare/v3.4.5...v3.5.0

  4. v3.4.52024-05-29 · 2024-05-29 22:58 UTC
    查看更新说明
  5. v3.4.42024-01-24 · 2024-01-24 18:54 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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.

    asciicast

    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.