CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

dig (BIND)

$ dig 基金会 低风险
Internet Systems Consortium (ISC) · 浏览器与网页抓取 · MPL-2.0 · macos / linux / windows

ISC BIND 套件中的 dig 是几乎所有 macOS 与 Linux 主机自带的经典 DNS 排查工具。传入 +short 或 +noall +answer 可裁剪冗长头部信息,便于 Shell 脚本解析。

FCRS-1.0 综合评分
86 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install bind
CLI vs MCP 选型建议 仅 CLI 可用

零安装的基础 DNS 诊断工具;在管道中使用 +short,若环境已装 doggo 则可优先使用 doggo --json。

Agent 友好度体检单

本地探针实测证据
— 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
✓ 只读模式开关
✓ 支持 NO_COLOR
— 自省/Schema 发现
— 官方 SKILL.md
实测版本
DiG 9.10.6
冷启动耗时
3 ms
退出码 (help / 非法参数)
1 / 1
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
Invalid option: --help
Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} [...]]

Use "dig -h" (or "dig -h | more") for complete list of options

FCRS-1.0 六维评分拆解

Agent 友好度 19 / 25

借助 +short 与 +noall +answer 实现确定性非交互输出,但缺少原生 JSON 格式。

  • Supports +short and +noall +answer filtering; plain text output only
安全与权限边界 24 / 25

严格只读的 DNS 解析工具,不写入本地文件。

  • Read-only DNS queries without credential storage
安装与运行摩擦 15 / 15

预装于 macOS 与绝大多数 Linux 系统(通过 bind-utils / dnsutils)。

  • Pre-installed system utility across Unix environments
能力覆盖与边际价值 12 / 15

支持可靠的 +trace 链路追踪与 +short 过滤,但在结构化输出上不如 doggo --json。

  • Supports +trace, +short, DNSSEC (+dnssec), and DoH in newer BIND
维护与来源背书 9 / 10

由 Internet Systems Consortium(ISC)在 MPL-2.0 协议下长期维护。

  • Official ISC BIND9 project
文档与可验证性 7 / 10

man 手册详尽,但 +option 风格参数与常规 --flag 不同。

  • Official BIND9 man page documentation

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

常规查询无需凭据;可选 TSIG 密钥(-k/-y)需显式传入。

潜在副作用
只读查询
费用与配额提示

免费开源(MPL-2.0 协议);macOS 与多数 Linux 发行版自带。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# dig Agent Rules
- Always pass `+short` or `+noall +answer` to avoid wasting tokens on default BIND statistics banners.
- Use `+time=5 +tries=2` when querying unresponsive nameservers.

Agent 高频安全命令配方

只读查询(安全推荐)

获取精简 DNS 解析结果
dig +short @1.1.1.1 example.com A

使用 +short 直接向 1.1.1.1 查询并仅打印解析出的 IP 地址,去除冗余信息。

查看含 TTL 的完整应答记录
dig +noall +answer example.com MX

关闭统计头噪音(+noall)并仅输出应答段(+answer)。

核心优势

  • + macOS 与多数 Linux 服务器/容器默认预装,无需安装。
  • + +short 与 +trace 能可靠定位 DNS 委派与传播问题。

注意事项与踩坑点

  • ! 无原生 JSON 输出;默认会打印冗长 BIND 统计头,需加 +noall +answer 或 +short。
  • ! 特有的 +option 开关语法略显非主流。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI