+
+
+{{ partial("layout_partials/base_dialog",['fields':formDialogSubnet,'id':'DialogSubnet','label':lang._('Edit Subnet')])}}
+{{ partial("layout_partials/base_dialog",['fields':formDialogReservation,'id':'DialogReservation','label':lang._('Edit Reservation')])}}
diff --git a/src/opnsense/service/conf/actions.d/actions_kea.conf b/src/opnsense/service/conf/actions.d/actions_kea.conf
new file mode 100644
index 000000000..90cebb3e2
--- /dev/null
+++ b/src/opnsense/service/conf/actions.d/actions_kea.conf
@@ -0,0 +1,24 @@
+[stop]
+command:/usr/local/etc/rc.d/kea stop
+parameters:
+type:script
+message:stop kea daemon
+
+[start]
+command:/usr/local/etc/rc.d/kea start
+parameters:
+type:script
+message:start kea daemon
+
+[restart]
+command:/usr/local/etc/rc.d/kea restart
+parameters:
+type:script
+message:restart kea daemon
+description:Restart kea daemon
+
+[status]
+command:/usr/local/sbin/pluginctl -s kea-dhcpv4 status
+parameters:
+type:script_output
+message:get kea daemon status
diff --git a/src/opnsense/service/templates/OPNsense/Kea/+TARGETS b/src/opnsense/service/templates/OPNsense/Kea/+TARGETS
new file mode 100644
index 000000000..a3bf79720
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Kea/+TARGETS
@@ -0,0 +1,4 @@
+kea-dhcp4.conf:/usr/local/etc/kea/kea-dhcp4.conf
+rc.conf.d:/etc/rc.conf.d/kea
+keactrl.conf:/usr/local/etc/kea/keactrl.conf
+kea-ctrl-agent.conf:/usr/local/etc/kea/kea-ctrl-agent.conf
\ No newline at end of file
diff --git a/src/opnsense/service/templates/OPNsense/Kea/kea-ctrl-agent.conf b/src/opnsense/service/templates/OPNsense/Kea/kea-ctrl-agent.conf
new file mode 100644
index 000000000..e8a88a594
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Kea/kea-ctrl-agent.conf
@@ -0,0 +1,105 @@
+// This is a basic configuration for the Kea Control Agent.
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// in ISC's Knowledgebase (https://kea.readthedocs.io; the direct link for
+// the stable version is https://kea.readthedocs.io/).
+//
+// This configuration file contains only Control Agent's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the Control Agent.
+{
+
+// This is a basic configuration for the Kea Control Agent.
+// RESTful interface to be available at http://127.0.0.1:8000/
+"Control-agent": {
+ "http-host": "127.0.0.1",
+ // If enabling HA and multi-threading, the 8000 port is used by the HA
+ // hook library http listener. When using HA hook library with
+ // multi-threading to function, make sure the port used by dedicated
+ // listener is different (e.g. 8001) than the one used by CA. Note
+ // the commands should still be sent via CA. The dedicated listener
+ // is specifically for HA updates only.
+ "http-port": 8000,
+
+ // Specify location of the files to which the Control Agent
+ // should connect to forward commands to the DHCPv4, DHCPv6
+ // and D2 servers via unix domain sockets.
+ "control-sockets": {
+ "dhcp4": {
+ "socket-type": "unix",
+ "socket-name": "/var/run/kea4-ctrl-socket"
+ },
+ "dhcp6": {
+ "socket-type": "unix",
+ "socket-name": "/var/run/kea6-ctrl-socket"
+ },
+ "d2": {
+ "socket-type": "unix",
+ "socket-name": "/var/run/kea-ddns-ctrl-socket"
+ }
+ },
+
+ // Specify hooks libraries that are attached to the Control Agent.
+ // Such hooks libraries should support 'control_command_receive'
+ // hook point. This is currently commented out because it has to
+ // point to the existing hooks library. Otherwise the Control
+ // Agent will fail to start.
+ "hooks-libraries": [
+// {
+// "library": "/usr/local/lib/kea/hooks/control-agent-commands.so",
+// "parameters": {
+// "param1": "foo"
+// }
+// }
+ ],
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+ "loggers": [
+ {
+ // This specifies the logging for Control Agent daemon.
+ "name": "kea-ctrl-agent",
+ "output_options": [
+ {
+ // Specifies the output file. There are several special values
+ // supported:
+ // - stdout (prints on standard output)
+ // - stderr (prints on standard error)
+ // - syslog (logs to syslog)
+ // - syslog:name (logs to syslog using specified name)
+ // Any other value is considered a name of the file
+ "output": "syslog"
+
+ // Shorter log pattern suitable for use with systemd,
+ // avoids redundant information
+ // "pattern": "%-5p %m\n"
+
+ // This governs whether the log output is flushed to disk after
+ // every write.
+ // "flush": false,
+
+ // This specifies the maximum size of the file before it is
+ // rotated.
+ // "maxsize": 1048576,
+
+ // This specifies the maximum number of rotated files to keep.
+ // "maxver": 8
+ }
+ ],
+ // This specifies the severity of log messages to keep. Supported values
+ // are: FATAL, ERROR, WARN, INFO, DEBUG
+ "severity": "INFO",
+
+ // If DEBUG level is specified, this value is used. 0 is least verbose,
+ // 99 is most verbose. Be cautious, Kea can generate lots and lots
+ // of logs if told to do so.
+ "debuglevel": 0
+ }
+ ]
+}
+}
diff --git a/src/opnsense/service/templates/OPNsense/Kea/kea-dhcp4.conf b/src/opnsense/service/templates/OPNsense/Kea/kea-dhcp4.conf
new file mode 100644
index 000000000..f36241dda
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Kea/kea-dhcp4.conf
@@ -0,0 +1,64 @@
+{%- if not helpers.empty('OPNsense.Kea.dhcp4.general.interfaces') and not helpers.empty('OPNsense.Kea.dhcp4.general.enabled') -%}
+{%- set reservation_fields = ({
+ 'hw-address': 'hw_address',
+ 'ip-address': 'ip_address'
+}) -%}
+{%- set general = OPNsense.Kea.dhcp4.general -%}
+{
+ "Dhcp4": {
+ "valid-lifetime": {{general.valid_lifetime}},
+ "interfaces-config": {
+ "interfaces": ["{{helpers.physical_interfaces(general.interfaces.split(','))|join('","')}}"]
+ },
+ "lease-database": {
+ "type": "memfile",
+ "persist": true
+ },
+ "control-socket": {
+ "socket-type": "unix",
+ "socket-name": "/var/run/kea4-ctrl-socket"
+ },
+ "loggers": [
+ {
+ "name": "kea-dhcp4",
+ "output_options": [
+ {
+ "output": "syslog"
+ }
+ ],
+ "severity": "INFO"
+ }
+ ],
+ "subnet4": [
+{% for subnet in helpers.toList('OPNsense.Kea.dhcp4.subnets.subnet4') %}
+ {
+ "id": {{loop.index}},
+ "subnet": "{{subnet.subnet}}",
+ "option-data": [
+{% for od_attr in subnet.option_data if subnet.option_data[od_attr]|length > 1 %}
+ {
+ "name": "{{od_attr.replace('_','-')}}",
+ "data": {{subnet.option_data[od_attr]|tojson}}
+ }{% if not loop.last %},{% endif +%}
+{% endfor %}
+ ],
+ "pools": [
+{% for pool in (subnet.pools|default('')).split("\n") if pool|length > 1%}
+ { "pool": "{{pool}}" }{% if not loop.last %},{% endif +%}
+{% endfor %}
+ ],
+ "reservations": [
+{% for reservation in helpers.toList('OPNsense.Kea.dhcp4.reservations.reservation') if reservation.subnet == subnet['@uuid'] %}
+ {
+{% for res_key, res_prop in reservation_fields.items() if reservation[res_prop]|length > 1 %}
+ "{{res_key}}": "{{reservation[res_prop]}}"{% if not loop.last %},{% endif +%}
+{% endfor %}
+ }{% if not loop.last %},{% endif +%}
+{% endfor %}
+ ]
+ }{% if not loop.last %},{% endif +%}
+{% endfor %}
+ ]
+ }
+}
+{%- endif -%}
\ No newline at end of file
diff --git a/src/opnsense/service/templates/OPNsense/Kea/keactrl.conf b/src/opnsense/service/templates/OPNsense/Kea/keactrl.conf
new file mode 100644
index 000000000..7d24e7899
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Kea/keactrl.conf
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# This is a configuration file for keactrl script which controls
+# the startup, shutdown, reconfiguration and gathering the status
+# of the Kea's processes.
+
+# Note that control agent must be launched after servers and netconf last.
+
+# shellcheck disable=SC2034
+# SC2034: ... appears unused. Verify use (or export if used externally).
+
+# prefix holds the location where the Kea is installed.
+prefix="/usr/local"
+
+# Location of Kea configuration files.
+kea_dhcp4_config_file="${prefix}/etc/kea/kea-dhcp4.conf"
+kea_dhcp6_config_file="${prefix}/etc/kea/kea-dhcp6.conf"
+kea_dhcp_ddns_config_file="${prefix}/etc/kea/kea-dhcp-ddns.conf"
+kea_ctrl_agent_config_file="${prefix}/etc/kea/kea-ctrl-agent.conf"
+kea_netconf_config_file="${prefix}/etc/kea/kea-netconf.conf"
+
+# Location of Kea binaries.
+exec_prefix="${prefix}"
+dhcp4_srv="${exec_prefix}/sbin/kea-dhcp4"
+dhcp6_srv="${exec_prefix}/sbin/kea-dhcp6"
+dhcp_ddns_srv="${exec_prefix}/sbin/kea-dhcp-ddns"
+ctrl_agent_srv="${exec_prefix}/sbin/kea-ctrl-agent"
+netconf_srv="${exec_prefix}/sbin/kea-netconf"
+
+# Start DHCPv4 server?
+dhcp4=yes
+
+# Start DHCPv6 server?
+dhcp6=no
+
+# Start DHCP DDNS server?
+dhcp_ddns=no
+
+# Start Control Agent?
+ctrl_agent=no
+
+# Start Netconf?
+netconf=no
+
+# Be verbose?
+kea_verbose=no
diff --git a/src/opnsense/service/templates/OPNsense/Kea/rc.conf.d b/src/opnsense/service/templates/OPNsense/Kea/rc.conf.d
new file mode 100644
index 000000000..4c0772ea5
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Kea/rc.conf.d
@@ -0,0 +1,5 @@
+{% if not helpers.empty('OPNsense.Kea.dhcp4.general.interfaces') and not helpers.empty('OPNsense.Kea.dhcp4.general.enabled') %}
+kea_enable="YES"
+{% else %}
+kea_enable="NO"
+{% endif %}
\ No newline at end of file
diff --git a/src/opnsense/service/templates/OPNsense/Syslog/local/kea.conf b/src/opnsense/service/templates/OPNsense/Syslog/local/kea.conf
new file mode 100644
index 000000000..9ac906e59
--- /dev/null
+++ b/src/opnsense/service/templates/OPNsense/Syslog/local/kea.conf
@@ -0,0 +1,6 @@
+###################################################################
+# Local syslog-ng configuration filter definition [kea].
+###################################################################
+filter f_local_kea {
+ program("kea-dhcp4") or program("kea-dhcp6") or program("kea-ctrl-agent");
+};