# mDNS Service

[![Component Registry](](

mDNS is a multicast UDP service that is used to provide local network service and host discovery.

## Examples

Get started with example test [Example](

## Documentation

* View the full [documentation(English)](
* View the full [documentation(Chinese)](


# Changelog

## [1.2.4](

### Bug Fixes

- Correction on 6d2c475 MDNS_PREDEF_NETIF_ETH fix ([fc59f87c4e](
- fix the logic of creating pcb for networking socket ([5000a9a20a](
- fix compiling issue when disabling IPv4 ([2646dcd23a](
- Fix compile error when MDNS_PREDEF_NETIF_ETH is defined, but ETH_ENABLED is not (#459) ([6d2c475c20](

## [1.2.3](

### Bug Fixes

- fixed CI issues for host and afl tests ([4be5efc84e](
- fix copy delegated host addr ([19fb36000c](
- enable CONFIG_ESP_WIFI_ENABLED if CONFIG_SOC_WIFI_SUPPORTED is also enabled (for ESP-IDF <= 5.1) ([d20a718320](
- remove protocol_examples_common ([1ee9dae6bf](
- move the example into a subdirectory ([d28232b9f8](
- reference protocol_examples_common from IDF ([c83b76ea8f](

## [1.2.2](

### Bug Fixes

- add terminator for the getting host name ([b6a4d94](
- Enable ESP_WIFI_CONFIG when ESP-IDF <= 5.1 ([0b783c0](
- set host list NULL on destroy ([ea54eef](
- removed Wno-format flag and fixed formatting warnings ([c48e442](
- remove the the range of MDNS_MAX_SERVICES and fix issues of string functions ([3dadce2](

## [1.2.1](

### Features

- Allow setting length of mDNS action queue in menuconfig ([28cd898](

### Bug Fixes

- fix build issue if CONFIG_ESP_WIFI_ENABLED disabled ([24f7031](
- added idf_component.yml for examples ([d273e10](
- added guard check for null pointer ([71bb461](

## [1.2.0](

### Features

- add an API for setting address to a delegated host ([ddc3eb6](
- Add support for lwip build under linux ([588465d](
- Allow for adding a delegated host with no address ([c562461](
- Add APIs for looking up self hosted services and getting the self hostname ([f0df12d](

### Bug Fixes

- Refactor freertos linux compat layers ([79a0e57](
- Fix delegated service PTR response ([cab0e1d](
- Added unit tests to CI + minor fix to pass it ([c974c14](

### Updated

- docs: update documentation links ([4de5298](

## [1.1.0](

### Features

- Decouple main module from mdns-networking ([d238e93](

### Bug Fixes

- Use idf-build-apps package for building mdns ([1a0a41f](
- socket networking to init interfaces properly ([ee9b04f](
- Removed unused internal lock from mdns_server struct ([a06fb77](
- Resolve conflicts only on self hosted items ([e69a9eb](, [#185](
- Fix memory issues reported by valgrind ([0a682e7](

### Updated

- docs(common): updated component and example links ([f48d9b2](
- Add APIs to look up delegated services ([87dcd7d](
- Fix deadly mdns crash ([4fa3023](
- docs(common): improving documentation ([ca3fce0](
- append all ipv6 address in mdns answer ([5ed3e9a](
- test(mdns): Host tests to use IDF's esp_event_stub ([537d170](

## [1.0.9](

### Features

- Add reverse lookup to the example and test ([d464ed7](
- Add support for IPv6 reverse query ([d4825f5](

### Bug Fixes

- Reintroduce missing CHANGELOGs ([200cbb3](
- use semaphore instead of task notification bits (IDFGH-9380) ([73f2800](, [IDF#10754](

### Updated

- ci(common): force scoping commit messages with components ([c55fcc0](
- Add homepage URL and License to all components ([ef3f0ee](
- docs: fix of mdns link translation ([1c850dd](
- unite all tags under common structure py test: update tags under common structure ([c6db3ea](

## [1.0.8](

### Features

- Add support for IPv4 reverse query ([b87bef5](

### Bug Fixes

- Host test with IDFv5.1 ([fb8a2f0](
- Remove strict mode as it's invalid ([d0c9070](
- Allow setting instance name only after hostname set ([a8339e4](, [#190](
- Make unit test executable with pytest ([12cfcb5](
- AFL port layer per IDF-latest changes ([0247926](

### Updated

- bump the component version to 1.0.8 ([b9b4a75](
- Make reverse query conditional per Kconfig ([91134f1](
- Added badges with version of components to the respective README files ([e4c8a59](
- fix some coverity reported issues ([c73c797](
- Examples: using pytest.ini from top level directory ([aee016d](
- mDNS: test_app pytest migration ([f71f61f](
- CI: fixing the files to be complient with pre-commit hooks ([945bd17](
- prevent crash when hostname is null ([3498e86](
- Example tests integration ([a045c1c](
- Replace hardcoded TTL values with named defines ([bb4c002](
- Fix add_service() to report error if no-hostname ([656ab21](

## [1.0.7](

### Updated

- bump up the component version ([088f7ac](
- fix IPV4 only build and also update CI configuration ([e079f8b](
- add test configuration for IPV6 disabled build ([330332a](

## [1.0.6](

### Bug Fixes

- Example makefile to add only mdns as extra comps ([d74c296](
- ignore authoritative flag on reception ([415e04a](

### Updated

- fix build issue with CONFIG_LWIP_IPV6 disabled ([48c157b](
- fix bit order issue in DNS header flags ([c4e85bd](
- updated package version to 0.1.19 ([469f953](

## [1.0.5](

### Features

- Define explicit dependencies on esp-wifi ([36de9af](

### Updated

- bugfix: mdns IPv6 address convert error ([238ee96](

## [1.0.4](

### Updated

- Bump asio/mdns/esp_websocket_client versions ([57afa38](
- ignore format warnings ([d66f9dc](
- Fix test_app build ([0b102f6](

## [1.0.3](

### Updated

- Updated mDNS to explicitely use esp-eth dependency if needed ([4868689](, [IDF@5e19b9c](

## [1.0.2](

### Features

- fix bug when clean action memory ([81c219d](, [IDF@3d4deb9](

### Bug Fixes

- add the maximum number of services ([0191d6f](, [IDF@ba458c6](
- fix the exception when remove one of multiple service ([b26c866](, [IDF@696d733](

### Updated

- Minor fixes here and there ([8fe2a3a](
- mDNS: Initial version based on IDF 5.0 ([b6b20ad](
- soc: moved kconfig options out of the target component. ([4a52cf2](, [IDF@d287209](
- cmake: fix issue with passing cxx_std option for GCC 11, a common workaround ([87c2699](, [IDF@ea0d212](
- kconfig: Changed default values of bool configs - Some bool configs were using default values true and false,   instead of y and n. ([eb536a7](, [IDF@25c5c21](
- esp_netif: Remove tcpip_adapter compatibility layer ([3e93ea9](, [IDF@795b7ed](
- Fix copyright messages, update API descrition ([2c764b1](, [IDF@42ba8a8](
- Add API to control custom network interfaces ([f836ae7](, [IDF@b02468d](
- CI/mdns: Fix fuzzer build ([4b5f24f](, [IDF@98e9426](
- Add support for registering custom netif ([30f37c0](, [IDF@bec42ff](
- Indicate interface using esp_netif in search results ([ddc58e8](, [IDF@f8495f1](
- Use predefined interfaces to prepare for custom netifs ([fa951bf](, [IDF@f90b3b7](
- Prepare for dynamic esp-netif support ([605d1fa](, [IDF@f9892f7](
- esp_hw_support/esp_system: Re-evaluate header inclusions and include directories ([58bf218](, [IDF@a9fda54](
- system: move kconfig options out of target component ([ec491ec](, [IDF@bb88338](
- Update to drop our own packet if bounced back ([94ae672](, [IDF@b5149e3](
- Fix potential read behind parsed packet ([e5a3a3d](, [IDF@51a5de2](
- Fix memleak when adding delegated host ([7710ea9](, [IDF@9cbdb87](
- Fix null-service issue when parsing packets ([034c55e](, [IDF#8307](, [IDF@a57be7b](
- Update fuzzer test (add delegation, check memory) ([ec03fec](, [IDF@2c10071](
- Remove legacy esp_event API ([5909e9e](, [IDF@e46aa51](
- added missing includes ([82e2a5d](, [IDF@28d09c7](
- Clear notification value in mdns_hostname_set ([48e4d40](, [IDF@83a4ddb](
- esp_timer: remove legacy ESP32 FRC timer implementation. ([ac6dcb6](, [IDF@edb76f1](
- freertos: Remove legacy data types ([085dbd8](, [IDF@57fd78f](
- Tools: Custom baud-rate setup is not possible for IDF Monitor from menuconfig anymore ([f78e8cf](, [IDF@36a4011](
- Use memcpy() for copy to support non-text TXTs ([6cdf5ee](, [IDF@6aefe9c](
- Support for null-value TXT records ([fcb5515](, [IDF#8267](, [IDF@23c2db4](
- Fix alloc issue if TXT has empty value ([9fdbe5f](, [IDF@205f6ba](
- Fix random crash when defalt service instance queried ([20e6e9e](, [IDF@f46dffc](
- Fix minor memory leaks when creating services ([c588263](, [IDF@fad62cc](
- Fix mDNS memory leak ([6258edf](, [IDF@119b4a9](
- Fix mDNS memory leak ([c8b0d5e](, [IDF@f5ffd53](
- Use multi/uni-cast types in API ([5252b1d](, [IDF@125c312](
- Allow for unicast PTR queries ([4e11cc8](, [IDF@7eeeb01](
- Fix potential null deref for ANY query type ([7af91ec](, [IDF@99dd8ee](
- Make fuzzer layers compatible with llvm>=6 ([01256d3](, [IDF@1882cbe](
- Fix copyright ([5a2d4ea](, [IDF@c83678f](
- Add mDNS miss comment ([9de3f53](, [IDF@08e0813](
- freertos: remove FREERTOS_ASSERT option ([bcabc8e](, [IDF@7255497](
- Minor err print fix in socket-networking layer ([dfb27b3](, [IDF@f1b8f5c](
- unified errno format ([076c095](, [IDF@87506f4](
- always send A/AAAA records in announcements ([7dd0bc1](, [IDF@456f80b](
- filter instance name for ANY queries ([7e82a7c](, [IDF@5d0c473](
- Fix potential null deref reported by fuzzer test ([ae381b7](, [IDF@cb5653f](
- Minor fix of API description and API usage ([941dc5c](, [IDF@c297301](
- Added results count to MDNS ([525c649](, [IDF@f391d61](
- fix mdns server instance mismatch ([f0839d9](, [IDF@6173dd7](
- support multiple instance for mdns service txt set ([69902ea](, [IDF@50f6302](
- fix wrong PTR record count ([d0bbe88](, [IDF@5d3f815](
- Build & config: Remove leftover files from the unsupported "make" build system ([4a9d55e](, [IDF@766aa57](
- Build & config: Remove the "make" build system ([be2a924](, [IDF@9c1d4f5](
- freertos: update freertos folder structure to match upstream ([76fcd41](, [IDF@4846222](
- support service subtype ([fd8499c](, [IDF#5508](, [IDF@e7e8610](
- Fix parsing non-standard queries ([38b4fe2](, [IDF#7694](, [IDF@d16f9ba](
- allow mutiple instances with same service type ([b266062](, [IDF@b7a99f4](
- Update copyright header ([5e087d8](, [IDF@2a2b95b](
- Fix potential null dereference identified by fuzzer tests ([91a3d95](, [IDF@e7dabb1](
- components/bt: move config BT_RESERVE_DRAM from bluedroid to ESP32 controller ([6d6dd2b](, [IDF@b310c06](
- add notification callback for async APIs ([52306e9](, [IDF@986603c](
- add more mdns result attributes ([d37ab6d](, [IDF@76ec76c](
- Add host test using linux target ([5c55ea6](, [IDF@fc7e2d9](
- Implement mdns_networking using BSD sockets ([0c71c7b](, [IDF@73dfe84](
- fix crash when adding services without hostname set ([4c368c0](, [IDF@5e98772](
- Fix fuzzer IDF-mock layer ([af22753](, [IDF@619235c](
- Clean the main mdns module from lwip dependencies ([b0957e7](, [IDF@54e3294](
- Add asynchronous query API ([47c7266](, [IDF#7090](, [IDF@d81482d](
- Fix crashes reported by the fuzzer tests ([40da0d2](, [IDF@4a2e726](
- mdns/fuzzer: Fix non-instrumentation test to reproduce fuzzer issues ([5f6b6f9](, [IDF@dae8033](
- return ESP_OK rather than ERR_OK in API functions ([8a12082](, [IDF@2386113](
- fix memory leak in mdns_free when adding delegated hostnames ([46f28a8](, [IDF@0baee93](
- Support for One-Shot mDNS queries ([5a81eae](, [IDF@f167238](
- allow explicit txt value length ([2ddaee2](, [IDF@b4e0088](
- Fix crashes reported by the fuzzer ([27fc285](, [IDF@79ba738](
- Minor correction of the test code ([93e6efe](, [IDF@7d76245](
- Fix fuzzer from miss-interpreting adding services as timeouts ([bc4cda8](, [IDF@14099fe](
- fix test script delayed response ([8a8d58d](, [IDF@a4f2639](
- fix wrong SRV/PTR record handling ([402baeb](, [IDF@e613555](
- fix wrong service hostname after mangling ([9fa25ef](, [IDF@439b31d](
- fix empty address change announce packets ([121b525](, [IDF@7bbb72d](
- fix mdns probe/reply behavior ([418fb60](, [IDF@d2a5d25](
- make delegate host address a list ([4049b3b](, [IDF@2d34352](
- add remove delegate host api ([c882119](, [IDF@2174693](
- add mdns delegation ([1eb5df9](, [IDF@401ff56](
- fix memory free issue when repeating the query in reply ([b62b4b3](, [IDF@5f244c8](
- Fix of crash when wifi interface get deleted and mdns receives the packets ([4d8aec1](, [IDF#6973](, [IDF@03de74a](
- Docs: Added for lwip fuzzer tests ([6d64910](, [IDF@53c18a8](
- Fixed the ip header TTL to be correctly set to 255 ([ab3fa69](, [IDF@5cce919](
- Fix parsing answers with questions when instance name not set ([c3a5826](, [IDF#6598](, [IDF@3404945](
- Fix the resolver to correctly parse it's own non-strict answers ([cbcbe4f](, [IDF@b649603](
- Add MDNS_STRICT_MODE config option ([adc3430](, [IDF@0eee315](
- freertos: common config header ([c30617d](, [IDF@39cf818](
- Removed freeRTOS dependancies from fuzzer tests ([1e5eeb1](, [IDF@5571694](
- mDNS: Updated APIs description and shows the warning when hostname contains domain name during the query ([22c7c0a](, [IDF#6590](, [IDF@9f8d2b9](
- components: Use CONFIG_LWIP_IPV6 to strip IPv6 function in components ([1623c0e](, [IDF@da58235](
- add bound check when setting interface as duplicate ([b114ed6](, [IDF@2b9d2c0](
- mDNS: Fix of text length calculation when detecting a collision ([2ffd223](, [IDF@be0ae1e](
- global: fix sign-compare warnings ([1fe901f](, [IDF@753a929](
- lwip: Moved default SNTP API to esp_sntp.h ([2cf9fd8](, [IDF@76f6dd6](
- Allow resolve its own non-strict answers ([89439e0](, [IDF#6190](, [IDF@0693e17](
- mDNS: Fix of collision detection during txt length calculation ([becd5d0](, [IDF#6114](, [IDF@f33772c](
- esp32c3: Apply one-liner/small changes for ESP32-C3 ([0d7a309](, [IDF@5228d9f](
- test: fix several test build error ([1fdffbb](, [IDF@b7ecccd](
- freertos: Add RISC-V port ([988d120](, [IDF@87e13ba](
- Fix wrong mdns source address if lwIP IPv6 zones disabled ([fd47df3](, [IDF@7ac9761](
- Whitespace: Automated whitespace fixes (large commit) ([2cb3a6e](, [IDF@66fb5a2](
- test_compile_fuzzers: Fix include paths for host build ([825652f](, [IDF@98a0cc7](
- CI: Add a test to pre-check fuzzer tests compilation before weekly run ([fc53888](, [IDF@637f5c0](
- soc: descriptive part occupy whole component ([7635c04](, [IDF@79887fd](
- Coredump config option rename throughout IDF ([d5fe42b](, [IDF@20af94f](
- mdns, dns, dhcp, dhcps: update fuzzer test to work in CI ([e0bc60a](, [IDF@a43c06a](
- cmock: added cmock as component ([9772e49](, [IDF@20c068e](
- Support queries in responses in mDNS non-strict mode ([6021a88](, [IDF#5521](, [IDF@bcfa36d](
- Fix include query ID in reponses ([78f71ec](, [IDF#5574](, [IDF@f62e321](
- Allow config mDNS task stack size ([3319844](, [IDF@cf7e48c](
- Remove mbedtls dependency ([ac70c9a](, [IDF@f4a4549](
- limit the GOT_IP6_EVENT to only known network interfaces ([2b7d43e](, [IDF@ab8cab1](
- esp32: add implementation of esp_timer based on TG0 LAC timer ([4eb3e89](, [IDF@739eb05](
- fixed typos in the variable names and the comments ([b5e5a64](, [IDF@ecca39e](
- fix preset of esp_netif ptr for local interfaces ([6713ffe](, [IDF@09e36f9](
- fixed crash on event during deinit ([817c4fd](, [IDF@eaa2f12](
- respond to discovery with the proper pseudo name _services._dns-sd._udp ([8f0dc6d](, [IDF#4369](, [IDF@de17a14](
- fixed forgotten merge conflicts in debug code ([d20666f](, [IDF@d9433ef](
- add missing include of esp_task.h ([662a4ce](, [IDF@5884b80](
- add configuration values for task priority, affinity and internal service timeouts ([fb1de80](, [IDF@c6f38f0](
- tcpip_adapter: updated tcpip_adapter compatablity layer to include all public API and keep 100% backward compatibility update build of tcpip adapter when ethernet disabled ([1f35e9a](, [IDF@7f5cda1](
- update mdns to use esp-netif for mdns supported services such as STA, AP, ETH ([48b819b](, [IDF@19e24fe](
- esp_netif: Introduction of esp-netif component as a replacement of tcpip_adpter ([53e2aa3](, [IDF@ffe043b](
- examples: removed ip4addr_ntoa and used prefered IP2STR for displaying IP addresses ([3cc6446](, [IDF@ec9f245](
- esp_event, mdns: fixes for CONFIG_ETH_ENABLED=n ([248b11b](, [IDF@569ad75](
- build and link hello-world for esp32s2beta ([901124b](, [IDF@84b2f9f](
- fix crash for hostname queries ([f6ff165](, [IDF#4224](, [IDF@3d11700](
- fix possible race condition when checking DHCP status on WIFI_EVENT_STA_CONNECTED event. ([f44c569](, [IDF@7f410a0](
- use constant size of AAAA answer in mdns packets instead of deriving from lwip struct size, since the struct could contain also zones ([286c646](, [IDF@e5e31c5](
- esp_wifi: wifi support new event mechanism ([c70d527](, [IDF@003a987](
- fix missing bye packet if services removed with mdns_service_remove_all() or mdns_free() ([7cdf96c](, [IDF#3660](, [IDF@a001998](
- mdns_service_remove_all doesn't take an argument ([407875d](, [IDF@c2764f6](
- tools: Mass fixing of empty prototypes (for -Wstrict-prototypes) ([3e753f5](, [IDF@afbaf74](
- fix ignoring mdns packet with some invalid name entries in question field ([144d4ad](, [IDF@4bd4c7c](
- add esp_eth component ([680bad6](, [IDF@90c4827](
- components: use new component registration api ([7fb6686](, [IDF@9eccd7c](
- fix static analysis warnings ([4912bef](, [IDF@c34de4c](
- added initial suite of api unit tests ([181a22e](, [IDF@e680191](
- mdns tests: adapt mdns fuzzer test to compile with event loop library ([4172219](, [IDF@38d15cb](
- fixed mdns crashing on reception of txt packet without a corresponding service closes #2866 ([98d2c1a](, [IDF@af48977](
- use const char* for mdns txt items types to remove warning when assigning ([84cbb1f](, [IDF@c050a75](
- updated doxygen comments documenting mdns api ([4c6818e](, [IDF#1718](, [IDF@a851aac](
- update mdns_out_question_s to be in line with mdns_parsed_question_s struct ([c440114](, [IDF#1568](, [IDF@eddd5c4](
- use esp_event library to handle events ([6ea0ea9](, [IDF@a2d5952](
- fuzzer tests: update of mdns and lwip host compilation for fuzzer testing ([d9aec9f](, [IDF@bc60bbb](
- fix possible crash when probing on particular interface with duplicated service instances due to naming conflicts on network ([985e691](, [IDF@265e983](
- enable pcbs before starting service thread to avoid updating pcb's internal variables from concurent tasks ([75deebb](, [IDF@c87f0cb](
- fix possible deadlock on mdns deinit calling mdns_free() ([fdd27dc](, [IDF#1696](, [IDF@48b5501](
- mdsn: fix race condition in updating packet data from user task when failed to allocate or queue a new service ([2ec3b55](, [IDF@021dc5d](
- fix possible crash when packet scheduled to transmit contained service which might have been already removed ([450cbf0](, [IDF@67051a2](
- use binary semaphore instead of mutex when searching ([34f6d8d](, [IDF@eef0b50](
- fix memory leak in pbuf if tcpipadapter failed to get netif ([b6efc68](, [IDF@8462751](
- fix malfuctional query_txt ([90e4bab](, [IDF@1a02773](
- fix possible crash when mdns_free called while action queue not empty ([c546ab8](, [IDF@206b47c](
- fix memory leak when query for service receives multiple ptr entries for one instance ([6582b41](, [IDF@9a4da97](
- fix crash after init if no memory for task ([358d26c](, [IDF@a47768d](
- fixed crash on free undefined ptr after skipped strdup ([2ac83d0](, [IDF@e0a8044](
- Correct Kconfigs according to the coding style ([98e3171](, [IDF@37126d3](
- fix networking running udp_sendif from lwip thread ([2f85c07](, [IDF@f7d4a4b](
- fixed static memory leak ([b30a7fe](, [IDF@6bb68a5](
- check all mallocs for failure and add default hook to log error with free heap ([7a4fdad](, [IDF@c8cb4cd](
- resolve memory leak when txt record received multiple times ([b4e5742](, [IDF@a6b2b73](
- skip sending search when finished, not properly locked timer task ([2763bcd](, [IDF@31163f0](
- sending search packets also in probing and announcing state ([8cd0e8a](, [IDF@d16762a](
- fixed crashes on network changes ([9b3b41c](, [IDF@097282a](
- Update network code for mDNS to work with newest LwIP ([ea23007](, [IDF@3ec0e7e](
- bugfix: mdns_service_txt_set() wasn't allocating memory for TXT records ([0c17121](, [IDF@e5e2702](
- cmake: make main a component again ([67173f6](, [IDF@d9939ce](
- Feature/sync lwip as submodule ([fed787f](, [IDF@3578fe3](
- Fix a portion of the queries are issued with the wildcard query type ([b4ab30b](, [IDF@f3f0445](
- added CI job for AFL fuzzer tests ([dd71494](, [IDF@0c14764](
- Minor fix for mdns_service_remove() ([39de491](, [IDF@5c7eb7e](
- Replace all DOS line endings with Unix ([19acac7](, [IDF@a67d5d8](
- remove executable permission from source files ([98069f9](, [IDF@cb649e4](
- Fixed nullptr dereference in MDNS.c ([ad29d34](, [IDF@fffbf7b](
- MDNS-Fuzzer: AFL fuzzer tests for mdsn packet parser ([9f1be36](, [IDF@e983230](
- cmake: Add component dependency support ([c7701d4](, [IDF@1cb5712](
- cmake: Remove defaults for COMPONENT_SRCDIRS, COMPONENT_SRCS, COMPONENT_ADD_INCLUDEDIRS ([f1ccc40](, [IDF@4f1a856](
- build system: Initial cmake support, work in progress ([84bd1d7](, [IDF@c671a0c](
- fix the bug that in mdns test code redefine esp_err_t to uint32_t, which should be int32_t ([259d3fc](, [IDF@81e4cad](
- Fix exception when service is removed while there are pending packets that depend on it ([7784d00](, [IDF@421c6f1](
- Fix case where service is NULL and that will cause exception ([bce7d52](, [IDF@4fa130a](
- Fix issue with some mDNS parsers ([ef924f1](, [IDF@51dde19](
- Import mDNS changes ([ad8c92d](, [IDF@4bddbc0](
- Fix compilation errors when using gcc-7.2.0 for the crosstool-ng toolchain ([3aa605f](, [IDF@519edc3](
- components/mdns: wrong Message compression detect ([00a72b8](, [IDF@6e24566](
- fix leak after _mdns_create_service if we have a malloc error. ([907e7ee](, [IDF@b6b36bd](
- Use LwIP IPC for low-level API calls ([b367484](, [IDF@713964f](
- Add AFL fuzz test ([4a8582f](, [IDF@4c26227](
- implement fixes for issues found while fuzz testing ([75de31c](, [IDF@99d3990](
- add simple dns-sd meta query support ([4acf639](, [IDF@96e8a3c](
- address security issues with mDNS ([91bb509](, [IDF@c89e11c](
- Initial mDNS component and example ([7fbf8e5](, [IDF@dd3f18d](

readme of query_advertise example

                                        # mDNS example

Shows how to use mDNS to advertise and query services and hosts

## Example workflow

- mDNS is initialized with host name and instance name defined through the project configuration and `_http._tcp` service is added to be advertised
- A delegated host `esp32-delegated._local` is added and another `_http._tcp` service is added for this host.
- WiFi STA is started and trying to connect to the access point defined through the project configuration
- The system event handler is used to pass the network events to mDNS so the service is aware when the interface comes up or down
- GPIO0 (BOOT Button) is initialized as pulled-up input that can be monitored for button press
- Example task is started to check if the button is pressed so it can execute the mDNS queries defined

### Configure the project

* Open the project configuration menu (` menuconfig`)

* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu
* Set `mDNS Hostname` as host name prefix for the device and its instance name in `mDNS Instance Name`
* Disable `Resolve test services` to prevent the example from querying defined names/services on startup (cause warnings in example logs, as illustrated below)

### Build and Flash

Build the project and flash it to the board, then run monitor tool to view serial output:

``` -p PORT flash monitor

- Wait for WiFi to connect to your access point
- You can now ping the device at `[board-hostname].local`, where `[board-hostname]` is preconfigured hostname, `esp32-mdns` by default.
- You can also browse for `_http._tcp` on the same network to find the advertised service
- Pressing the BOOT button will start querying the local network for the predefined in `check_button` hosts and services
- Note that for purpose of CI tests, configuration options of `MDNS_RESOLVE_TEST_SERVICES` and `MDNS_ADD_MAC_TO_HOSTNAME` are available, but disabled by default. If enabled, then the hostname suffix of last 3 bytes from device MAC address is added, e.g. `esp32-mdns-80FFFF`, and a query for test service is issued.

(To exit the serial monitor, type ``Ctrl-]``.)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

## Example Output
I (0) cpu_start: Starting scheduler on APP CPU.
I (276) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (276) mdns-test: mdns hostname set to: [esp32-mdns]
I (286) wifi: wifi driver task: 3ffc2fa4, prio:23, stack:3584, core=0
I (286) wifi: wifi firmware version: a3be639
I (286) wifi: config NVS flash: enabled
I (296) wifi: config nano formating: disabled
I (296) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (306) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (336) wifi: Init dynamic tx buffer num: 32
I (336) wifi: Init data frame dynamic rx buffer num: 32
I (336) wifi: Init management frame dynamic rx buffer num: 32
I (346) wifi: Init static rx buffer size: 1600
I (346) wifi: Init static rx buffer num: 10
I (346) wifi: Init dynamic rx buffer num: 32
I (356) mdns-test: Setting WiFi configuration SSID myssid...
I (426) phy: phy_version: 4000, b6198fa, Sep  3 2018, 15:11:06, 0, 0
I (426) wifi: mode : sta (30:ae:a4:80:FF:FF)
I (426) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1756) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (2736) wifi: state: init -> auth (b0)
I (2756) wifi: state: auth -> assoc (0)
I (2766) wifi: state: assoc -> run (10)
I (2786) wifi: connected with myssid, channel 11
I (2786) wifi: pm start, type: 1

I (4786) event: sta ip:, mask:, gw:
I (21126) mdns-test: Query A: esp32.local
W (23176) mdns-test: ESP_ERR_NOT_FOUND: Host was not found!
I (23176) mdns-test: Query PTR: _arduino._tcp.local
W (26276) mdns-test: No results found!
I (26276) mdns-test: Query PTR: _http._tcp.local
1: Interface: STA, Type: V6
  PTR : HP Color LaserJet MFP M277dw (7C2E10)
  SRV : NPI7C2E10.local:80
  A   :
2: Interface: STA, Type: V4
  PTR : switch4e4919
  SRV : switch4e4919.local:80
  TXT : [1] path=/config/authentication_page.htm;
  A   :
I (29396) mdns-test: Query PTR: _printer._tcp.local
1: Interface: STA, Type: V6
  PTR : HP Color LaserJet MFP M277dw (7C2E10)
  SRV : NPI7C2E10.local:515
  A   :
2: Interface: STA, Type: V4
  PTR : HP Color LaserJet MFP M277dw (7C2E10)



Supports all targets

License: Apache-2.0

To add this component to your project, run: add-dependency "espressif/mdns^1.2.4"

or download archive


  • ESP-IDF >=5.0
  • Examples:


    more details

    To create a project from this example, run: create-project-from-example "espressif/mdns^1.2.4:query_advertise"

    or download archive


    • Downloaded in total
      Downloaded in total 1.2M times
    • Downloaded this version
      This version: 32.4k times


    espressif/mdns version: 1.2.4