Add new dhcp.ignoreUnknownClients option

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2024-05-30 12:26:40 +02:00
parent 7ff016f21c
commit 1a5e7f6bf8
4 changed files with 18 additions and 0 deletions
+3
View File
@@ -320,6 +320,8 @@ components:
type: boolean
logging:
type: boolean
ignoreUnknownClients:
type: boolean
hosts:
type: array
items:
@@ -653,6 +655,7 @@ components:
rapidCommit: false
multiDNS: false
logging: false
ignoreUnknownClients: false
hosts:
- "11:22:33:44:55:66,192.168.1.123"
- "11:22:33:44:55:67,192.168.1.124,hostname"
+7
View File
@@ -785,6 +785,13 @@ void initConfig(struct config *conf)
conf->dhcp.logging.d.b = false;
conf->dhcp.logging.c = validate_stub; // Only type-based checking
conf->dhcp.ignoreUnknownClients.k = "dhcp.ignoreUnknownClients";
conf->dhcp.ignoreUnknownClients.h = "Ignore unknown DHCP clients.\n If this option is set, Pi-hole ignores all clients which are not explicitly configured through dhcp.hosts. This can be useful to prevent unauthorized clients from getting an IP address from the DHCP server.\n It should be noted that this option is not a security feature, as clients can still assign themselves an IP address and use the network. It is merely a convenience feature to prevent unknown clients from getting a valid IP configuration assigned automatically.\n Note that you will need to configure new clients manually in dhcp.hosts before they can use the network when this feature is enabled.";
conf->dhcp.ignoreUnknownClients.t = CONF_BOOL;
conf->dhcp.ignoreUnknownClients.f = FLAG_RESTART_FTL;
conf->dhcp.ignoreUnknownClients.d.b = false;
conf->dhcp.ignoreUnknownClients.c = validate_stub; // Only type-based checking
conf->dhcp.hosts.k = "dhcp.hosts";
conf->dhcp.hosts.h = "Per host parameters for the DHCP server. This allows a machine with a particular hardware address to be always allocated the same hostname, IP address and lease time or to specify static DHCP leases";
conf->dhcp.hosts.a = cJSON_CreateStringReference("Array of static leases each on in one of the following forms: \"[<hwaddr>][,id:<client_id>|*][,set:<tag>][,tag:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]\"");
+1
View File
@@ -187,6 +187,7 @@ struct config {
struct conf_item rapidCommit;
struct conf_item multiDNS;
struct conf_item logging;
struct conf_item ignoreUnknownClients;
struct conf_item hosts;
} dhcp;
+7
View File
@@ -582,6 +582,13 @@ bool __attribute__((const)) write_dnsmasq_config(struct config *conf, bool test_
fputs("log-dhcp\n\n", pihole_conf);
}
// Add option to ignore unknown clients if enabled
if(conf->dhcp.ignoreUnknownClients.v.b)
{
fputs("# Ignore clients not configured below\n", pihole_conf);
fputs("dhcp-ignore=tag:!known\n", pihole_conf);
}
// Add per-host parameters
if(cJSON_GetArraySize(conf->dhcp.hosts.v.json) > 0)
{