mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[master] Merging trac5374 (new classification) - conflicts resolved, regen needed
This commit is contained in:
150
doc/examples/kea4/classify2.json
Normal file
150
doc/examples/kea4/classify2.json
Normal file
@@ -0,0 +1,150 @@
|
||||
// This is an example configuration file for the DHCPv4 server in Kea.
|
||||
// The purpose of this example is to showcase how clients can be classified
|
||||
// with advanced features.
|
||||
|
||||
{ "Dhcp4": {
|
||||
|
||||
// Kea is told to listen on ethX interface only.
|
||||
"interfaces-config": {
|
||||
"interfaces": [ "ethX" ]
|
||||
},
|
||||
|
||||
// Let's use the simplest backend: memfile and use some reasonable values
|
||||
// for timers. They are of no concern for the classification demonstration.
|
||||
"lease-database": { "type": "memfile" },
|
||||
"renew-timer": 1000,
|
||||
"rebind-timer": 2000,
|
||||
"valid-lifetime": 4000,
|
||||
|
||||
// This list defines several classes that incoming packets can be assigned to.
|
||||
// One packet can belong to zero or more classes.
|
||||
"client-classes": [
|
||||
|
||||
// This class is required by the second subnet and is evaluated only
|
||||
// if it is required. The test expression returns true.
|
||||
// Note it is not possible to depend on VoIP class because it is not yet
|
||||
// defined.
|
||||
{
|
||||
"name": "second_subnet",
|
||||
"only-if-required": true,
|
||||
"test": "member('ALL')",
|
||||
"option-data": [{
|
||||
"name": "domain-name-servers",
|
||||
"data": "127.0.0.1"
|
||||
}]
|
||||
},
|
||||
|
||||
// Let's classify all incoming DISCOVER (message type 1) to a separate
|
||||
// class.
|
||||
{
|
||||
"name": "discovers",
|
||||
"test": "pkt4.msgtype == 1"
|
||||
},
|
||||
|
||||
// Clients are supposed to set the transaction-id field to a random value.
|
||||
// Clients that send it with 0 are most likely broken. Let's mark them
|
||||
// as such.
|
||||
{
|
||||
"name": "broken",
|
||||
"test": "pkt4.transid == 0"
|
||||
},
|
||||
|
||||
// Let's pick VoIP phones. Those that send their class identifiers
|
||||
// as Aastra, should belong to VoIP class. For a list of all options,
|
||||
// see www.iana.org/assignments/bootp-dhcp-parameters/.
|
||||
// In this particular class, we want to set specific values
|
||||
// of certain DHCPv4 fields. If the incoming packet matches the
|
||||
// test, those fields will be set in outgoing responses.
|
||||
// The option 43 is defined to encapsulate suboption in the aastra space.
|
||||
{
|
||||
"name": "VoIP",
|
||||
"test": "substring(option[60].hex,0,6) == 'Aastra'",
|
||||
"next-server": "192.0.2.254",
|
||||
"server-hostname": "hal9000",
|
||||
"boot-file-name": "/dev/null",
|
||||
"option-def": [ {
|
||||
"name": "vendor-encapsulated-options",
|
||||
"code": 43,
|
||||
"type": "empty",
|
||||
"encapsulate": "aastra" } ]
|
||||
},
|
||||
|
||||
// Both a VoIP phone (by evaluation or host reservation) and has a host
|
||||
// reservation.
|
||||
{
|
||||
"name": "VoIP_host",
|
||||
"test": "member('VoIP') and member('KNOWN')",
|
||||
"server-hostname": "hal9001"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
// The following list defines subnets. For some subnets we defined
|
||||
// a class that is allowed in that subnet. If not specified,
|
||||
// everyone is allowed. When a class is specified, only packets belonging
|
||||
// to that class are allowed for that subnet.
|
||||
"subnet4": [
|
||||
{
|
||||
// This one is for VoIP devices only.
|
||||
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
|
||||
"subnet": "192.0.2.0/24",
|
||||
"client-class": "VoIP",
|
||||
"interface": "ethX"
|
||||
},
|
||||
// This one doesn't have any client-class specified, so everyone
|
||||
// is allowed in. The normal subnet selection rules still apply,
|
||||
// though. There is also a static class reservation for a client
|
||||
// using MAC address 1a:1b:1c:1d:1e:1f. This client will always
|
||||
// be assigned to this class.
|
||||
{
|
||||
"pools": [ { "pool": "192.0.3.1 - 192.0.3.200" } ],
|
||||
"subnet": "192.0.3.0/24",
|
||||
"reservations": [
|
||||
{
|
||||
"hw-address": "1a:1b:1c:1d:1e:1f",
|
||||
"client-classes": [ "VoIP" ]
|
||||
} ],
|
||||
"interface": "ethX",
|
||||
"require-client-classes": [ "second_subnet" ]
|
||||
},
|
||||
|
||||
// The following list defines a subnet with pools. For some pools
|
||||
// we defined a class that is allowed in that pool. If not specified
|
||||
// everyone is allowed. When a class is specified, only packets belonging
|
||||
// to that class are allowed for that pool.
|
||||
{
|
||||
"pools": [
|
||||
{
|
||||
// This one is for VoIP devices only.
|
||||
"pool": "192.0.4.1 - 192.0.4.200",
|
||||
"client-class": "VoIP"
|
||||
},
|
||||
// This one doesn't have any client-class specified, so everyone
|
||||
// is allowed in.
|
||||
{
|
||||
"pool": "192.0.5.1 - 192.0.5.200"
|
||||
} ],
|
||||
"subnet": "192.0.4.0/23",
|
||||
"interface": "ethY"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// The following configures logging. It assumes that messages with at
|
||||
// least informational level (info, warn, error and fatal) should be
|
||||
// logged to stdout.
|
||||
"Logging": {
|
||||
"loggers": [
|
||||
{
|
||||
"name": "kea-dhcp4",
|
||||
"output_options": [
|
||||
{
|
||||
"output": "stdout"
|
||||
}
|
||||
],
|
||||
"severity": "INFO"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
// This is an example configuration file for the DHCPv4 server in Kea.
|
||||
// This is an example configuration file for the DHCPv6 server in Kea.
|
||||
// The purpose of this example is to showcase how clients can be classified.
|
||||
|
||||
{ "Dhcp6":
|
||||
|
122
doc/examples/kea6/classify2.json
Normal file
122
doc/examples/kea6/classify2.json
Normal file
@@ -0,0 +1,122 @@
|
||||
// This is an example configuration file for the DHCPv6 server in Kea.
|
||||
// The purpose of this example is to showcase how clients can be classified.
|
||||
|
||||
{ "Dhcp6":
|
||||
|
||||
{
|
||||
// Kea is told to listen on ethX interface only.
|
||||
"interfaces-config": {
|
||||
"interfaces": [ "ethX" ]
|
||||
},
|
||||
|
||||
// Let's use the simplest backend: memfile and use some reasonable values
|
||||
// for timers. They are of no concern for the classification demonstration.
|
||||
"lease-database": {
|
||||
"type": "memfile",
|
||||
"lfc-interval": 3600
|
||||
},
|
||||
"renew-timer": 1000,
|
||||
"rebind-timer": 2000,
|
||||
"preferred-lifetime": 3000,
|
||||
"valid-lifetime": 4000,
|
||||
|
||||
// This list defines several classes that incoming packets can be assigned to.
|
||||
// One packet can belong to zero or more classes.
|
||||
"client-classes": [
|
||||
|
||||
// This class is required by the second subnet and is evaluated only
|
||||
// if it is required. The test expression returns true.
|
||||
// Note it is not possible to depend on cable-modems class because it
|
||||
// is not yet defined.
|
||||
{
|
||||
"name": "second_subnet",
|
||||
"only-if-required": true,
|
||||
"test": "member('ALL')",
|
||||
"option-data": [{
|
||||
"name": "dns-servers",
|
||||
"data": "2001:db8::1"
|
||||
}]
|
||||
},
|
||||
|
||||
// Let's classify all incoming RENEW (message type 5) to a separate
|
||||
// class.
|
||||
{
|
||||
"name": "renews",
|
||||
"test": "pkt6.msgtype == 5"
|
||||
},
|
||||
|
||||
// Let's pick cable modems. In this simple example we'll assume the device
|
||||
// is a cable modem if it sends a vendor option with enterprise-id equal
|
||||
// to 4491.
|
||||
{
|
||||
"name": "cable-modems",
|
||||
"test": "vendor.enterprise == 4491"
|
||||
},
|
||||
|
||||
// Both a cable modem (by evaluation or host reservation) and has a host
|
||||
// reservation.
|
||||
{
|
||||
"name": "cable-modem-hosts",
|
||||
"test": "member('cable-modems') and member('KNOWN')"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
|
||||
// The following list defines subnets. Each subnet consists of at
|
||||
// least subnet and pool entries.
|
||||
"subnet6": [
|
||||
{
|
||||
"pools": [ { "pool": "2001:db8:1::/80" } ],
|
||||
"subnet": "2001:db8:1::/64",
|
||||
"client-class": "cable-modems",
|
||||
"interface": "ethX"
|
||||
},
|
||||
// The following subnet contains a class reservation for a client using
|
||||
// DUID 01:02:03:04:05:0A:0B:0C:0D:0E. This client will always be assigned
|
||||
// to this class.
|
||||
{
|
||||
"pools": [ { "pool": "2001:db8:2::/80" } ],
|
||||
"subnet": "2001:db8:2::/64",
|
||||
"reservations": [
|
||||
{
|
||||
"duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
|
||||
"client-classes": [ "cable-modems" ]
|
||||
} ],
|
||||
"interface": "ethX",
|
||||
"require-client-classes": [ "second_subnet" ]
|
||||
},
|
||||
// The following subnet contains a pool with a class constraint: only
|
||||
// clients which belong to the class are allowed to use this pool.
|
||||
{
|
||||
"pools": [
|
||||
{
|
||||
"pool": "2001:db8:3::/80",
|
||||
"client-class": "cable-modems"
|
||||
} ],
|
||||
"subnet": "2001:db8:4::/64",
|
||||
"interface": "ethY"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
// The following configures logging. It assumes that messages with at
|
||||
// least informational level (info, warn, error and fatal) should be
|
||||
// logged to stdout.
|
||||
"Logging": {
|
||||
"loggers": [
|
||||
{
|
||||
"name": "kea-dhcp6",
|
||||
"output_options": [
|
||||
{
|
||||
"output": "stdout"
|
||||
}
|
||||
],
|
||||
"debuglevel": 0,
|
||||
"severity": "INFO"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user