Does the IDF provide a DNS server? How do I use it?
Posted: Wed Nov 21, 2018 12:09 am
I'm building off the softAP example code, and I'd like my AP to act as a DNS server so a client can resolve the device by name.
It looks like there are some options to set hostname and DNS functionality via LWIP, but I can't get them to work with a client. For example, here's some code that might go after the wifi start call:
If param is set to 0, then a Windows 10 client gives:
If it's set to 1, then:
When param = 1 I also don't get any DNS servers on the client via DHCP, which seems like it's the opposite of what a 1/0 flag should be.
Do I need to know the domain here? How is it set? I'd prefer not to use mDNS because it introduces extra dependencies for Windows clients. Is there a way to get normal DNS working out of the box with the IDF?
It looks like there are some options to set hostname and DNS functionality via LWIP, but I can't get them to work with a client. For example, here's some code that might go after the wifi start call:
Code: Select all
ESP_ERROR_CHECK(esp_wifi_start());
// ...later...
const char * hostname;
tcpip_adapter_ip_info_t ip;
uint8_t param = 0;
ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
ESP_ERROR_CHECK(tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_AP, CONFIG_ESP_NETNAME));
ESP_ERROR_CHECK(
tcpip_adapter_dhcps_option(
TCPIP_ADAPTER_OP_SET,
TCPIP_ADAPTER_DOMAIN_NAME_SERVER,
¶m,
sizeof(param)
));
ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));
Code: Select all
> nslookup streamer
DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
Address: 192.168.4.1
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to UnKnown timed-out
Code: Select all
>nslookup streamer
Server: UnKnown
Address: 0.0.0.0
*** UnKnown can't find streamer: No response from server
Do I need to know the domain here? How is it set? I'd prefer not to use mDNS because it introduces extra dependencies for Windows clients. Is there a way to get normal DNS working out of the box with the IDF?