mdns – Multicast Domain Name Service

The mdns module provides basic support for multicast domain name services. Basic use provides hostname resolution under the .local TLD. This module also supports DNS Service Discovery that allows for discovering other hosts that provide a desired service.

Available on these boards
  • 01Space 0.42 OLED ESP32C3
  • AITHinker ESP32-C3S_Kit
  • AITHinker ESP32-C3S_Kit_2M
  • ATMegaZero ESP32-S2
  • Adafruit Camera
  • Adafruit Feather ESP32 V2
  • Adafruit Feather ESP32-C6 4MB Flash No PSRAM
  • Adafruit Feather ESP32-S2 Reverse TFT
  • Adafruit Feather ESP32-S2 TFT
  • Adafruit Feather ESP32-S3 Reverse TFT
  • Adafruit Feather ESP32-S3 TFT
  • Adafruit Feather ESP32S2
  • Adafruit Feather ESP32S3 4MB Flash 2MB PSRAM
  • Adafruit Feather ESP32S3 No PSRAM
  • Adafruit Feather HUZZAH32
  • Adafruit FunHouse
  • Adafruit HUZZAH32 Breakout
  • Adafruit ItsyBitsy ESP32
  • Adafruit MagTag
  • Adafruit MatrixPortal S3
  • Adafruit Metro ESP32S2
  • Adafruit Metro ESP32S3
  • Adafruit QT Py ESP32 PICO
  • Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM
  • Adafruit QT Py ESP32-S3 no psram
  • Adafruit QT Py ESP32C3
  • Adafruit QT Py ESP32S2
  • Adafruit-Qualia-S3-RGB666
  • Arduino Nano ESP32
  • Artisense Reference Design RD00
  • BLING!
  • BPI-Bit-S2
  • BPI-Leaf-S3
  • BPI-PicoW-S3
  • BastWiFi
  • Bee-Data-Logger
  • Bee-Motion-S3
  • Bee-S3
  • BlizzardS3
  • CRCibernetica IdeaBoard
  • ColumbiaDSL-Sensor-Board-V1
  • CrumpS2
  • Cytron EDU PICO W
  • Cytron Maker Feather AIoT S3
  • DFRobot Beetle ESP32-C3
  • DFRobot FireBeetle 2 ESP32-S3
  • Deneyap Kart
  • Deneyap Kart 1A
  • Deneyap Kart 1A v2
  • Deneyap Kart G
  • Deneyap Mini
  • Deneyap Mini v2
  • ES3ink
  • ESP 12k NodeMCU
  • ESP32 Devkit V1
  • ESP32-C3-DevKitM-1
  • ESP32-C6-DevKitC-1-N8
  • ESP32-C6-DevKitM-1
  • ESP32-S2-DevKitC-1-N4
  • ESP32-S2-DevKitC-1-N4R2
  • ESP32-S2-DevKitC-1-N8R2
  • ESP32-S3-Box-2.5
  • ESP32-S3-Box-Lite
  • ESP32-S3-DevKitC-1-N32R8
  • ESP32-S3-DevKitC-1-N8
  • ESP32-S3-DevKitC-1-N8R2
  • ESP32-S3-DevKitC-1-N8R8
  • ESP32-S3-DevKitC-1-N8R8-with-HACKTABLET
  • ESP32-S3-DevKitM-1-N8
  • ESP32-S3-EYE
  • ESP32-S3-USB-OTG-N8
  • Espressif ESP32 DevKitc V4 WROOM-32E
  • Espressif ESP32 DevKitc V4 WROVER
  • Espressif ESP32-EYE
  • Espressif ESP32-LyraT
  • Espressif-ESP32-S3-LCD-EV-Board
  • FeatherS2
  • FeatherS2 Neo
  • FeatherS2 PreRelease
  • FeatherS3
  • Flipper Zero Wi-Fi Dev
  • Franzininho WIFI w/Wroom
  • Franzininho WIFI w/Wrover
  • Gravitech Cucumber M
  • Gravitech Cucumber MS
  • Gravitech Cucumber R
  • Gravitech Cucumber RS
  • HMI-DevKit-1.1
  • Hardkernel Odroid Go
  • Heltec ESP32-S3-WIFI-LoRa-V3
  • HexKyS2
  • IoTs2
  • Kaluga 1
  • LILYGO T-DECK
  • LILYGO T-DISPLAY S3 v1.2
  • LILYGO TEMBED ESP32S3
  • LILYGO TTGO T-01C3
  • LILYGO TTGO T-DISPLAY v1.1
  • LILYGO TTGO T-DISPLAY v1.1 4M
  • LILYGO TTGO T-OI PLUS
  • LILYGO TTGO T8 ESP32-S2
  • LILYGO TTGO T8 ESP32-S2 w/Display
  • LOLIN S3 16MB Flash 8MB PSRAM
  • LOLIN S3 MINI 4MB Flash 2MB PSRAM
  • LOLIN S3 PRO 16MB Flash 8MB PSRAM
  • Lilygo T-watch 2020 V3
  • Luatos Core-ESP32C3
  • M5 Stack Cardputer
  • M5STACK STAMP-C3
  • M5Stack Atom Echo
  • M5Stack Atom Lite
  • M5Stack Atom Matrix
  • M5Stack Atom U
  • M5Stack AtomS3
  • M5Stack AtomS3 Lite
  • M5Stack AtomS3U
  • M5Stack Core Basic
  • M5Stack Core Fire
  • M5Stack Core2
  • M5Stack Dial
  • M5Stack M5Paper
  • M5Stack Stick C
  • M5Stack Stick C Plus
  • M5Stack Timer Camera X
  • MORPHEANS MorphESP-240
  • MagiClick S3 N4R2
  • Maker badge by Czech maker
  • MakerFabs-ESP32-S3-Parallel-TFT-With-Touch-7inch
  • MicroDev microC3
  • MicroDev microS2
  • MixGo CE
  • NanoS3
  • Neuron
  • Oak Dev Tech PixelWing ESP32S2
  • Oxocard Artwork
  • Oxocard Connect
  • Oxocard Galaxy
  • Oxocard Science
  • Pajenicko PicoPad
  • Pimoroni Badger 2040 W
  • Pimoroni Inky Frame 5.7
  • Pimoroni Inky Frame 7.3
  • Pimoroni Pico DV Base W
  • Pimoroni Plasma 2040W
  • ProS3
  • Raspberry Pi Pico W
  • S2Mini
  • S2Pico
  • Saola 1 w/Wroom
  • Saola 1 w/Wrover
  • Seeed Studio XIAO ESP32C3
  • TTGO T8 ESP32-S2-WROOM
  • Targett Module Clip w/Wroom
  • Targett Module Clip w/Wrover
  • TinyC6
  • TinyPICO
  • TinyPICO Nano
  • TinyS2
  • TinyS3
  • TinyWATCH S3
  • VCC-GND YD-ESP32-S3 (N16R8)
  • VCC-GND YD-ESP32-S3 (N8R8)
  • Waveshare ESP32-S2-Pico
  • Waveshare ESP32-S2-Pico-LCD
  • Waveshare ESP32-S3-Pico
  • Waveshare ESP32-S3-Zero
  • WeAct ESP32-C6 (4MB)
  • WeAct ESP32-C6 (8MB)
  • Wemos Lolin C3 Mini" // from Wemos MP
  • Wemos Lolin C3 Pico" // from Wemos MP
  • nanoESP32-S2 w/Wrover
  • nanoESP32-S2 w/Wroom
  • senseBox MCU-S2 ESP32S2

class mdns.RemoteService

Encapsulates information about a remote service that was found during a search. This object may only be created by a mdns.Server. It has no user-visible constructor.

Cannot be instantiated directly. Use mdns.Server.find.

hostname: str

The hostname of the device (read-only),.

instance_name: str

The human readable instance name for the service. (read-only)

service_type: str

The service type string such as _http. (read-only)

protocol: str

The protocol string such as _tcp. (read-only)

port: int

Port number used for the service. (read-only)

ipv4_address: ipaddress.IPv4Address | None

IP v4 Address of the remote service. None if no A records are found.

__del__() None

Deletes the RemoteService object.

class mdns.Server(network_interface: wifi.Radio)

The MDNS Server responds to queries for this device’s information and allows for querying other devices.

Constructs or returns the mdns.Server for the given network_interface. (CircuitPython may already be using it.) Only native interfaces are currently supported.

hostname: str

Hostname resolvable as <hostname>.local in addition to circuitpython.local. Make sure this is unique across all devices on the network. It defaults to cpy-###### where ###### is the hex digits of the last three bytes of the mac address.

instance_name: str

Human readable name to describe the device.

deinit() None

Stops the server

find(service_type: str, protocol: str, *, timeout: float = 1) Tuple[RemoteService]

Find all locally available remote services with the given service type and protocol.

This doesn’t allow for direct hostname lookup. To do that, use socketpool.SocketPool.getaddrinfo().

Parameters:
  • service_type (str) – The service type such as “_http”

  • protocol (str) – The service protocol such as “_tcp”

  • timeout (float/int) – Time to wait for responses

advertise_service(*, service_type: str, protocol: str, port: int) None

Respond to queries for the given service with the given port.

service_type and protocol can only occur on one port. Any call after the first will update the entry’s port.

If web workflow is active, the port it uses can’t also be used to advertise a service.

Limitations: Publishing up to 32 TXT records is only supported on the RP2040 Pico W board at this time.

Parameters:
  • service_type (str) – The service type such as “_http”

  • protocol (str) – The service protocol such as “_tcp”

  • port (int) – The port used by the service

  • txt_records (Sequence[str]) – An optional sequence of strings to serve as TXT records along with the service