tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
666 stars 219 forks source link

Anyway to use a hostname instead of an IP? #11

Closed hchaudhary1 closed 5 years ago

hchaudhary1 commented 6 years ago

Instead of going to http://192.168.1.1, is it possible instead to go to "http://myesp.config". Is that possible?

tonyp7 commented 6 years ago

Hi hchaudhary1, that would not be something you can solve with the code. You would have to add an entry into your DNS server so that mysesp.config gets you back to 192.168.1.1.

You can also buy your own domain and have it send you back to 192.168.1.1.

There is mDNS but it has its own set of limitations.

hchaudhary1 commented 6 years ago

well, most routers in hotels and coffee shops will automatically force my laptop to open a page with a non-public DNS name. I never need to know the IP of the router...

Here is a Wikipedia article I found. I will research this more. It should be possible. https://en.wikipedia.org/wiki/Captive_portal

hchaudhary1 commented 6 years ago

ok, I think it would go something like this...

  1. ESP in AP mode offers my laptop an IP & DNS
  2. The ESP runs a DNS server with the ability to resolve "http://myesp.config" to 192.168.1.1
  3. The ESP does 301 redirect to ANY http requests. Redirects always to "http://myesp.config"
  4. Wifi manager runs at 192.168.1.1

Perhaps I will test this at some point...

lukecyca commented 5 years ago

I have forked this and added captive portal functionality, but it currently only works on macOS and iOS clients, due to a very hacky DNS implementation that can only parse the very specific DNS request that I sniffed on the network during testing.

There may now be a more generalized DNS server implementation that can parse any DNS query and resolve it to 192.168.1.1.

https://github.com/craftmetrics/esp32-wifi-manager https://github.com/craftmetrics/esp32-dns-server

hchaudhary1 commented 5 years ago

ESP team may support the captive portal. ref: https://github.com/espressif/esp-idf/issues/2723

tonyp7 commented 5 years ago

The current version now automatically opens a page for you, similarly to a hotel wifi ("captive portal"). Try it out!