The domain_validator plugin validates DNS query domain names for RFC 1035/1123 compliance and rejects malformed queries early, reducing upstream load and improving robustness.
The plugin validates domain names according to DNS standards:
--), except for Punycode A-labels (xn--...)REFUSED responseDEBUG levelWhen the web feature is enabled, this plugin triggers the following security events:
malformed_query: whenever a domain fails RFC validation rules.strict_mode (bool, default: true): enable strict RFC compliance mode
true: reject domains with consecutive hyphens (except Punycode)false: allow consecutive hyphens (more permissive)cache_size (number, default: 1000): maximum number of validation results to cache
0 to disable caching (not recommended)plugins:
- tag: validator
type: domain_validator
args:
strict_mode: true
cache_size: 2000
plugins:
- tag: validator
type: domain_validator
args:
strict_mode: false
cache_size: 1000
Place the domain_validator plugin very early in your pipeline (it has priority=2100 by default) to reject invalid queries before they reach expensive plugins like cache or forward:
plugins:
- type: domain_validator
tag: validator
args:
strict_mode: true
cache_size: 1000
- type: cache
tag: main_cache
args:
size: 2048
- type: forward
tag: upstream
args:
upstreams:
- addr: "8.8.8.8:53"
When the metrics feature is enabled, the plugin exposes Prometheus metrics:
dns_domain_validation_total{result}: total validation attempts by result type
result labels: valid, invalid_chars, invalid_length, invalid_formatdns_domain_validation_cache_hits_total: number of cache hitsdns_domain_validation_duration_seconds: histogram of validation durationEnsure all queries comply with DNS RFC standards before forwarding to upstream resolvers.
Cache validation results to reduce CPU overhead for frequently queried domains.
Prevent DNS tunneling attacks by rejecting malformed names early.
Symptom: Valid domains like xn--example-something are rejected.
Solution: Punycode A-labels (xn--...) are allowed even in strict mode. If other domains with consecutive hyphens are legitimate, set strict_mode: false:
args:
strict_mode: false
Symptom: CPU usage is high even with domain validation enabled.
Solution: Increase cache_size to cache more validation results:
args:
cache_size: 5000
strict_mode: true for security-focused deployments, false for international domain supportcache_size based on your query volume (1000-5000 is typical)Unlike domain_set or acl plugins, domain_validator focuses on structural RFC validation rather than policy-based filtering. It ensures queries are well-formed before they reach other plugins.
Use domain_validator for RFC compliance, and domain_set + black_hole for domain blocking/blocklisting.