lazydns

Domain Validator Plugin

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.

Key features

Validation rules

The plugin validates domain names according to DNS standards:

Basic validation

Strict mode (default)

Lenient mode

Behavior details

Audit Integration

When the web feature is enabled, this plugin triggers the following security events:

Configuration options

Example configuration

Basic usage (strict mode)

plugins:
  - tag: validator
    type: domain_validator
    args:
      strict_mode: true
      cache_size: 2000

Lenient mode (for IDN support)

plugins:
  - tag: validator
    type: domain_validator
    args:
      strict_mode: false
      cache_size: 1000

Typical pipeline placement

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"

Metrics (when enabled)

When the metrics feature is enabled, the plugin exposes Prometheus metrics:

Use cases

1. Compliance enforcement

Ensure all queries comply with DNS RFC standards before forwarding to upstream resolvers.

2. Performance optimization

Cache validation results to reduce CPU overhead for frequently queried domains.

3. Security filtering

Prevent DNS tunneling attacks by rejecting malformed names early.

Troubleshooting

Legitimate domains are being rejected

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

High CPU usage

Symptom: CPU usage is high even with domain validation enabled.

Solution: Increase cache_size to cache more validation results:

args:
  cache_size: 5000

Best practices

  1. Place early in pipeline: The validator should run before cache and forward plugins to reject queries as early as possible
  2. Use appropriate mode: Enable strict_mode: true for security-focused deployments, false for international domain support
  3. Size cache appropriately: Set cache_size based on your query volume (1000-5000 is typical)
  4. Monitor metrics: Track validation rejections to identify potential issues or attacks

Performance notes

Differences from similar plugins

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.