Systemd

In the default installation, Knot Resolver contains systemd integration and starting it on such system usually involves only one command.

systemctl enable --now knot-resolver.service

If you don’t have systemd service file for Knot Resolver already installed in your system, you can create one manually with the folling content:

[Unit]
Description=Knot Resolver Manager
Documentation=man:knot-resolver.systemd(7)
Wants=network-online.target
After=network-online.target
Before=nss-lookup.target
Wants=nss-lookup.target

[Service]
Type=notify
TimeoutStartSec=10s
ExecStart=@bin_dir@/knot-resolver --config=@etc_dir@/config.yaml
Environment=KRES_LOGGING_TARGET=syslog
ExecReload=@bin_dir@/kresctl --config=@etc_dir@/config.yaml reload
KillSignal=SIGINT
WorkingDirectory=@systemd_work_dir@
User=@user@
Group=@group@
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETPCAP
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_SETPCAP

[Install]
WantedBy=multi-user.target

Note

Replace words surrounded by @ to some real values (i.e. @user@ to a user you want Knot Resolver to run as).