Closed moogle19 closed 7 months ago
best check the contents of /usr/local/etc/kea/kea-dhcp4.conf
as that is what we generate.
@AdSchellevis
Hmm, kea-dhcp4.conf
matches the values in the web interface. Not sure why the API yields different values.
Hi have same issue, and when I edit any non-first entry and save, first entry get corrupted even in kea-dhcp4.conf
A kea-dhcp4.conf
file combined with the kea configuration section (in config.xml
) might help track possible issues....
@AdSchellevis
config.xml
after first subnet:
<Kea>
<ctrl_agent version="0.0.1">
<general>
<enabled>1</enabled>
<http_host>127.0.0.1</http_host>
<http_port>8000</http_port>
</general>
</ctrl_agent>
<dhcp4 version="1.0.0">
<general>
<enabled>1</enabled>
<interfaces>opt20</interfaces>
<valid_lifetime>4000</valid_lifetime>
<fwrules>0</fwrules>
</general>
<ha>
<enabled>0</enabled>
<this_server_name/>
</ha>
<subnets>
<subnet4 uuid="b3b776e5-0cfc-4510-b80a-9210ec814f4c">
<subnet>192.168.0.0/24</subnet>
<option_data_autocollect>0</option_data_autocollect>
<option_data>
<domain_name_servers>192.168.0.1</domain_name_servers>
<routers>192.168.0.1</routers>
<domain_name/>
<ntp_servers/>
<tftp_server_name/>
<boot_file_name/>
</option_data>
<pools>192.168.0.10-192.168.0.240</pools>
</subnet4>
</subnets>
<reservations/>
<ha_peers/>
</dhcp4>
</Kea>
kea-dhcp4.conf
after first subnet:
{
"Dhcp4": {
"valid-lifetime": 4000,
"interfaces-config": {
"interfaces": ["vlan0.803"]
},
"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": [
{
"id": 1,
"subnet": "192.168.0.0/24",
"option-data": [
{
"name": "domain-name-servers",
"data": "192.168.0.1"
},
{
"name": "routers",
"data": "192.168.0.1"
},
{
"name": "domain-name",
"data": "localdomain"
}
],
"pools": [
{ "pool": "192.168.0.10-192.168.0.240" }
],
"reservations": [
]
}
]
,"hooks-libraries": [
{
"library": "/usr/local/lib/kea/hooks/libdhcp_lease_cmds.so",
"parameters": { }
},
]
}
}
config.xml
after second subnet added:
<Kea>
<ctrl_agent version="0.0.1">
<general>
<enabled>1</enabled>
<http_host>127.0.0.1</http_host>
<http_port>8000</http_port>
</general>
</ctrl_agent>
<dhcp4 version="1.0.0">
<general>
<enabled>1</enabled>
<interfaces>opt20</interfaces>
<valid_lifetime>4000</valid_lifetime>
<fwrules>0</fwrules>
</general>
<ha>
<enabled>0</enabled>
<this_server_name/>
</ha>
<subnets>
<subnet4 uuid="b3b776e5-0cfc-4510-b80a-9210ec814f4c">
<subnet>192.168.0.0/24</subnet>
<option_data_autocollect>0</option_data_autocollect>
<option_data>
<domain_name_servers>192.168.178.1</domain_name_servers>
<routers>192.168.178.1</routers>
<domain_name/>
<ntp_servers/>
<tftp_server_name/>
<boot_file_name/>
</option_data>
<pools>192.168.0.10-192.168.0.240</pools>
</subnet4>
<subnet4 uuid="07b8fa5b-7754-4c59-8694-a75df52f468c">
<subnet>192.168.178.0/24</subnet>
<option_data_autocollect>0</option_data_autocollect>
<option_data>
<domain_name_servers>192.168.178.1</domain_name_servers>
<routers>192.168.178.1</routers>
<domain_name/>
<ntp_servers/>
<tftp_server_name/>
<boot_file_name/>
</option_data>
<pools>192.168.178.10-192.168.178.240</pools>
</subnet4>
</subnets>
<reservations/>
<ha_peers/>
</dhcp4>
</Kea>
kea-dhcp4.conf
after second subnet:
{
"Dhcp4": {
"valid-lifetime": 4000,
"interfaces-config": {
"interfaces": ["vlan0.803"]
},
"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": [
{
"id": 1,
"subnet": "192.168.0.0/24",
"option-data": [
{
"name": "domain-name-servers",
"data": "192.168.178.1"
},
{
"name": "routers",
"data": "192.168.178.1"
},
{
"name": "domain-name",
"data": "localdomain"
}
],
"pools": [
{ "pool": "192.168.0.10-192.168.0.240" }
],
"reservations": [
]
},
{
"id": 2,
"subnet": "192.168.178.0/24",
"option-data": [
{
"name": "domain-name-servers",
"data": "192.168.178.1"
},
{
"name": "routers",
"data": "192.168.178.1"
},
{
"name": "domain-name",
"data": "localdomain"
}
],
"pools": [
{ "pool": "192.168.178.10-192.168.178.240" }
],
"reservations": [
]
}
]
,"hooks-libraries": [
{
"library": "/usr/local/lib/kea/hooks/libdhcp_lease_cmds.so",
"parameters": { }
},
]
}
}
@moogle19 from my perspective this looks good, same as specified in https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html or am I missing something?
@AdSchellevis
The files are valid, the problem is that domain-name-servers
and routers
in the option-data
values of the first entry are overwritten by the second entry.
I configured 192.168.0.1
as router/dns for the first subnet but after adding the second subnet with 192.168.178.1
the first one gets the router/dns specified in the 192.168.178.0
subnet.
@moogle19 after save it changes to the first?
I can't reproduce that on my end, auto collect is the only thing that mangles with these settings when set, the rest operates the same as any other form.
Yes, after save of second, first is corrupted. It happens when auto collect is off (could that be an issue)?
and what does the configuration history show? (System: Configuration: History)
starting from scratch I seem to be able to reproduce this, not sure why this happens yet though.
@moogle19 @mmaction does this issue on your end only happen when adding a new item or also when editing an existing one (and 2 are already there)?
@AdSchellevis It only happens when adding a new entry
@moogle19 ok, thanks, then I know where to look.
Should be fixed with https://github.com/opnsense/core/commit/8973f6efb14bec010e7f929ae748d8e06795e8c9 , which can be installed using:
opnsense-patch 8973f6e
Kea is the only component that currently uses these nested structures inside the model, which is the reason this issue only shows itself here.
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
Describe the bug
We have multiple subnets in Kea. When we add a new one without "Auto collect option data" the Gateway and DNS servers of the first entry are overwritten by the values used in the new subnet. There are also inconsistencies between the Kea API and the opnsense user interface (see Screenshots).
To Reproduce
Steps to reproduce the behavior:
Expected behavior The first entry should not be overwritten
Screenshots This is the interface configuration in the user interface (192.168.70.0/24 net look correct, 192.168.90.0/24 has a wrong gateway and dns from a subnet we added later):
This is what the API returns (192.168.90.0/24 net look correct, 192.168.70.0/24 has a wrong gateway and dns):
Relevant log files
If applicable, information from log files supporting your claim.
Additional context
Add any other context about the problem here.
Environment
Software version used and hardware type if relevant, e.g.:
OPNsense 24.1.2_1-amd64 FreeBSD 13.2-RELEASE-p10 OpenSSL 3.0.13 Intel(R) Xeon(R) Gold 6326 CPU @ 2.90GHz (8 cores, 8 threads)