The domain_validator plugin validates DNS query domain names for RFC compliance and filters invalid or malicious queries. It helps protect against DNS abuse, malformed queries, and can block specific domains using a blacklist.
The plugin validates domain names according to DNS standards:
--)xn--example)The blacklist supports three matching modes:
"example.com" blocks only example.com"example.com" blocks example.com, sub.example.com, deep.sub.example.com, etc."*.blocked.org" blocks sub.blocked.org, any.blocked.org, etc., but not blocked.org itselfREFUSED responseWARN levelDEBUG levelstrict_mode (bool, default: true): enable strict RFC compliance mode
true: reject domains with consecutive hyphensfalse: allow IDN-style domains (more permissive)cache_size (number, default: 1000): maximum number of validation results to cache
0 to disable caching (not recommended)blacklist (array of strings, default: []): list of domains to block
plugins:
- tag: validator
type: domain_validator
config:
strict_mode: true
cache_size: 2000
plugins:
- tag: validator
type: domain_validator
config:
strict_mode: true
cache_size: 1000
blacklist:
- "malicious.com" # Blocks malicious.com and *.malicious.com
- "tracking.example.com" # Blocks tracking.example.com and sub-domains
- "*.ads.com" # Blocks *.ads.com but not ads.com itself
- "phishing-site.org"
plugins:
- tag: validator
type: domain_validator
config:
strict_mode: false # Allow consecutive hyphens for punycode domains
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
config:
strict_mode: true
cache_size: 1000
blacklist:
- "malware.example.com"
- "*.ads.example.org"
- type: cache
tag: main_cache
config:
size: 2048
- type: forward
tag: upstream
config:
upstreams:
- "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_format, blacklisteddns_domain_validation_cache_hits_total: number of cache hitsdns_domain_validation_duration_seconds: histogram of validation durationBlock known malicious domains and prevent DNS tunneling attacks by rejecting malformed names.
Ensure all queries comply with DNS RFC standards before forwarding to upstream resolvers.
Use the blacklist to block advertising and tracking domains without requiring external zone files.
Cache validation results to reduce CPU overhead for frequently queried domains.
Symptom: Valid domains like xn--example-something are rejected.
Solution: Set strict_mode: false to allow consecutive hyphens required for punycode/IDN domains.
config:
strict_mode: false # Allow IDN domains
Symptom: CPU usage is high even with domain validation enabled.
Solution: Increase cache_size to cache more validation results:
config:
cache_size: 5000 # Increase from default 1000
Symptom: Blacklisted domains are still being resolved.
Solution:
WARN messages about rejected domains*.example.com doesn’t block example.com itself (use both if needed)config:
blacklist:
- "ads.example.com" # Blocks ads.example.com and subdomains
- "*.ads.example.com" # Redundant with suffix match above
strict_mode: true for security-focused deployments, false for international domain supportcache_size based on your query volume (1000-5000 is typical)Unlike ACL or domain set plugins, domain_validator focuses on structural validation rather than policy-based filtering. It ensures queries are well-formed before they reach other plugins.
Use domain_validator for RFC compliance and basic security, and acl/domain_set for policy-based allow/deny rules.