Problem Statement
Today, when connecting to an MQTT broker using a hostname, DNS resolution happens implicitly and the returned IPs are used directly for connection. While applications can perform pre-validation of DNS results (e.g., resolving the hostname first and filtering out restricted IP ranges), there is currently no way to pass a filtered/approved list of IP addresses into the MQTT connection itself.
This creates a gap where:
This is particularly relevant for scenarios where clients must connect to arbitrary or user-provided endpoints, such as connectors.
Proposed Enhancement
Allow callers to inject a custom DNS resolver into the MQTT client so that:
-
DNS resolution occurs through caller-controlled logic
-
Restricted IPs can be filtered out during resolution
-
Only the approved IPs are returned and used for the connection attempt
Injecting the resolver would make DNS validation:
-
Seamless (part of normal resolution flow)
-
Safer (no mismatch between validation-time resolution and connect-time resolution)
-
More efficient (avoids redundant DNS lookups)
Problem Statement
Today, when connecting to an MQTT broker using a hostname, DNS resolution happens implicitly and the returned IPs are used directly for connection. While applications can perform pre-validation of DNS results (e.g., resolving the hostname first and filtering out restricted IP ranges), there is currently no way to pass a filtered/approved list of IP addresses into the MQTT connection itself.
This creates a gap where:
A hostname may be validated ahead of time
But a subsequent DNS resolution at connection time may still return a restricted IP
This is particularly relevant for scenarios where clients must connect to arbitrary or user-provided endpoints, such as connectors.
Proposed Enhancement
Allow callers to inject a custom DNS resolver into the MQTT client so that:
DNS resolution occurs through caller-controlled logic
Restricted IPs can be filtered out during resolution
Only the approved IPs are returned and used for the connection attempt
Injecting the resolver would make DNS validation:
Seamless (part of normal resolution flow)
Safer (no mismatch between validation-time resolution and connect-time resolution)
More efficient (avoids redundant DNS lookups)