mDNS multiple hostnames (alias)?

phatpaul
Posts: 110
Joined: Fri Aug 24, 2018 1:14 pm

mDNS multiple hostnames (alias)?

Postby phatpaul » Tue Nov 13, 2018 9:54 pm

I have either one or multiple devices on the network which share the same services.

For WiFi AP, I set the SSID uniquely as "base-xxxx" where xxxx is unique and derived from the MAC address.

But for STA and ETH, they are just anonymous devices on the network with dhcp given IP. (at least I can set the dhcp-client hostname uniquely -see https://esp32.com/viewtopic.php?t=1406 )

If there is just one device on the network (or I don't care which device responds), I would like to be able to access it using mDNS at http://base.local

In the case of multiple devices present, I would also like to be able to access as http://base-xxxx.local (same unique name as SSID).
That way I know for sure which device I'm talking to.

But the mDNS implementation only seems to support one hostname, and no concept of an alias. How can I get both http://base.local and http://base-xxxx.local working?

Interestingly, it seems that there is some conflict resolution going on in the mDNS. I'm seeing some devices coming up with base-2.local and base-3.local, etc...
But that doesn't help me know which device I'm talking to.

Thoughts?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mDNS multiple hostnames (alias)?

Postby WiFive » Tue Nov 13, 2018 10:26 pm

Query for base.local and if you get a response set your hostname to base-xxxx.local

phatpaul
Posts: 110
Joined: Fri Aug 24, 2018 1:14 pm

Re: mDNS multiple hostnames (alias)?

Postby phatpaul » Thu Nov 29, 2018 6:33 pm

Thanks for the response WiFive, but that's not exactly what I'm after.
It seems the mdns server code in the IDF already does what you proposed. I'm seeing some devices coming up with base-2.local and base-3.local, etc...

But I want multiple hosts to all share the same name base.local. The RFC states that this should be possible.
https://www.ietf.org/rfc/rfc6762.txt [Page 31]
The RFC says that a host may be "configured to require a unique host name" or not. "These considerations apply to address records (i.e., host names) and to all resource records where uniqueness (or maintenance of some other defined constraint) is desired."

But this option to not require a unique name doesn't seem to be configurable in the IDF. (this is an issue in addition to not allowing multiple hostnames/alias)

I ran into another problem as well. It seems the mDNS server doesn't allow multiple SRV records of the same name!
So I can't have 2 _http._tcp services?
i.e.
mdns_service_add("site1", "_http", "_tcp", 80, NULL, 0) );
mdns_service_add("site2", "_http", "_tcp", 80, NULL, 0) );
But this should be possible according to this: https://tools.ietf.org/html/rfc6763

The offending code is here:
https://github.com/espressif/esp-idf/bl ... ns.c#L4154

Should I open issues in ESP-IDF for these?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mDNS multiple hostnames (alias)?

Postby WiFive » Thu Nov 29, 2018 11:59 pm

Right but base-increment.local is not as useful as base-knownvalue.local. how does a browser mediate conflicts for multiple base.local responders? First to reply? It could be a different device every time.

Who is online

Users browsing this forum: No registered users and 140 guests