🚀 快速访问
访问 Blocky 管理 API 和监控接口:
项目简介
Blocky 是一个高性能的 DNS 代理服务器,主要用于本地网络环境中拦截广告、追踪器和恶意域名。它采用 Go 语言开发,具有出色的性能和极低的资源占用。
主要功能
🛡️ 广告和追踪器拦截
基于可自定义的黑名单拦截广告、追踪器和恶意域名
📋 多种拦截列表支持
支持多种格式的拦截列表,包括 hosts 文件和域名列表
👥 客户端分组
为不同客户端配置不同的拦截规则和上游 DNS 服务器
⚡ DNS 缓存
内置智能缓存机制,提升 DNS 查询速度
🔀 条件转发
根据域名条件转发到不同的上游 DNS 服务器
🔒 DoH 和 DoT 支持
支持 DNS over HTTPS (DoH) 和 DNS over TLS (DoT)
🔌 REST API
提供 REST API 接口用于管理和监控
📈 Prometheus 监控
内置 Prometheus 指标导出,便于集成监控系统
快速开始
在 Lazycat 平台部署
- 访问 Lazycat 应用市场
- 搜索并选择 "Blocky"
- 点击"一键部署"按钮
- 根据需要调整配置参数
- 完成部署后即可使用
使用指南
访问 API 和监控
部署成功后,您可以通过以下方式访问 Blocky 的管理接口:
常用 API 端点
| 端点 |
方法 |
描述 |
/api/blocking/status |
GET |
获取拦截功能状态 |
/api/blocking/enable |
GET |
启用拦截功能 |
/api/blocking/disable |
GET |
临时禁用拦截功能 |
/api/lists/refresh |
POST |
刷新拦截列表 |
/api/query?domain=example.com |
GET |
测试域名查询 |
配置 DNS 客户端
要使用 Blocky 作为 DNS 服务器,需要将局域网设备的 DNS 设置指向 Blocky 服务器。
⚠️ 重要: Blocky 的 DNS 端口(53)默认仅在容器内网可用。要在局域网中使用,需要配置端口转发。
步骤 1: 部署 Port Forwarder 应用
为了让局域网设备能够使用 Blocky 作为 DNS 服务器,您需要:
- 在 Lazycat 应用市场 搜索并部署 Port Forwarder(局域网端口转发工具)
- 配置端口转发规则,将宿主机外部 IP 的 TCP 53 和 UDP 53 端口映射到 Blocky 应用的 53 端口
- 保存配置并启动 Port Forwarder
✅ 配置完成后: 您可以在局域网中将设备的 DNS 服务器设置为 Lazycat 平台的局域网 IP 地址,即可使用 Blocky 进行 DNS 解析和广告拦截。
步骤 2: 配置设备 DNS
在您的路由器或设备上,将 DNS 服务器设置为 Lazycat 平台的局域网 IP 地址(例如: 192.168.1.100)。
示例:测试 DNS 查询
# 使用 dig 命令测试(假设服务器 IP 是 192.168.1.100)
dig @192.168.1.100 -p 53 example.com
# 测试拦截功能(查询已知广告域名)
dig @192.168.1.100 -p 53 doubleclick.net
# 如果返回 0.0.0.0,说明拦截成功
查看拦截日志
在 Lazycat 平台的应用管理界面,可以查看 Blocky 的日志输出,日志中会显示:
- 被拦截的域名查询(标记为
response_reason=BLOCKED)
- 正常解析的域名
- 上游 DNS 服务器响应时间
- 缓存命中情况
配置说明
Blocky 的配置文件为 config.yml,在 Lazycat 平台部署时已预配置。
📁 配置文件路径: 在 Lazycat 平台上,实际的配置文件位于:
/data/appvar/cloud.lazycat.app.liu.blocky/config/config.yml
上游 DNS 服务器
默认配置了多个可靠的 DNS 服务器:
- Google DNS: 8.8.8.8
- Cloudflare DNS: 1.1.1.1
- DNS over TLS: fdns1.dismail.de:853
- DNS over HTTPS: dns.digitale-gesellschaft.ch
广告拦截列表
默认启用了 StevenBlack hosts 拦截列表,包含:
💡 关于拦截列表文件:
- 默认配置: 为了解决访问外网的问题,安装包中默认使用本地文件
/lzcapp/pkg/content/config/hosts,这是从 StevenBlack 项目预先下载的。
- 在线更新: 如果您的 Lazycat 平台能够访问外网,可以在配置文件中修改为公网地址:
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
这样可以自动获取最新的拦截列表。
自定义配置
您可以在配置文件中自定义:
- 添加更多拦截列表
- 配置客户端分组规则
- 设置条件 DNS 转发
- 配置自定义域名解析
- 调整缓存策略
常见问题
Q: 如何临时禁用广告拦截?
A: 通过 API 禁用拦截功能:
curl http://YOUR_DOMAIN:4000/api/blocking/disable
重新启用:
curl http://YOUR_DOMAIN:4000/api/blocking/enable
Q: 如何刷新拦截列表?
A: 拦截列表默认每 24 小时自动刷新。手动刷新可以使用:
curl -X POST http://YOUR_DOMAIN:4000/api/lists/refresh
Q: 某些正常网站被错误拦截怎么办?
A: 在配置文件的 blocking.allowlists 部分添加白名单规则,详见配置文件注释。
Q: 如何查看当前拦截统计?
A: 访问 Prometheus 指标端点查看详细统计:
curl http://YOUR_DOMAIN:4000/metrics
致谢
本项目基于 Blocky 开源项目进行移植和封装。感谢 Blocky 开发团队和开源社区的贡献者们创造了如此优秀的 DNS 代理工具。
特别感谢:
🚀 Quick Access
Access Blocky management API and monitoring interface:
Introduction
Blocky is a high-performance DNS proxy server designed for local network environments to block ads, trackers, and malicious domains. Built with Go, it offers excellent performance with minimal resource consumption.
Key Features
🛡️ Ad & Tracker Blocking
Block ads, trackers, and malicious domains using customizable denylists
📋 Multiple List Formats
Support for various blocklist formats including hosts files and domain lists
👥 Client Groups
Configure different blocking rules and upstream servers for different clients
⚡ DNS Caching
Built-in intelligent caching mechanism to improve DNS query speed
🔀 Conditional Forwarding
Route domains to specific upstream DNS servers based on conditions
🔒 DoH & DoT Support
Support for DNS over HTTPS (DoH) and DNS over TLS (DoT)
📊 Query Logging
Optional query logging for monitoring and debugging
🔌 REST API
REST API interface for management and monitoring
📈 Prometheus Metrics
Built-in Prometheus metrics export for monitoring integration
Quick Start
Deploy on Lazycat Platform
- Visit Lazycat App Marketplace
- Search and select "Blocky"
- Click "One-Click Deploy" button
- Adjust configuration parameters as needed
- Start using after deployment completes
Usage Guide
Access API and Monitoring
After successful deployment, you can access Blocky's management interface:
📌 Access URLs: Using your app domain as an example:
- API Address:
- Prometheus Metrics:
Common API Endpoints
| Endpoint |
Method |
Description |
/api/blocking/status |
GET |
Get blocking status |
/api/blocking/enable |
GET |
Enable blocking |
/api/blocking/disable |
GET |
Temporarily disable blocking |
/api/lists/refresh |
POST |
Refresh blocklists |
/api/query?domain=example.com |
GET |
Test domain query |
Configure DNS Client
To use Blocky as your DNS server, you need to point your LAN devices' DNS settings to the Blocky server.
⚠️ Important: Blocky's DNS port (53) is only accessible within the container network by default. To use it on your LAN, you need to configure port forwarding.
Step 1: Deploy Port Forwarder Application
To allow LAN devices to use Blocky as their DNS server, you need to:
- Search and deploy Port Forwarder from Lazycat App Marketplace
- Configure port forwarding rules to map the host's external IP TCP 53 and UDP 53 ports to Blocky application's port 53
- Save the configuration and start Port Forwarder
✅ After Configuration: You can set your devices' DNS server to the Lazycat platform's LAN IP address, enabling DNS resolution and ad blocking through Blocky.
Step 2: Configure Device DNS
On your router or device, set the DNS server to the Lazycat platform's LAN IP address (e.g., 192.168.1.100).
Example: Test DNS Query
# Test using dig command (assuming server IP is 192.168.1.100)
dig @192.168.1.100 -p 53 example.com
# Test blocking feature (query known ad domain)
dig @192.168.1.100 -p 53 doubleclick.net
# If returns 0.0.0.0, blocking is working
View Blocking Logs
In the Lazycat Platform app management interface, you can view Blocky's log output, which shows:
- Blocked domain queries (marked as
response_reason=BLOCKED)
- Normally resolved domains
- Upstream DNS server response times
- Cache hit statistics
Configuration
Blocky's configuration file is config.yml, pre-configured when deployed on Lazycat Platform.
📁 Configuration File Path: On Lazycat Platform, the actual configuration file is located at:
/data/appvar/cloud.lazycat.app.liu.blocky/config/config.yml
Upstream DNS Servers
Multiple reliable DNS servers configured by default:
- Google DNS: 8.8.8.8
- Cloudflare DNS: 1.1.1.1
- DNS over TLS: fdns1.dismail.de:853
- DNS over HTTPS: dns.digitale-gesellschaft.ch
Ad Blocklists
Enabled StevenBlack hosts blocklist by default, including:
- Ad servers
- Trackers
- Malicious domains
💡 About Blocklist Files:
- Default Configuration: To solve internet access issues, the package uses a local file by default:
/lzcapp/pkg/content/config/hosts, which is pre-downloaded from the StevenBlack project.
- Online Updates: If your Lazycat platform can access the internet, you can modify the configuration file to use the public URL:
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
This allows automatic updates to the latest blocklist.
Custom Configuration
You can customize in the configuration file:
- Add more blocklists
- Configure client group rules
- Set up conditional DNS forwarding
- Configure custom domain resolution
- Adjust caching policies
FAQ
Q: How to temporarily disable ad blocking?
A: Disable blocking via API:
curl http://YOUR_DOMAIN:4000/api/blocking/disable
Re-enable:
curl http://YOUR_DOMAIN:4000/api/blocking/enable
Q: How to refresh blocklists?
A: Blocklists refresh automatically every 24 hours. To manually refresh:
curl -X POST http://YOUR_DOMAIN:4000/api/lists/refresh
Q: What if legitimate websites are incorrectly blocked?
A: Add allowlist rules in the blocking.allowlists section of the configuration file. See config comments for details.
Q: How to view current blocking statistics?
A: Access the Prometheus metrics endpoint for detailed statistics:
curl http://YOUR_DOMAIN:4000/metrics
Acknowledgments
This project is based on the open-source Blocky project. Thanks to the Blocky development team and open-source community contributors for creating such an excellent DNS proxy tool.
Special thanks to:
- Blocky project maintainer 0xERR0R and all contributors
- Community projects providing various blocklists, such as StevenBlack hosts project
- Lazycat Platform for providing app deployment capabilities