[![Coverity Status](https://img.shields.io/coverity/scan/knot-dns.svg)](https://scan.coverity.com/projects/knot-dns)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/knot-dns.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:knot-dns)

# Requirements

[doc/requirements.rst](doc/requirements.rst)

# Installation

[doc/installation.rst](doc/installation.rst)

## 1. Install prerequisites

### Debian based distributions

#### Update the system:
```bash
sudo apt-get update
sudo apt-get upgrade
```

#### Install prerequisites:
```bash
sudo apt-get install \
  libtool autoconf automake make pkg-config liburcu-dev libgnutls28-dev libedit-dev liblmdb-dev
```

#### Install optional packages:
```bash
sudo apt-get install \
  libcap-ng-dev libsystemd-dev libidn2-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler libfstrm-dev libmaxminddb-dev libnghttp2-dev libbpf-dev libxdp-dev libmnl-dev python3-sphinx python3-sphinx-panels softhsm2
```

### Fedora like distributions

#### Update the system:
```bash
dnf upgrade
```

#### Install basic development tools:
```bash
dnf install @buildsys-build
```

#### Install prerequisites:
```bash
dnf install \
  libtool autoconf automake pkgconfig userspace-rcu-devel gnutls-devel libedit-devel lmdb-devel
```

#### Install optional packages:
```bash
dnf install \
  libcap-ng-devel systemd-devel libidn2-devel protobuf-c-devel fstrm-devel libmaxminddb-devel libnghttp2-devel libbpf-devel libxdp-devel libmnl-devel python-sphinx python-sphinx-panels softhsm
```

When compiling on RHEL based system, the Fedora EPEL repository has to be
enabled.

## 2. Install Knot DNS

Get the source code:
```bash
git clone https://gitlab.nic.cz/knot/knot-dns.git
```
Or extract source package to knot-dns directory.

Compile the source code:
```bash
cd knot-dns
autoreconf -if
./configure
make
```

Note that `./configure` accepts various parameters (see `./configure --help`).
The following examples assume `--sysconfdir=/etc` and `--localstatedir=/var/lib`.

Install Knot DNS into system:
```bash
sudo make install
sudo ldconfig
```

# Running

### 1. Ensure some configuration

[doc/configuration.rst](doc/configuration.rst)

Please see [samples/knot.sample.conf](samples/knot.sample.conf),
[project documentation](https://www.knot-dns.cz/documentation/),
or `man 5 knot.conf` for more details. Basically the configuration should specify:
- network interfaces
- served zones

E.g. use the default configuration file:
```bash
cd /etc/knot
mv knot.sample.conf knot.conf
```
Modify the configuration file:
```bash
editor knot.conf
```

### 2. Prepare working directory

```bash
mv example.com.zone /var/lib/knot/
```

### 3. Start the server

[doc/operation.rst](doc/operation.rst)

This can be done by running the `knotd` command. Alternatively, your distribution
should have an init script available, if you installed Knot DNS from a binary package.

Start the server in foreground to see if it runs:
```bash
knotd -c /etc/knot/knot.conf
```
