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

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동