multiple-options.json 6.97 KB
Newer Older
1 2
// This is an example configuration file for the DHCPv4 server in Kea.
// It demonstrates simple configuration of the options for a subnet.
3 4 5 6

{ "Dhcp4":

{
7
// Kea is told to listen on ethX interface only.
8
  "interfaces-config": {
9 10
    "interfaces": [ "ethX" ]
  },
11

12 13 14 15
// We need to specify the the database used to store leases. As of
// September 2016, four database backends are supported: MySQL,
// PostgreSQL, Cassandra, and the in-memory database, Memfile.
// We'll use memfile  because it doesn't require any prior set up.
16 17 18 19
  "lease-database": {
    "type": "memfile"
  },

20
// Addresses will be assigned with a lifetime of 4000 seconds.
21 22
  "valid-lifetime": 4000,

23 24 25 26 27 28
// Renew and rebind timers are commented out. This implies that options
// 58 and 59 will not be sent to the client. In this case it is up to
// the client to pick the timer values according to RFC2131. Uncomment the
// timers to send these options to the client.
//  "renew-timer": 1000,
//  "rebind-timer": 2000,
29

30
// Defining a subnet. There are some DHCP options returned to the
31
// clients connected to this subnet. The first and third options are
32
// clients connected to this subnet. The first two options are
33 34
// identified by the name. The third option is identified by the
// option code.
35 36 37
// There is an address pool defined within this subnet. Pool
// specific value for option domain-name-servers is defined
// for the pool.
38 39 40
  "subnet4": [
    {
       "subnet": "192.0.2.0/24",
Tomek Mrugalski's avatar
Tomek Mrugalski committed
41
       "interface": "ethX",
42
       "option-data": [
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
            // When specifying options, you typically need to specify
            // one of (name or code) and data. The full option specification
            // covers name, code, space, csv-format and data.
            // space defaults to "dhcp4" which is usually correct, unless you
            // use encapsulate options. csv-format defaults to "true", so
            // this is also correct, unless you want to specify the whole
            // option value as long hex string. For example, to specify
            // domain-name-servers you could do this:
            // {
            //     "name": "domain-name-servers",
            //     "code": 6,
            //     "csv-format": "true",
            //     "space": "dhcp4",
            //     "data": "192.0.2.1, 192.0.2.2"
            // }
            // but it's a lot of writing, so it's easier to do this instead:
59 60 61 62
         {
             "name": "domain-name-servers",
             "data": "192.0.2.1, 192.0.2.2"
         },
63 64
            // Note the Kea provides some of the options on its own. In
            // particular:
65 66 67 68

            // - IP address lease time (option 51) is governed by
            //   valid-lifetime parameter, so you don't need to specify
            //   it as option.
69 70 71 72 73 74 75 76 77
            // - Subnet mask (option 1) is calculated automatically from the
            //   subnet parameter specified for each "subnet4" entry.
            // - renewal-timer (option 58) is calculated from renew-timer
            //   parameter
            // - rebind timer (option 59) is calculated from rebind-timer
            //   parameter

            // For each IPv4 subnet you most likely need to specify at least
            // one router.
78 79 80 81
         {
             "name": "routers",
             "data": "192.0.2.1"
         },
82 83 84 85 86 87

            // Typically people prefer to refer to options by their
            // names, so they don't need to remember the code names.
            // However, some people like to use numerical values. For
            // example, option "domain-name" uses option code 15, so you
            // can reference to it either by
88
            // "name": "domain-name" or "code": 15.
89 90 91
         {
             "code": 15,
             "data": "example.org"
Tomek Mrugalski's avatar
Tomek Mrugalski committed
92 93 94 95
         },
             // Domain search is also a popular option. It tells the client to
             // attempt to resolve names within those specificed domains. For
             // example, name "foo" would be attempted to be resolved as
96 97 98
             // foo.mydomain.example.com and if it fails, then as
             // foo.example.com

Tomek Mrugalski's avatar
Tomek Mrugalski committed
99 100 101
         {
             "name": "domain-search",
             "data": "mydomain.example.com, example.com"
102 103
         },
            // String options that have a comma in their values need to have
Josh Soref's avatar
Josh Soref committed
104
            // it escaped (i.e. each comma is preceded by two backslashes).
105 106 107 108 109 110 111 112 113 114 115 116
            // That's because commas are reserved for separating fields in
            // compound options. At the same time, we need to be conformant
            // with JSON spec, that does not allow "\,". Therefore the
            // slightly uncommon double backslashes notation is needed.

            // Legal JSON escapes are \ followed by "\/bfnrt character
            // or \u followed by 4 hexa-decimal numbers (currently Kea
            // supports only \u0000 to \u00ff code points).
            // CSV processing translates '\\' into '\' and '\,' into ','
            // only so for instance '\x' is translated into '\x'. But
            // as it works on a JSON string value each of these '\'
            // characters must be doubled on JSON input.
117
         {
118 119
            "name": "boot-file-name",
            "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
120

121
         },
122 123 124
            // Options that take integer values can either be specified in
            // dec or hex format. Hex format could be either plain (e.g. abcd)
            // or prefixed with 0x (e.g. 0xabcd).
125 126 127
         {
            "name": "default-ip-ttl",
            "data": "0xf0"
128 129
         },
            // At a few exceptions options are added to response only when
130
            // the client requests them. The always-send flag should be used
131 132 133 134
            // to enforce a particular option.
         {
            "name": "vendor-class-identifier",
            "data": "isc",
135
            "always-send": true
136
         }
137
       ],
138 139 140 141 142 143 144

        // Now we define pools. There are two pools here.
        "pools": [ {
            // This is the first pool. Nothing spectacular here, just a range
            // of addresses.
           "pool": "192.0.2.10 - 192.0.2.100"

Francis Dupont's avatar
Francis Dupont committed
145
          }, {
146 147 148 149 150 151 152 153 154 155 156
            // This second pool is more interesting. Anyone who gets an
            // address from this pool will also get this specific option
            // value if asks for DNS servers configuration. This value,
            // being more specific, overrides any values that were specified
            // on either global or subnet scope.
            "pool":  "192.0.2.101 - 192.0.2.200",
            "option-data": [
                {
                    "name": "domain-name-servers",
                    "data": "192.0.2.3, 192.0.2.4"
                }
Francis Dupont's avatar
Francis Dupont committed
157
          ]
158
        } ]
159
    } ]
160 161
},

162 163 164
// The following configures logging. It assumes that messages with at
// least informational level (info, warn, error and fatal) should be
// logged to stdout.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
"Logging": {
    "loggers": [
        {
            "name": "kea-dhcp4",
            "output_options": [
                {
                    "output": "stdout"
                }
            ],
            "severity": "INFO"
        }
    ]
}

}