diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 231536c39d..c51fab4514 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -433,6 +433,20 @@ menu "LWIP" Enabling this option allows DHCP server to support temporary static ARP entries for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast. + config LWIP_DHCPS_ADD_DNS + bool "Always add DNS option in DHCP responses" + default y + depends on LWIP_DHCPS + help + This allows the DNS option to be optional in the DHCP offers, + depending on the server's runtime configuration. + When enabled, the DHCP server will always add the DNS option to DHCP responses. + If a DNS server is not explicitly configured, the server's IP address will be used + as the fallback for the DNS option. + When disabled, the DHCP server will only include the DNS option in responses + if a DNS server has been explicitly configured. + This option will be removed in IDF v6.x + endmenu # DHCPS menuconfig LWIP_AUTOIP diff --git a/components/lwip/apps/dhcpserver/dhcpserver.c b/components/lwip/apps/dhcpserver/dhcpserver.c index 60e6e15cd4..8859e52c63 100644 --- a/components/lwip/apps/dhcpserver/dhcpserver.c +++ b/components/lwip/apps/dhcpserver/dhcpserver.c @@ -461,6 +461,15 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr) *optptr++ = ip4_addr2(&dhcps->dns_server); *optptr++ = ip4_addr3(&dhcps->dns_server); *optptr++ = ip4_addr4(&dhcps->dns_server); +#ifdef CONFIG_LWIP_DHCPS_ADD_DNS + }else { + *optptr++ = DHCP_OPTION_DNS_SERVER; + *optptr++ = 4; + *optptr++ = ip4_addr1(&ipadd); + *optptr++ = ip4_addr2(&ipadd); + *optptr++ = ip4_addr3(&ipadd); + *optptr++ = ip4_addr4(&ipadd); +#endif /* CONFIG_LWIP_DHCPS_ADD_DNS */ } ip4_addr_t broadcast_addr = { .addr = (ipadd.addr & dhcps->dhcps_mask.addr) | ~dhcps->dhcps_mask.addr };