mDNS: Multicast Domain Name System


Sming provides the mDNS::Responder class to allow applications to advertise themselves on the local network.

To use:

  1. Add COMPONENT_DEPENDS += MDNS to your application file.

  2. Add these lines to your application:

    #include <Mdns/Responder.h>
    static mDNS::Responder responder;
    // Call when IP address has been obtained
    void startmDNS()

This will advertise the device as myhostname.local.

To provide a custom service, implement a mDNS::Service class and call mDNS::Responder::addService().

See the UDP Server mDNS sample application.


This library also provides support for device discovery using a separate set of classes, based on the mDNS::Server. See Basic MDNS for an example.


For linux, you can use avahi to perform mDNS queries and confirm output is as expected:

sudo apt install avahi
avahi-browse --all -r


API Documentation

namespace mDNS


using ResourceType = Resource::Type


void printQuestion(Print &p, Question &question)
void printAnswer(Print &p, Answer &answer)
void printMessage(Print &p, Message &message)


constexpr uint32_t MDNS_IP = {0xFB0000E0}
constexpr uint16_t MDNS_TARGET_PORT = {5353}
constexpr uint16_t MDNS_SOURCE_PORT = {5353}
constexpr uint16_t MDNS_TTL = {255}
constexpr uint16_t MAX_PACKET_SIZE = {1024}
Server server
class Answer : public LinkedObjectTemplate<Answer>
#include <Answer.h>

A single mDNS Answer.

class Handler : public LinkedObjectTemplate<Handler>
#include <Handler.h>

Virtual base class used for chaining message handlers.

Subclassed by mDNS::Responder

class Message
#include <Message.h>

Encapsulates a message packet for flexible introspection.

Subclassed by mDNS::Request

class Name
#include <Name.h>

Encoded DNS name.

mDNS-SD names are represented as instance.service.domain. See

Instance names should be friendly and not attempt to be unique. See

Example: “UDP Server._http._tcp.local” instance: “UDP Server” service: “_http._tcp” name: “http” protocol: Protocol::Tcp domain: “local”

class Question : public LinkedObjectTemplate<Question>
#include <Question.h>

A single mDNS Question.

class Request : public mDNS::Message
#include <Request.h>

Subclassed by mDNS::Query, mDNS::Reply

class Query : public mDNS::Request
#include <Request.h>
class Reply : public mDNS::Request
#include <Request.h>
class Responder : public mDNS::Handler
#include <Responder.h>

Special name for querying list of services.

class Server : protected UdpConnection
#include <Server.h>

Locates mDNS services by issuing queries.

class Service : public LinkedObjectTemplate<Service>
#include <Service.h>

Describes a basic service.

The default methods translate to a DNS-SD name of “Sming._http._tcp.local”. See :cpp:class:mDNS::Name for a description of how names are defined.

namespace Resource


enum class Type : uint16_t


enumerator XX
class Record
#include <Resource.h>

Resource Record with no specific type.

Subclassed by mDNS::Resource::A, mDNS::Resource::AAAA, mDNS::Resource::HINFO, mDNS::Resource::PTR, mDNS::Resource::SRV, mDNS::Resource::TXT

class A : public mDNS::Resource::Record
#include <Resource.h>

A’ record containing IP4 address

class PTR : public mDNS::Resource::Record
#include <Resource.h>

PTR’ record containing pointer to a canonical name

class HINFO : public mDNS::Resource::Record
#include <Resource.h>

HINFO’ record containing Host information

class TXT : public mDNS::Resource::Record
#include <Resource.h>

TXT’ record containing attribute list

Originally for arbitrary human-readable text in a DNS record. Content is a set of name=value pairs. Value can be binary.

class AAAA : public mDNS::Resource::Record
#include <Resource.h>

AAAA’ record containing 128-bit IPv6 address

class SRV : public mDNS::Resource::Record
#include <Resource.h>

SRVService Locator record


Used by

SoC support

  • esp32

  • esp32c2

  • esp32c3

  • esp32s2

  • esp32s3

  • esp8266

  • host

  • rp2040