0

I want to assign a hostname to a ESP8266 access point, so that the clients can reach a webserver on this access point without caring about the IP address of the AP. How can that be done?

I tried using WiFi.hostname("something"); but that does not work with AP mode. Can this somehow be done?

UPDATE

Using mDNS seems to work in this AP mode too. However, I am still curious to know if this is possible to access the webserver on the AP using the hostname and not mDNS.

1 Answer 1

1

I'm unclear on the distinction being drawn here:

the hostname and not mDNS

mDNS, like DNS, and hostname lists are all things a "resolver" would use to map a "hostname" to an IP address.

If you mean "how do I use DNS instead of mDNS?", you'd need to have your ESP8266 running a DNS server. And for clients to be aware of it you'd probably have to be running a DHCP server as well.

By the way, the examples list for the ESP8266 Arduino package contains a DNSServer/DNSServer example that appears to do exactly this. I have just tested it.

This is the exact code I ran out of the ESP8266 Arduino github repo at the tag for the version of the ESP8266 Arduino core I tested it on, 2.7.4.

4
  • Well, yes, I would like the ESP AP to be able to resolve the hostnames (including its own hostname, and share it with any station requests this hostname). Thank you for pointing out that the examples include DNS server, I did a quick research and found nothing, now after checking again, I found one example. I am gonna give it a try. Thanks! Commented Nov 15, 2020 at 17:45
  • @MohammedNoureldin, let me know if it doesn't work.
    – timemage
    Commented Nov 16, 2020 at 17:59
  • Thank you for your comment, I got it working using DNS server, I will post a short answer a bit later. Thank you! Commented Nov 16, 2020 at 19:12
  • @MohammedNoureldin, good to know.
    – timemage
    Commented Nov 16, 2020 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.