classify.json 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # This is an example configuration file for the DHCPv4 server in Kea.
  2. # The purpose of this example is to showcase how clients can be classified.
  3. { "Dhcp4": {
  4. # Kea is told to listen on ethX interface only.
  5. "interfaces-config": {
  6. "interfaces": [ "ethX" ]
  7. },
  8. # Let's use the simplest backend: memfile and use some reasonable values
  9. # for timers. They are of no concern for the classification demonstration.
  10. "lease-database": { "type": "memfile" },
  11. "renew-timer": 1000,
  12. "rebind-timer": 2000,
  13. "valid-lifetime": 4000,
  14. # This list defines several classes that incoming packets can be assigned to.
  15. # One packet can belong to zero or more classes.
  16. "client-classes": [
  17. # The first class attempts to match the whole hardware address to a specific
  18. # value. All incoming packets with that MAC address will get a special
  19. # value of the option. If there are many hosts that require special
  20. # treatment, it is much better to use host reservations. However, doing
  21. # tricks with MAC addresses may prove useful in some cases, e.g.
  22. # by matching OUI to known values we can detect certain vendors.
  23. {
  24. "name": "special_snowflake",
  25. "test": "pkt4.mac == 0x010203040506",
  26. "option-data": [{
  27. "name": "domain-name-servers",
  28. "data": "127.0.0.1"
  29. }]
  30. },
  31. # Let's classify all incoming DISCOVER (message type 1) to a separate
  32. # class.
  33. {
  34. "name": "discovers",
  35. "test": "pkt4.msgtype == 1"
  36. },
  37. # Clients are supposed to set the transaction-id field to a random value.
  38. # Clients that send it with 0 are most likely broken. Let's mark them
  39. # as such.
  40. {
  41. "name": "broken",
  42. "test": "pkt4.transid == 0"
  43. },
  44. # Let's pick VoIP phones. Those that send their class identifiers
  45. # as Aastra, should belong to VoIP class. For a list of all options,
  46. # see www.iana.org/assignments/bootp-dhcp-parameters/.
  47. # In this particular class, we want to set specific values
  48. # of certain DHCPv4 fields. If the incoming packet matches the
  49. # test, those fields will be set in outgoing responses.
  50. {
  51. "name": "VoIP",
  52. "test": "substring(option[60].hex,0,6) == 'Aastra'",
  53. "next-server": "192.0.2.254",
  54. "server-hostname": "hal9000",
  55. "boot-file-name": "/dev/null"
  56. }
  57. ],
  58. # The following list defines subnets. For some subnets we defined
  59. # a class that is allowed in that subnet. If not specified,
  60. # everyone is allowed. When a class is specified, only packets belonging
  61. # to that class are allowed for that subnet.
  62. "subnet4": [
  63. {
  64. # This one is for VoIP devices only.
  65. "pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
  66. "subnet": "192.0.2.0/24",
  67. "client-class": "VoIP",
  68. "interface": "ethX"
  69. },
  70. # This one doesn't have any client-class specified, so everyone
  71. # is allowed in. The normal subnet selection rules still apply,
  72. # though. There is also a static class reservation for a client
  73. # using MAC address 1a:1b:1c:1d:1e:1f. This client will always
  74. # be assigned to this class.
  75. {
  76. "pools": [ { "pool": "192.0.3.1 - 192.0.3.200" } ],
  77. "subnet": "192.0.3.0/24",
  78. "reservations": [
  79. {
  80. "hw-address": "1a:1b:1c:1d:1e:1f",
  81. "client-classes": [ "VoIP" ]
  82. } ],
  83. "interface": "ethX"
  84. }
  85. ]
  86. },
  87. # The following configures logging. It assumes that messages with at least
  88. # informational level (info, warn, error and fatal) should be logged to stdout.
  89. "Logging": {
  90. "loggers": [
  91. {
  92. "name": "kea-dhcp4",
  93. "output_options": [
  94. {
  95. "output": "stdout"
  96. }
  97. ],
  98. "severity": "INFO"
  99. }
  100. ]
  101. }
  102. }