Pion ICE supports Multicast DNS (mDNS) for local network discovery, allowing peers to exchange ICE candidates usingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pion/ice/llms.txt
Use this file to discover all available pages before exploring further.
.local hostnames instead of IP addresses. This enhances privacy by preventing IP address exposure in certain scenarios.
MulticastDNS Modes
ICE agents can operate in three different mDNS modes:mdns.go
Disabled Mode
In this mode, mDNS is completely disabled:- Local candidates use IP addresses
- Remote
.localcandidates are discarded with a warning
Query Only Mode
The agent can resolve remote.local addresses but publishes IP addresses for its own candidates:
- You want to accept connections from privacy-conscious peers using mDNS
- Your application doesn’t require IP address privacy
- You want maximum compatibility (IP addresses work everywhere)
Query and Gather Mode
Full mDNS support - both generate and resolve.local addresses:
- Privacy is important (hide IP addresses)
- Peers are on the same local network
- Both sides support mDNS
This is the most privacy-preserving mode but requires both peers to support mDNS and be on networks that allow multicast traffic.
mDNS Name Generation
When usingMulticastDNSModeQueryAndGather, Pion ICE generates a unique hostname following the mDNS ICE candidates specification:
mdns.go
Network Configuration
The mDNS server can be configured for specific network interfaces:IPv4 and IPv6 Support
mDNS operates on both IPv4 and IPv6:- IPv4:
224.0.0.251:5353(defined inmdns.DefaultAddressIPv4) - IPv6:
[ff02::fb]:5353(defined inmdns.DefaultAddressIPv6)
NetworkTypes configuration:
mdns.go
Candidate Resolution
When a remote candidate with a.local address is added, the agent automatically resolves it:
agent.go
Resolution happens asynchronously in a goroutine to avoid blocking the agent’s main loop.
Error Handling
If mDNS server initialization fails, Pion ICE automatically falls back to disabled mode:mdns.go
- Port 5353 is already in use
- Insufficient permissions to bind to multicast addresses
- Multicast traffic is blocked by firewall
- Network interface doesn’t support multicast
Use Cases
Local Development
mDNS is perfect for development environments where peers are on the same network:Privacy-Preserving Applications
Applications that prioritize user privacy can use mDNS to avoid exposing IP addresses in signaling:IoT and Local Device Discovery
IoT devices on a local network can discover each other using mDNS without requiring external STUN/TURN servers:Mixed Environments
For maximum compatibility, use query-only mode to support both traditional IP and mDNS peers:SDP Representation
mDNS candidates appear in SDP with.local hostnames:
Network Requirements
Firewall Configuration
Firewall Configuration
Allow UDP traffic on port 5353 for multicast addresses:
- IPv4:
224.0.0.251 - IPv6:
ff02::fb
Router Configuration
Router Configuration
Ensure your router/switch supports:
- IGMP (Internet Group Management Protocol) for IPv4 multicast
- MLD (Multicast Listener Discovery) for IPv6 multicast
Operating System Support
Operating System Support
All major operating systems support mDNS:
- Linux: Avahi daemon (usually pre-installed)
- macOS: Bonjour (built-in)
- Windows: Bonjour service (may need installation)
- iOS/Android: Native support
Debugging
Enable debug logging to troubleshoot mDNS issues:Failed to enable mDNS over IPv4/IPv6Remote mDNS candidate added, but mDNS is disabledFailed to resolve .local address
Reference
- mDNS Modes:
mdns.go:18- MulticastDNSMode enum - Name Generation:
mdns.go:33- generateMulticastDNSName function - Server Creation:
mdns.go:42- createMulticastDNS function - Candidate Resolution:
agent.go:955- mDNS candidate handling - Specification: draft-ietf-rtcweb-mdns-ice-candidates