The easiest way to configure Knot Resolver is via the /etc/knot-resolver/config.yaml file containing a declarative YAML configuration.

You can start exploring the configuration by reading further in this chapter, or you can take a look at the complete configuration documentation.

Complete example configuration files can be found in Knot Resolver’s source repository. Examples are also installed as documentation files, typically in the /usr/share/doc/knot-resolver/examples/ directory (the location may differ based on your Linux distribution).


The kresctl utility may be used to validate your configuration before you push it to the running resolver. This can help prevent typos in the configuration from causing resolver outages.

$ kresctl validate /etc/knot-resolver/config.yaml

If you update the configuration file while Knot Resolver is running, you can force the resolver to reload it by invoking a systemd reload command.

$ systemctl reload knot-resolver.service


Reloading configuration may fail, even when your configuration is valid, because some options cannot be changed while running. You can always find an explanation of the error in the log accesed by the journalctl -eu knot-resolver command.

Listening on network interfaces

The first thing you will probably want to configure are the network interfaces to listen on. The following example instructs the resolver to receive standard unencrypted DNS queries on IP addresses and 2001:db8::1. Encrypted DNS queries using the DNS-over-TLS protocol are accepted on all IP addresses of the eth0 network interface, TCP port 853.

    - interface: # port 53 is default
        - 2001:db8::1
    - interface: eth0
      port: 853
      kind: dot # DNS-over-TLS

For more details, see network configuration.


On machines with multiple IP addresses, avoid listening on wildcards like or ::. If a client can be reached through multiple addresses, UDP answers from a wildcard address might pick a wrong source address - most well-behaved clients will then refuse such a response.

Example: Internal Resolver

This is an example configuration snippet typical for a company-internal resolver inaccessible from the outside of a company network.

Internal-only domains

An internal-only domain is a domain not accessible from the public Internet. In order to resolve internal-only domains, a query policy needs to be added to forward queries to a correct internal server. This configuration will forward the two listed domains to an internal authoritative DNS server with the IP address

  # define a list of internal-only domains
  - subtree:
      - company.example
      - internal.example
    # forward all queries belonging to the domains in the list above to IP address ''
    # common options configuration for internal-only domains
      authoritative: true
      dnssec: false

See the forwarding chapter for more details.

Example: ISP Resolver

The following configuration snippets are typical for Internet Service Providers offering DNS resolver services to their own clients on their own network. Please note that running a public DNS resolver is a more complicated use-case and not covered by this example.

Limiting client access

With the exception of public resolvers, a DNS resolver should resolve only queries sent by clients in its own network. This restriction limits the attack surface on the resolver itself, as well as the rest of the Internet.

In a situation where access to your DNS resolver is not limited using an IP firewall, you may want to implement access restrictions. The following example allows only queries from clients on the subnet and refuses all the rest.

  # refuse everything that hasn't matched
  - subnets: [, "::/0" ]
    answer: refused
  # whitelist queries identified by subnet
  - subnets: [ ]
    answer: allow

TLS server configuration

Knot Resolver supports secure transport for DNS queries between client machines and the resolvers, a feature whose popular demand is on the rise. The recommended way to achieve this is to start a DNS-over-TLS server and accept encrypted queries.

First step is to enable TLS on listening interfaces:

    # DNS over TLS on port 853
    - interface:
        - 2001:db8::1
      kind: dot

By default, a self-signed certificate is generated. The second step is then obtaining and configuring your own TLS certificates signed by a trusted CA. Once a certificate was obtained, a path to the certificate files can be specified as follows:

    cert-file: '/etc/knot-resolver/server-cert.pem'
    key-file: '/etc/knot-resolver/server-key.pem'

Mandatory domain blocking

Some jurisdictions mandate blocking access to certain domains. This can be achieved using by using rules.

    - name:
      type: nxdomain

Example: Personal Resolver

DNS queries can be used to gather data about user behavior. Knot Resolver can be configured to forward DNS queries elsewhere, to protect the users from being eavesdropped on by using TLS encryption.


Latest research has proven that encrypting DNS traffic is not sufficient to protect the users’ privacy. Therefore, we recommend all users to use a full VPN instead of encrypting just DNS queries. The following configuration is provided only for users who are not able to encrypt all their traffic. For more information, please see the following articles:

Forwarding over TLS protocol (DNS-over-TLS)

Forwarding over the TLS protocol protects DNS queries sent out by the resolver. It can be configured using forwarding, which provides settings for authentication.

  # encrypted public resolver, for all names
  - subtree: "."
      - address:
          - 2001:148f:fffe::1
        transport: tls


See list of DNS Privacy Test Servers supporting DNS-over-TLS to test your configuration.

Non-persistent cache

Knot Resolver’s cache contains data its clients queried for. If you are concerned about attackers who are able to get access to your computer system in power-off state, and your storage device is not secured by encryption, you can move the cache to tmpfs. See Persistence.