3.8. Classifying clients in Kea


Kea client classes provide a mechanism for grouping clients based on specific criteria, allowing for granular control over network configuration. You can use this feature to apply special processing rules or assign different DHCP options to clients.

You can create a client class that assigns Voice over IP (VoIP) devices to a specific IP pool to ensures that VoIP phones get different IP addresses than other devices on the network. For example, in IPv4 networks, you can use a substring expression to test for the first 3 octets of their media access control (MAC) address. In IPv6 networks where the MAC address is not a reliable indicator, you can test for a substring of the DHCPv6 vendor class option.

Prerequisites

  • The kea-dhcp4 and kea-dhcp6 services are configured and running.
  • You are logged in as the root user.

Procedure

  1. If you are configuring an IPv4 network:

    1. Edit the /etc/kea/kea-dhcp4.conf file, and make the following changes:

      1. Add the following client classes to the Dhcp4 parameter:

        {
          "Dhcp4": {
            ...
            "client-classes": [
              {
                  "name": "VoIP-Phones",
                  "test": "substring(pkt4.mac, 0, 3) == 0x525400"
              },
              {
                  "name": "Others",
                  "test": "not member('VoIP-Phones')"
              }
            ],
            ...

        In this example, devices with a MAC address starting with 52:54:00 match the VoIP-Phones client class. Devices that do not match the rule are assigned to the Others client class.

      2. Assign the client classes to your pool definitions:

        {
          "Dhcp4": {
            "subnet4": [
              {
                "subnet": "192.0.2.0/24",
        	"pools": [
                  {
                    "pool": "192.0.2.20  - 192.0.2.100",
                    "client-class": "Others"
                  },
                  {
                    "pool": "192.0.2.150 - 192.0.2.200",
                    "client-class": "VoIP-Phones"
                  }
                ],
                ...

        Depending on which client class a host matches, Kea assigns an IP from the corresponding pool.

    2. Verify the syntax of the configuration file:

      # kea-dhcp4 -t /etc/kea/kea-dhcp4.conf

      If the command returns Syntax check failed, fix the errors shown in the report.

    3. Restart the kea-dhcp4 service:

      # systemctl restart kea-dhcp4
  2. If you are configuring an IPv6 network:

    1. Edit the /etc/kea/kea-dhcp6.conf file, and make the following changes:

      1. Add the following client classes to the Dhcp6 parameter:

        {
          "Dhcp6": {
            ...
            "client-classes": [
              {
                  "name": "VoIP-Phones",
                  "test": "option[16].exists and (substring(option[16].hex, 0, 8) == '00000009')",
              },
              {
                  "name": "Others",
                  "test": "not member('VoIP-Phones')"
              }
            ],
            ...

        In this example, devices that send a DHCPv6 vendor class option (option 16) where the hexadecimal value begins with 00000009 match the VoIP-Phones client class. Devices that do not match the rule are assigned to the Others client class.

      2. Assign the client classes to your pool definitions:

        {
          "Dhcp6": {
            "subnet6": [
              {
                "subnet": "2001:db8:0:1::/64",
        	"pools": [
                  {
                    "pool": "2001:db8:0:1::1000 - 2001:db8:0:1::2000",
                    "client-class": "Others"
                  },
                  {
                    "pool": "2001:db8:0:1::4000 - 2001:db8:0:1::5000",
                    "client-class": "VoIP-Phones"
                  }
                ],
                ...

        Depending on which client class a host matches, Kea assigns an IP from the corresponding pool.

    2. Verify the syntax of the configuration file:

      # kea-dhcp6 -t /etc/kea/kea-dhcp6.conf

      If the command returns Syntax check failed, fix the errors shown in the report.

    3. Restart the kea-dhcp6 service:

      # systemctl restart kea-dhcp6

Verification

  • Connect clients that match the rules in the client classes and verify that Kea assigned an IP from the associated pool.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部