@node Running Knot DNS, Troubleshooting, Knot DNS Configuration, Top @chapter Running Knot DNS @menu * Running a slave server:: * Running a master server:: * Controlling running daemon:: @end menu Knot DNS is designed to compile zone files before loading them into server. The reason for this is to speed up server startup, but requires a bit of user effort, so each time the zone file changes you need to compile it. @example $ knotc -c knot.conf compile @end example Or alternatively, you can compile automatically using the @code{-a} flag. @example $ knotc -a -c knot.conf start|reload|restart @end example The tool @code{knotc} is designed as a front-end for user, making it easier to do everything from zone compilation to controlling the server daemon. To communicate with the binary, it reads the PID from the @emph{PID file} specified in the configuration @code{pidfile} and sends POSIX signals to it (@pxref{pidfile}). If you want to control the daemon directly, use @code{SIGINT} to quit the process or @code{SIGHUP} to reload configuration. Signal @code{SIGUSR2} is currently used to refresh slave zones. @example Usage: knotc [parameters] start|stop|restart|reload|running|compile Parameters: -c [file], --config=[file] Select configuration file. -j [num], --jobs=[num] Number of parallel tasks to run when compiling. -f, --force Force operation - override some checks. -v, --verbose Verbose mode - additional runtime information. -V, --version Print knot server version. -w, --wait Wait for the server to finish start/stop operations. -i, --interactive Interactive mode (do not daemonize). -a, --auto Enable automatic recompilation (start or reload). -h, --help Print help and usage. Actions: start Start knot server zone (no-op if running). stop Stop knot server (no-op if not running). restart Stops and then starts knot server. reload Reload knot configuration and compiled zones. refresh Refresh all slave zones. running Check if server is running. checkconf Check server configuration. checkzone Check zones (accepts specific zones, e.g. 'knotc checkzone example1.com example2.com'). compile Compile zones (accepts specific zones, see above). @end example If you want to run Knot DNS daemon directly, you can use @code{knotd} binary to do that. It accepts just configuration file and option to run in background. @example Usage: knotd [parameters] Parameters: -c, --config [file] Select configuration file. -d, --daemonize Run server as a daemon. -v, --verbose Verbose mode - additional runtime information. -V, --version Print version of the server. -h, --help Print help and usage. @end example Also, the server needs to create several files in order to run properly. All files are placed in the directory described by @code{storage} (@pxref{storage}). PID file can be placed elsewhere using the @code{pidfile} statement (@pxref{pidfile}). Slave zones with relative path specified will be placed in the @code{storage} as well. @itemize @bullet @item @emph{Compiled zones} - preprocessed zones, for example zone @code{example.com} will be placed in @file{STORAGE/example.com.db}. @item @emph{Journal files} - each zone has a journal file to store differences for IXFR and dynamic updates. Journal for zone @code{example.com} will be placed in @file{STORAGE/example.com.diff.db}. @item @emph{PID file} - unless specified differently by the @code{pidfile}, it will be placed in the @file{STORAGE/knot.pid}. @item @emph{Checksum files} - in order to identify compiled zone corruption, it has a separate checksum file. For @code{example.com} will be placed in @file{STORAGE/example.com.db.crc}. @end itemize @node Running a slave server @section Running a slave server Running the server as a slave is very straightforward as you usually bootstrap zones over AXFR and thus avoid any manual zone compilation. When a zone is transferred over AXFR, both the compiled zone and the zone file is updated, so no further compilation is needed. However when IXFR transfer finishes, it stores the differences in a journal file and doesn't update the zone file nor compiled zone immediately, but there is a timer that checks periodically for new differences and updates both zone file and the compiled zone. You can configure this timer with the @code{zonefile-sync} statement in @code{zones} (@pxref{zones}). There are two ways to start the server - directly or with the @code{knotc} controller tool. First, let us start it directly. If you do not pass any configuration, it will try to search configuration in default path that is @code{SYSCONFDIR/knot.conf}. The @code{SYSCONFDIR} depends on what you passed to the @code{./configure}, usually @code{/etc}. @example $ knotc -c slave.conf checkconf # check configuration $ knotd -c slave.conf @end example However to start it as a daemon, @code{knotc} tool should be used. The @code{knotc} tool accepts parameter @code{-w} to wait until the requested operation finishes. When the action is "start" for example, it waits until the server starts to serve zones. @example $ knotc -w -c slave.conf start # start the daemon $ knotc -c slave.conf stop # stop the daemon @end example When the server is running, you can control the daemon, see @ref{Controlling running daemon}. @node Running a master server @section Running a master server Knot DNS first needs to compile the zones before it can load them, therefore you need to compile them with the @code{knotc compile} action or use flag @code{-a} to compile the zones automatically. If you want to just check the zone files first before starting, you can use @code{knotc checkzone} action. @example $ knotc -c master.conf checkzone example.com @end example Starting and stopping the daemon is the same as with the slave server in the previous section. @example $ knotc -c master.conf compile $ knotc -w -c master.conf start @end example Or you can compile it automatically: @example $ knotc -c master.conf checkconf # check configuration $ knotc -a -w -c master.conf start @end example @node Controlling running daemon @section Controlling running daemon Knot DNS was designed to allow server reconfiguration on-the-fly without interrupting its operation. Thus it is possible to change both configuration and zone files and also add or remove zones without restarting the server. This can be done with the @code{knotc reload} action. @example $ knotc -c master.conf compile # compile updated zones $ knotc -c master.conf reload # reconfigure and load updated zones @end example Or use the @code{-a} again. @example $ knotc -a -c master.conf reload # compile zones and reconfigure @end example If you want @emph{IXFR-out} differences created from changes you make to a zone file, enable @code{ixfr-from-differences} in @code{zones} statement, then compile the zone and reload your server as seen above. If @emph{SOA}'s @emph{serial} is not changed no differences will be created. Please note that this feature is in @emph{experimental} stage and should be used with care. If you encounter a bug using this feature, please send it to Knot developers (@pxref{Submitting a bugreport}). You can also choose to tear-down the server fully and restart with the @code{knotc restart} action. @example $ knotc -c master.conf running # check if running $ knotc -c master.conf restart # fully restart @end example If you want to force refresh the slave zones, you can do this with the @code{knotc refresh} action. @example $ knotc -c slave.conf refresh @end example For a complete list of actions refer to @code{knotc --help} command output.