``myhost-172-16-1-10.example.com.``
+.. note::
+
+ When the client sends the host name option, ``kea-dhcp4`` never adds a dot to
+ the returned host name. It will only end with a dot if the client sent it
+ already qualified and ending with a dot. When the client sends the FQDN option,
+ the FQDN returned in the response will always end with a dot.
+
.. _dhcp4-host-name-sanitization:
Sanitizing Client Host Name and FQDN Names
...
}
+The default behavior of :iscman:`kea-dhcp4` is to prefer the FQDN option (code 81) over the
+host name option (code 12) when a client sends both. The following example shows
+the ``hostname-expr`` one would use to reverse this rule:
+
+.. code-block:: javascript
+
+ {
+ "hooks-libraries": [
+ {
+ "library": "/usr/local/lib/libdhcp_ddns_tuning.so",
+ "parameters": {
+ "hostname-expr" : "ifelse(option[12].exists, option[host-name].text, option[81].text)"
+ }
+ },
+ ],
+ }
+
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
"pool": "192.0.2.10 - 192.0.2.20"
} ],
- // This is a subnet-specific user context.
"user-context": {
"ddns-tuning": {
"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))"
- },
- "last-modified": "2017-09-04 13:32",
- "description": "you can put anything you like here",
- "phones": [ "x1234", "x2345" ],
- "devices-registered": 42,
- "billing": false
+ }
}
}],
...