Search code examples
network-programmingdnswifinodemcuaccess-point

Domain name resolution for NodeMCU as an access point


I was reading through the NodeMCU documentation on enduser setup Module, and now I have a little confusion about the following statement:

Connect to that SSID and then navigate to the root of any website (e.g., http://example.com/... 
A web page will load, allowing the end user to provide their Wi-Fi information.

With default configuration, the NodeMCU access point has an IP address: 192.168.4.1.

My question is, how is www.example.com resolved so that it points to the module's access point IP address (192.168.4.1)? Is there any default DNS configuration for the module?

Full documentation is available here.


Solution

  • It simply always returns the IP of the ESP for every DNS query.
    You can see that in line 1491 of the source code. (enduser_setup.c)

    The enduser_setup_dns_recv_callback will always return the IP that is being retrieved by calling wifi_get_ip_info.

    Line 1470:

    wifi_get_ip_info(if_index , &ip_info)
    

    Line 1491:

    c_memcpy(&(dns_reply[insert_byte]), &(ip_info.ip), 4);