Installing from packages¶
The resolver is packaged for Debian, Fedora+EPEL, Ubuntu, Docker, NixOS/NixPkgs, FreeBSD, HomeBrew, and Turris Omnia. Some of these are maintained directly by the knot-resolver team.
Refer to project page for information about installing from packages. If packages are not available for your OS, see following sections to see how you can build it from sources (or package it), or use official Docker images.
Knot-resolver is written for UNIX-like systems, mainly in C99. Portable I/O is provided by libuv. Some 64-bit systems with LuaJIT 2.1 may be affected by a problem – Linux on x86_64 is unaffected but Linux on aarch64 is.
Windows systems might theoretically work without large changes, but it’s most likely broken and currently not planned to be supported.
The following is a list of software required to build Knot Resolver from sources.
|GNU Make 3.80+||all||(build only)|
|C and C++ compiler||all||(build only) |
|pkg-config||all||(build only) |
|hexdump or xxd||
|libknot 2.7.2+||all||Knot DNS libraries - requires autotools, GnuTLS, …|
||Embedded scripting language.|
||Multiplatform I/O and services (libuv 1.0 with limitations ).|
||If missing, a static version is embedded.|
There are also optional packages that enable specific functionality in Knot Resolver, they are useful mainly for developers to build documentation and tests.
||HTTP/2 client/server for Lua.|
||Sockets for Lua.|
||TLS for Lua.|
||Unit testing framework.|
||Generating API documentation.|
|Sphinx and sphinx_rtd_theme||
||Building this HTML/PDF documentation.|
||Exposing Doxygen API doc to Sphinx.|
||Systemd socket activation support.|
||Protocol Buffers support for dnstap.|
||C bindings for Protobuf.|
||Frame Streams data transport protocol.|
||Syntax and static analysis checker for Lua.|
||Syntax and static analysis checker for C.|
||Code coverage analysis for Lua modules.|
|||Requires C99, |
|||You can use variables |
|||libuv 1.7 brings SO_REUSEPORT support that is needed for multiple forks. libuv < 1.7 can be still used, but only in single-process mode. Use different method for load balancing.|
Most of the dependencies can be resolved from packages, here’s an overview for several platforms.
- Debian (since sid) - current stable doesn’t have libknot and libuv, which must be installed from sources.
sudo apt-get install pkg-config libknot-dev libuv1-dev libcmocka-dev libluajit-5.1-dev
- Ubuntu - unknown.
# minimal build sudo dnf install @buildsys-build knot-devel libuv-devel luajit-devel # unit tests sudo dnf install libcmocka-devel # integration tests sudo dnf install cmake git python-dns python-jinja2 # optional features sudo dnf install lua-sec-compat lua-socket-compat systemd-devel # docs sudo dnf install doxygen python-breathe python-sphinx
- RHEL/CentOS - unknown.
- openSUSE - there is an experimental package.
- FreeBSD - when installing from ports, all dependencies will install automatically, corresponding to the selected options.
- NetBSD - unknown.
- OpenBSD - unknown.
- Mac OS X - the dependencies can be found through Homebrew.
brew install pkg-config libuv luajit cmocka
Building from sources¶
Initialize git submodules first.
$ git submodule update --init --recursive
$ make info # See what's missing
When you have all the dependencies ready, you can build and install.
$ make PREFIX="/usr/local" $ make install PREFIX="/usr/local"
Always build with
PREFIX if you want to install, as it is hardcoded in the executable for module search path.
Production code should be compiled with
If you build the binary with
-DNOVERBOSELOG, it won’t be possible to turn on verbose logging; we advise packagers against using that flag.
If you build with
PREFIX, you may need to also set the
LDFLAGS for the libraries:
make LDFLAGS="-Wl,-rpath=/usr/local/lib" PREFIX="/usr/local"
Alternatively you can build only specific parts of the project, i.e.
$ make lib $ make lib-install
Documentation is not built by default, run
make doc to build it.
Building with security compiler flags¶
Knot Resolver enables certain security compile-time flags that do not affect performance.
You can add more flags to the build by appending them to CFLAGS variable, e.g.
Method Status Notes -fstack-protector disabled (must be specifically enabled in CFLAGS) -D_FORTIFY_SOURCE=2 enabled -pie enabled enables ASLR for kresd (disable with
RELRO enabled full 
You can also disable linker hardening when it’s unsupported with
Building for packages¶
The build system supports DESTDIR
$ make install DESTDIR=/tmp/stage
There is a template for service file and AppArmor profile to help you kickstart the package.
The default installation follows FHS with several custom paths for configuration and modules.
All paths are prefixed with
PREFIX variable by default if not specified otherwise.
Component Variable Default Notes library
pkg-config is auto-generated  daemon
Configuration file, templates. modules
Runtime directory for loading dynamic modules . trust anchor file
(none) Path to read-only trust anchor file, which is used as fallback when no other file is specified.  work directory the current directory Run directory for daemon. (Only relevant during run time, not e.g. during installation.)
|||The default moduledir can be changed with -m option to kresd daemon or by calling moduledir() function from lua.|
|||If no other trust anchor is specified by user, the compiled-in path |
Each module is self-contained and may install additional bundled files within
$(MODULEDIR)/$(modulename). These files should be read-only, non-executable.
Static or dynamic?¶
By default the resolver library is built as a dynamic library with versioned ABI. You can revert to static build with
$ make BUILDMODE=dynamic # Default, create dynamic library $ make BUILDMODE=static # Create static library
When the library is linked statically, it usually produces a smaller binary. However linking it to various C modules might violate ODR and increase the size.
The build system relies on pkg-config to find dependencies. You can override it to force custom versions of the software by environment variables.
$ make libknot_CFLAGS="-I/opt/include" libknot_LIBS="-L/opt/lib -lknot -ldnssec"
Optional dependencies may be disabled as well using
$ make HAS_go=no HAS_cmocka=no
If the dependencies lie outside of library search path, you need to add them somehow.
LD_LIBRARY_PATH on Linux/BSD, and
DYLD_FALLBACK_LIBRARY_PATH on OS X.
Otherwise you need to add the locations to linker search path.
The project can be built with code coverage tracking using the
$ make coverage
Running unit and integration tests¶
The linter requires luacheck and clang-tidy and is executed by
The unit tests require cmocka and are executed by
Tests for the dnstap module need go and are executed by
The integration tests use Deckard, the DNS test harness.
$ make check-integration
Note that the daemon and modules must be installed first before running integration tests, the reason is that the daemon is otherwise unable to find and load modules.
Read the documentation for more information about requirements, how to run it and extend it.
Getting Docker image¶
Docker images require only either Linux or a Linux VM (see boot2docker on OS X).
$ docker run cznic/knot-resolver
See the Docker images page for more information and options. You can hack on the container by changing the container entrypoint to shell like:
$ docker run -it --entrypoint=/bin/bash cznic/knot-resolver
You can build the Docker image yourself with
docker build -t knot-resolver scripts.