Skip to content

Configuration File Example

This example shows how to use a configuration file with the DNS server CLI.

Configuration File

Create config.yaml:

yaml
server:
  host: "0.0.0.0"
  port: 53
  ttl: 500

dot:
  enabled: false

hosts:
  "example.com": "1.2.3.4"
  # Alias target (CNAME-like flattening)
  "mysql.ops.ys.idp.internal": "db.tencentcloud.com"
  # Explicit alias format (extension)
  "redis.ops.ys.idp.internal":
    cname: "redis.tencentcloud.com"
  "www.example.com":
    - "1.2.3.4"
    - "1.2.3.5"
  "*.example.com": "1.2.3.4"

system_hosts:
  disabled: false
  file_path: "/etc/hosts"

upstream:
  servers:
    - "8.8.8.8:53"
    - "tls://1.1.1.1"
  timeout: "5s"

# Optional: disable response cache (on by default; see Configuration guide)
# cache:
#   enabled: false

Using Configuration File

Start the server with the configuration file:

bash
dns server --config config.yaml

Command Line Override

Command line flags override config file values:

bash
# config.yaml has port: 53, but command line overrides it
dns server --config config.yaml --port 5353

Complete Example

See example/conf/server.yaml in the repository for a complete configuration file example.

Next Steps

Released under the MIT License.