跳转至主内容

配置文件

See file config.dist.yml for a full example of a YAML configuration file with comments.

dns

dns 配置对象用于设置 DNS 服务器的行为。 它包含以下属性:

cache

cache 对象配置缓存查询 DNS 的结果。 它包含以下属性:

  • enabled:是否启用 DNS 结果缓存。

    示例: true

  • size:DNS 结果缓存的最大值(人类可读的数据量格式)。 如果 enabledtrue,该值必须大于零。

    示例: 128MB

  • client_size:指定每个已配置客户端地址或子网的 DNS 结果缓存的最大尺寸(人类可读的数据量格式)。 如果 enabledtrue,该值必须大于零。

    示例 4MB

server

server 对象配置处理传入请求。 它包含以下属性:

  • bind_retry: The configuration of the retry mechanism for binding to the listen addresses. 这适用于当服务器在网络准备就绪之前启动且地址尚不可用的情况,例如在某些版本的 Windows 上作为系统服务安装时。

    note

    此对象自 v0.0.3 起可用。

    它包含以下属性:

    • enabled:是否启用绑定重试。

      示例: true

    • interval:重试间隔时间,以人类可读取的时间长度表示。

      示例1s

    • count:第一次失败后的最大尝试次数。 也就是说,如果 count4,则总尝试次数将为五次。

      示例4

  • listen_addresses:客户端监听的地址和端口集合。

    属性示例:

    'listen_addresses':
    - address: '127.0.0.1:53'
    - address: '[::1]:53'
  • pending_requests:用于处理重复的同时请求的配置,以缓解缓存中毒攻击。

    note

    该对象自版本 v0.0.4 起可用。

    • enabled:如果为真,服务器将只对每个唯一问题执行一次请求。 默认值为「true」。

      示例: true

bootstrap

bootstrap 对象配置上游服务器地址的解析。 它包含以下属性:

  • servers:该列表用于指定上游服务器主机名的解析服务器。

    属性示例:

    'servers':
    - address: '8.8.8.8:53'
    - address: '192.168.1.1:53'
  • timeout:指定引导 DNS 请求的超时时间,使用人类可读的数据量格式。

    示例2s

upstream

upstream 对象用于配置实际的请求解析。 它包含以下属性:

  • groups:使用服务器组名称作为键值定义了一组上游服务器集合。 它包含以下属性:

    • address: The upstream server’s address. If autodevice.enabled set to true for this group, the address should be a URL with one of https, tls, or quic scheme.

      示例: '8.8.8.8:53'

    • autodevice: Represents an automatic connection of a device.

      note

      The autodevice option must be used only for AdGuard DNS upstreams. Otherwise, we can’t guarantee proper work.

      它包含以下属性:

      • enabled: Defines whether all clients within the current group can be connected automatically.

        info

        The predefined private group must have enabled set to false, as it doesn't support autodevice yet.

      • profile_id: ID of a profile, in which new devices will be added.

      • device_type: A type of device which will be created for new clients.

      属性示例:

      'autodevice':
      - enabled: true
      - profile_id: 'defa5678'
      - device_type: 'lnx'
    • match: 用于定义将哪些请求路由到该服务器组进行解析。 每个列表项可以包含以下属性:

      • question_domain:指定域名或域名后缀。如果请求的域名匹配该值,则使用此服务器组进行解析。

        示例: 'mycompany.local'

      • client:指定客户端的地址或子网。如果请求来自匹配的客户端地址或子网,则使用此服务器组进行解析。 该值必须是子网掩码内的有效地址。

        示例: '192.0.2.0/24'

      note

      同一条目中指定的属性会使用逻辑 AND 进行组合判断。 不同条目之间的判断会使用逻辑 OR 进行组合判断。

      属性示例:

      'match':
      - question_domain: 'mycompany.local'
      client: '192.168.1.0/24'
      - question_domain: 'mycompany.external'
      - client: '1.2.3.4'
    info

    groups 配置中至少需要包含一个名为 default 的条目,并且可以 (可选) 包含一个名为 private 的条目,两个条目都不应该包含 match 属性。 The private group is also used to define the HumanID for clients created by autodevice feature. If it is not defined, an alternative generation method is used, whereby the HumanID is formed from the IP address.

    当其他组的匹配规则都不满足时,将使用 default 组指定的服务器进行解析。 如果定义了 private 组,则会将其用于解析来自私有 IP 地址的反向解析请求 (PTR)。 如果未定义 private 组,此类请求将返回 NXDOMAIN

  • timeout:指定上游 DNS 请求的超时时间,使用人类可读的数据量格式。

    示例: 2s

fallback

fallback 对象用于配置当主上游 DNS 服务器无法响应时的备用行为。 它包含以下属性:

  • servers:指定在主上游服务器无法响应时使用的备用服务器列表。

    属性示例:

    'servers':
    - address: 'tls://94.140.14.140'
  • timeout:指定备用 DNS 请求的超时时间,使用人类可读的数据量格式。

    示例: 2s

debug

debug 对象配置调试功能。 它包含以下属性:

pprof

pprof 对象配置 pprof HTTP 处理程序。 它包含以下属性:

  • port: 用于在本地监听调试 HTTP 请求的端口。

    示例: 6060

  • enabled:是否启用调试。

    示例: true

log

log 对象配置日志记录。 它包含以下属性:

  • output:指定日志记录的输出位置。

    note

    写入系统日志的日志条目采用 text 文本格式(如下),并使用系统时间戳。

    可能的选项值如下:

    • syslog 表示使用特定于平台的系统日志,对于 Linux 是 syslog,对于 Windows 是 Event Log。

    • stdout 表示标准输出流。

    • stderr 表示标准错误流。

    • 日志文件的绝对路径。

    示例: /home/user/logs

    示例: C:\Users\user\logs.txt

    示例: syslog

  • format:指定日志条目的格式。

    可能的选项值如下:

    • default:简单格式。 例如:

      INFO service started prefix=program addr=127.0.0.1:53
    • json:结构化 JSON 格式。 例如:

      {"level":"INFO","msg":"service started","prefix":"program","addr":"127.0.0.1:53"}
    • jsonhybrid:与 json 相同,但字段数量有限。 例如:

      {"level":"INFO","msg":"service started, attrs: prefix=program addr=127.0.0.1:53"}
    • text:结构化文本格式。 例如:

      level=INFO msg="service started" prefix=program addr=127.0.0.1:53

    示例: default

  • timestamp:指定是否在日志条目中包含时间戳。

    示例: false

  • verbose:指定是否启用详细日志输出。

    示例: false