跳转至主内容

概览

What is AdGuard DNS CLI?

A cross-platform lightweight DNS client for AdGuard DNS. 它充当一个 DNS 服务器,将 DNS 请求转发到相应的上游解析器。

快速开始

支持的操作系统:

  • Linux
  • macOS
  • Windows

支持的 CPU 架构:

  • 64-bit ARM
  • AMD64
  • i386

开始

类 Unix 操作系统

  1. 版本页面下载并解压 .tar.gz.zip 文件。

    caution

    On macOS, it’s crucial that globally installed daemons are owned by root (see the launchd documentation), so the adguarddns-cli executable must be placed in the /Applications/ directory or its subdirectory.

  2. 安装并运行以下命令将其设置为服务:

    ./adguarddns-cli -s install -v
  3. 编辑配置文件 config.yaml

  4. 启动服务:

    ./adguarddns-cli -s start -v

使用任意 DNS 检查工具验证是否运行正常。 例如,使用 nslookup

nslookup -debug 'www.example.com' '127.0.0.1'

Windows

只需从版本页面下载 MSI 安装程序并安装即可。

使用任意 DNS 检查工具验证是否运行正常。 例如,使用 nslookup.exe

nslookup -debug "www.example.com" "127.0.0.1"

命令行选项

每个选项都会覆盖配置文件和环境变量中的对应值。

帮助

Option -h makes AdGuard DNS CLI print out a help message to standard output and exit with a success status-code.

服务

-s <value> 选项用于指定对操作系统服务的操作。 可能的选项值如下:

  • install: installs AdGuard DNS CLI as a service
  • restart: restarts the running AdGuard DNS CLI service
  • start: starts the installed AdGuard DNS CLI service
  • status: shows the status of the installed AdGuard DNS CLI service
  • stop: stops the running AdGuard DNS CLI
  • uninstall: uninstalls AdGuard DNS CLI service

详细日志输出

-v 选项用于启用详细日志输出。

版本

Option --version makes AdGuard DNS CLI print out the version of the application to standard output and exit with a success status-code.

配置文件

文件

YAML 配置文件在配置文件说明中描述,并有一个示例配置文件 config.dist.yaml。 部分配置参数可以通过设置环境变量来覆盖配置文件中的值。

退出代码

在不同的错误状况下返回不同的退出代码:

  • 0:成功完成并退出,没有错误。

  • 1:内部错误,很可能是配置错误导致。

  • 2:无效的命令行参数或参数值。