2022-03-18 11:20:37 +01:00
|
|
|
.. _hooks-ddns-tuning:
|
|
|
|
|
2022-06-13 15:54:36 +00:00
|
|
|
``ddns_tuning``: DDNS Tuning
|
|
|
|
============================
|
2022-03-18 11:20:37 +01:00
|
|
|
|
2022-06-13 15:54:36 +00:00
|
|
|
This hook library adds support for fine-tuning various DNS update aspects.
|
2022-06-08 21:46:09 +00:00
|
|
|
It currently supports procedural host-name generation and the ability to skip
|
|
|
|
performing DDNS updates for select clients.
|
|
|
|
|
|
|
|
The DDNS Tuning hook library is only available to ISC customers with a paid
|
|
|
|
support contract.
|
2022-03-18 11:20:37 +01:00
|
|
|
|
2023-06-06 13:43:11 +03:00
|
|
|
The library, which was added in Kea 2.1.5, can be loaded by the :iscman:`kea-dhcp4`
|
|
|
|
and :iscman:`kea-dhcp6` daemons by adding it to the ``hooks-libraries`` element of the
|
2022-04-21 11:05:18 +03:00
|
|
|
server's configuration:
|
2022-03-18 11:20:37 +01:00
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"hooks-libraries": [
|
|
|
|
{
|
|
|
|
"library": "/usr/local/lib/libdhcp_ddns_tuning.so",
|
|
|
|
"parameters": {
|
2023-05-05 15:04:16 +03:00
|
|
|
...
|
2022-03-18 11:20:37 +01:00
|
|
|
}
|
2022-04-06 13:53:34 -04:00
|
|
|
},
|
2023-05-05 15:04:16 +03:00
|
|
|
...
|
|
|
|
],
|
|
|
|
...
|
2022-03-18 11:20:37 +01:00
|
|
|
}
|
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
Procedural Host-Name Generation
|
2022-04-06 13:53:34 -04:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2022-03-18 11:20:37 +01:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
This hook library provides the ability to generate host names procedurally, based on
|
2022-04-06 13:53:34 -04:00
|
|
|
an expression. The expression can be defined globally in the hook parameters, using
|
2022-05-11 22:05:43 +00:00
|
|
|
`hostname-expr`. If defined globally, it applies to all hosts in all subnets. The
|
2022-04-21 11:05:18 +03:00
|
|
|
expressions can use all tokens defined in :ref:`classify`. An example of a global
|
2022-04-06 13:53:34 -04:00
|
|
|
expression is shown below:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"hooks-libraries": [
|
|
|
|
{
|
|
|
|
"library": "/usr/local/lib/libdhcp_ddns_tuning.so",
|
|
|
|
"parameters": {
|
2023-05-05 15:04:16 +03:00
|
|
|
"hostname-expr": "'host-'+hexstring(pkt4.mac,'-')",
|
|
|
|
...
|
2022-04-06 13:53:34 -04:00
|
|
|
}
|
|
|
|
},
|
2023-05-05 15:04:16 +03:00
|
|
|
...
|
|
|
|
],
|
|
|
|
...
|
2022-04-06 13:53:34 -04:00
|
|
|
}
|
2022-03-18 11:20:37 +01:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
It is also possible to define this parameter in a subnet, using the user-context mechanism.
|
|
|
|
If defined at the subnet level, the expression applies to a specific subnet only. If the
|
|
|
|
subnet expression is defined as empty, ``""``, it suppresses (or disables) the use of a
|
2022-04-21 11:05:18 +03:00
|
|
|
global expression for that subnet. An example subnet expression is shown below:
|
2022-03-18 11:20:37 +01:00
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
2023-05-05 15:04:16 +03:00
|
|
|
{
|
2022-03-18 11:20:37 +01:00
|
|
|
"subnet4": [{
|
|
|
|
"subnet": "192.0.2.0/24",
|
|
|
|
"pools": [{
|
2022-09-23 14:42:03 +03:00
|
|
|
"pool": "192.0.2.10 - 192.0.2.20"
|
2022-03-18 11:20:37 +01:00
|
|
|
} ],
|
|
|
|
|
|
|
|
// This is a subnet-specific user context.
|
|
|
|
"user-context": {
|
2022-09-23 10:43:16 +00:00
|
|
|
"ddns-tuning": {
|
2023-05-08 14:47:29 +02:00
|
|
|
"hostname-expr": "'guest-'+int8totext(substring(pkt4.yiaddr, 0,1))+'-' \
|
|
|
|
+int8totext(substring(pkt4.yiaddr, 1,2))+'-' \
|
|
|
|
+int8totext(substring(pkt4.yiaddr, 2,3))+'-' \
|
|
|
|
+int8totext(substring(pkt4.yiaddr, 3,4))"
|
2022-03-28 10:37:48 -04:00
|
|
|
},
|
2022-03-18 11:20:37 +01:00
|
|
|
"last-modified": "2017-09-04 13:32",
|
|
|
|
"description": "you can put anything you like here",
|
|
|
|
"phones": [ "x1234", "x2345" ],
|
|
|
|
"devices-registered": 42,
|
|
|
|
"billing": false
|
|
|
|
}
|
2023-05-05 15:04:16 +03:00
|
|
|
}],
|
|
|
|
...
|
|
|
|
}
|
2022-03-18 11:20:37 +01:00
|
|
|
|
2022-03-28 10:37:48 -04:00
|
|
|
.. note::
|
2022-04-21 11:05:18 +03:00
|
|
|
|
|
|
|
The expression value above uses a slash, '\', to show line continuation. This is for
|
2022-05-11 22:05:43 +00:00
|
|
|
clarity only and is not valid JSON supported by Kea parsing. The actual value must
|
|
|
|
be expressed on a single line.
|
2022-03-28 10:37:48 -04:00
|
|
|
|
2022-03-18 11:20:37 +01:00
|
|
|
.. note::
|
|
|
|
|
2022-04-21 11:05:18 +03:00
|
|
|
Privacy should be taken into consideration when generating a host name. The host name
|
|
|
|
is usually inserted into the DNS, which is a public system. Exposing identifiers that
|
2022-05-11 22:05:43 +00:00
|
|
|
can be used to track devices, such as a MAC address, are usually a very bad idea.
|
|
|
|
The global expression example here used a MAC address for simplicity.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
DHCPv4 Host-Name Generation
|
2022-04-06 13:53:34 -04:00
|
|
|
---------------------------
|
|
|
|
|
2023-06-06 13:43:11 +03:00
|
|
|
With this library installed, the behavior for :iscman:`kea-dhcp4` when forming host names in
|
2022-04-06 13:53:34 -04:00
|
|
|
response to a client query (e.g. DISCOVER, REQUEST) is as follows:
|
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
1. If a host name is supplied via a host reservation, use it with the DDNS
|
|
|
|
behavioral parameters to form the final host name. Go to step 4.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
2. If the client supplied an FQDN option (option 81), use the domain name value
|
|
|
|
specified within it, with the DDNS behavioral parameters, to form the final
|
|
|
|
host name. Go to step 4.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
3. If the client supplied a host-name option (option 12), use the host name specified
|
|
|
|
within it, with the DDNS behavioral parameters, to form the final host name.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
4. If there is a ``ddns-tuning`` in-scope host-name expression (either global or subnet),
|
2022-04-21 11:05:18 +03:00
|
|
|
calculate the host name using the expression. If the calculated value is not a fully
|
2022-05-11 22:05:43 +00:00
|
|
|
qualified name and there is an in-scope ``ddns-qualifying-suffix``, append the suffix.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-04-21 11:05:18 +03:00
|
|
|
5. If the value calculated by the hook is not an empty string and is different than
|
2022-05-11 22:05:43 +00:00
|
|
|
the host name formed in steps 1 or 2, the calculated value becomes the
|
2022-04-06 13:53:34 -04:00
|
|
|
final host name.
|
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
DHCPv6 Host-Name Generation
|
2022-04-06 13:53:34 -04:00
|
|
|
---------------------------
|
|
|
|
|
2023-06-06 13:43:11 +03:00
|
|
|
With this library installed, the behavior for :iscman:`kea-dhcp6` when forming host names in
|
2022-04-06 13:53:34 -04:00
|
|
|
response to a client query (e.g. SOLICIT, REQUEST, RENEW, REBIND) is as follows:
|
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
1. If the client supplied an FQDN option (option 39), use the domain name value
|
|
|
|
specified within it, with the DDNS behavioral parameters, to form the final
|
|
|
|
host name. Go to step 4.
|
2022-04-12 11:56:46 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
2. If the client did not supply an FQDN but ``ddns-replace-client-name`` is either
|
2022-04-12 11:56:46 -04:00
|
|
|
``always`` or ``when-not-present``, then calculate the final form of the host
|
2022-05-11 22:05:43 +00:00
|
|
|
name and use it to create an outbound FQDN. Go to step 4.
|
2022-04-12 11:56:46 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
3. If there is no outbound FQDN at this point, client-name processing for this
|
2022-04-12 11:56:46 -04:00
|
|
|
packet stops. Without an outbound FQDN there is no way to communicate a host
|
|
|
|
name to the client.
|
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
4. If a host name is supplied via a host reservation, use it along with the DDNS
|
|
|
|
behavioral parameters to form the final host name; it supersedes the FQDN value
|
2022-04-12 11:56:46 -04:00
|
|
|
calculated in steps 1 or 2.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
5. If there is a ``ddns-tuning`` in-scope host name expression (either global or subnet),
|
2022-04-21 11:05:18 +03:00
|
|
|
calculate the host name using the expression. If the calculated value is not a fully
|
2022-05-11 22:05:43 +00:00
|
|
|
qualified name and there is an in-scope ``ddns-qualifying-suffix``, append the suffix.
|
2022-04-06 13:53:34 -04:00
|
|
|
|
2022-04-21 11:05:18 +03:00
|
|
|
6. If the value calculated by the hook is not an empty string and is different than
|
2022-05-11 22:05:43 +00:00
|
|
|
the host name formed in steps 1 or 2, the calculated value becomes the
|
2022-04-06 13:53:34 -04:00
|
|
|
final host name.
|
2022-05-11 10:14:56 -04:00
|
|
|
|
2022-05-11 22:05:43 +00:00
|
|
|
|
2022-05-11 10:14:56 -04:00
|
|
|
Skipping DDNS Updates
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2022-06-08 18:49:39 +00:00
|
|
|
The ``ddns-tuning`` library also provides the ability to skip DDNS updates on a
|
|
|
|
per-client basis. The library recognizes a special client class, "SKIP_DDNS"; when a
|
2023-06-06 13:43:11 +03:00
|
|
|
client is matched to this class, the Kea servers (:iscman:`kea-dhcp4` and :iscman:`kea-dhcp6`) do not
|
|
|
|
send DDNS update requests (NCRs) to :iscman:`kea-dhcp-ddns`. A common use case would be
|
2022-06-08 18:49:39 +00:00
|
|
|
to skip DDNS updates for fixed-address host reservations. This is done easily by
|
2022-05-23 17:16:29 +03:00
|
|
|
simply assigning the class to the host reservation as shown below:
|
2022-05-11 10:14:56 -04:00
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"reservations": [
|
|
|
|
{
|
|
|
|
"hw-address": "01:02:03:04:05:06",
|
|
|
|
"ip-address": "192.0.2.1",
|
|
|
|
"client-classes": [ "SKIP_DDNS", "foo", "bar" ]
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
<<<<<<< HEAD
|
2022-06-08 18:50:18 +00:00
|
|
|
The ``ddns-tuning`` library notes the presence of the "SKIP_DDNS" class in the
|
2023-06-06 13:43:28 +03:00
|
|
|
||||||| parent of 0e20e5ed8c (isccmd)
|
|
|
|
:ischooklib:`libdhcp_ddns_tuning.so` notes the presence of the ``"SKIP_DDNS"`` class in the
|
|
|
|
=======
|
|
|
|
The :ischooklib:`libdhcp_ddns_tuning.so` hook library notes the presence of the ``"SKIP_DDNS"`` class in the
|
|
|
|
>>>>>>> 0e20e5ed8c (isccmd)
|
2022-05-11 10:14:56 -04:00
|
|
|
client's class list each time the client requests, renews, or releases its lease,
|
2023-06-06 13:43:11 +03:00
|
|
|
and instructs :iscman:`kea-dhcp4` to bypass sending DDNS updates. A similar workflow is
|
|
|
|
supported for :iscman:`kea-dhcp6`:
|
2022-05-11 10:14:56 -04:00
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"reservations": [
|
|
|
|
{
|
|
|
|
"duid": "01:02:03:04:05:06",
|
|
|
|
"ip-address": "2001:db8::1",
|
|
|
|
"client-classes": [ "SKIP_DDNS", "foo", "bar" ]
|
|
|
|
}]
|
|
|
|
}
|
2022-05-19 13:38:10 -04:00
|
|
|
|
2022-06-08 18:50:34 +00:00
|
|
|
Although "SKIP_DDNS" is a special class, it can be defined with a test
|
|
|
|
expression. Defining it as shown below would omit DDNS updates for all KNOWN
|
2022-05-19 14:49:45 -04:00
|
|
|
clients:
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
{
|
|
|
|
"client-classes":[
|
|
|
|
{
|
|
|
|
"name": "SKIP_DDNS",
|
|
|
|
"test": "member('KNOWN')"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
2022-05-19 13:38:10 -04:00
|
|
|
.. note::
|
|
|
|
|
2023-06-06 13:43:28 +03:00
|
|
|
The :ischooklib:`libdhcp_ddns_tuning.so` hook library must be
|
|
|
|
loaded for the ``"SKIP_DDNS"`` class to have an effect.
|