// This is an example configuration file for the DHCPv4 server in Kea.
// It demonstrates how to enable Kea Configuration Backend using MySQL.
// It requires that libdhcp_mysql_cb.so library is available and
// optionally libdhcp_cb_cmds.so hook library.

{ "Dhcp4":

{
    // Set the server tag for the configuration backend. This instance will
    // be named server1. Every configuration element that is applicable to
    // either "all" or "server1" will be used by this instance.
    "server-tag": "server1",

    // Kea is told to listen on eth0 interface only.
    "interfaces-config": {
        "interfaces": [ "eth0" ]
    },

    // Use memfile lease database backend.
    "lease-database": {
        "type": "memfile",
        "lfc-interval": 3600
    },

    // This parameter controls how the server accesses the configuration
    // database. Currently only one database type is available - "mysql".
    // It requires that the libdhcp_mysql_cb.so hook library is loaded.
    "config-control": {
        // A list of database backends to connect to. Currently, it is limited
        // to a single backend.
        "config-databases": [
            {
                "type": "mysql",
                "reconnect-wait-time": 3000, // expressed in ms
                "max-reconnect-tries": 3,
                "name": "kea",
                "user": "kea",
                "password": "kea",
                "host": "localhost",
                "port": 3306
            }
        ],
        // Controls how often the server polls the database for the
        // configuration updates. The setting below implies that it
        // will take up to approx. 20 seconds for the server to
        // discover and fetch configuration changes.
        "config-fetch-wait-time": 20
    },

    // This defines a control socket. If defined, Kea will open a UNIX socket
    // and will listen for incoming commands. See section 17 of the Kea ARM for
    // details.
    "control-socket": {
        "socket-type": "unix",
        "socket-name": "/tmp/kea4-ctrl-socket"
    },

    // Hooks libraries that enable configuration backend are loaded.
    "hooks-libraries": [
        // The libdhcp_mysql_cb.so is required to use MySQL Configuration
        // Backend.
        {
            "library": "/usr/local/lib/kea/hooks/libdhcp_mysql_cb.so"
        }
        // The libdhcp_cb_cmds.so is optional. It allows for managing the
        // configuration in the database. If this library is not loaded,
        // the configuration can be managed directly using available
        // tools that work directly with the MySQL database.
        // ,{
        //     "library": "/usr/local/lib/kea/hooks/libdhcp_cb_cmds.so"
        // }
    ],

    // The following configures logging. It assumes that messages with at
    // least informational level (info, warn, error and fatal) should be
    // logged to stdout. Alternatively, you can specify stderr here, a filename
    // or 'syslog', which will store output messages via syslog.
    "loggers": [
        {
            "name": "kea-dhcp4",
            "output_options": [
                {
                    "output": "stdout"
                }
            ],
            "severity": "INFO"
        }
    ]
}

}
