How Do I Stop DHCPS from obtaining an IP address from another DHCP server?

PeterG76
Posts: 15
Joined: Wed May 25, 2022 10:25 am

How Do I Stop DHCPS from obtaining an IP address from another DHCP server?

Postby PeterG76 » Wed May 25, 2022 10:44 am

I'm using esp-2019r2 and have an esp32 application that can be configured as either DHCPC or DHCPS.

However when running in DHCPS mode if it sees another DHCP server on the ethernet network, it drops it's configured static IP address and obtains an IP address from the other DHCP server. How can I disable the EPS-IF network or lwip layers from doing this? I have other devices running buildroot Linux which also run DHCP severs and do not do this.

I've had to change the subnet mask and lease time in the esp-idf lwip dhcpserver.c to suit my needs, because configuring the subnet mask is'n't supported by my version of the esp-idf. Is there a configuration setting to stop the Espressif's EPS-IF DHCP Server from obtaining a dynamic IP address?

I get a esp_netif_handlers callback to say the app has got a new IP address & subnet mask so clearly the app is dropping it's static IP address and doing a DORA negotiation with the other DHCP server.

Any suggestions would be much appreciated.

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: How Do I Stop DHCPS from obtaining an IP address from another DHCP server?

Postby ESP_YJM » Thu May 26, 2022 9:57 am

When you use ethernet interface in ESP device, i think the eth in ESP now only support DHCP client mode, not support DHCP server, and the phenomenon is what you saw, the ESP device get IP from other DHCP server. You can try modify https://github.com/espressif/esp-idf/bl ... ults.h#L48 and change ESP_NETIF_DHCP_CLIENT to ESP_NETIF_DHCP_SERVER.

PeterG76
Posts: 15
Joined: Wed May 25, 2022 10:25 am

Re: How Do I Stop DHCPS from obtaining an IP address from another DHCP server?

Postby PeterG76 » Wed Jun 01, 2022 9:23 am

I've discovered the issue.

Version 4.1 of the ESP-IDF's esp_netif_handlers.c was always starting a DHCP Client regardless of the config flags. i.e ESP_NETIF_DHCP_CLIENT unset and ESP_NETIF_DHCP_SERVER set.

Looks like this has been fixed in Version 4.2 (See following commit)

https://github.com/espressif/esp-idf/co ... c581061746

If I apply this change to my version for the ESP-IDF then my application no longer sends DHCP Discover when I configure it to be DHCP Server only.

Who is online

Users browsing this forum: StuartsProjects and 110 guests