You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Production-ready systemd-resolved configuration for Debian and Ubuntu. Takes control of DNS resolution, DNSSEC validation, DNS-over-TLS, DNS Service Discovery, and name service switching—so you don't have to fight with /etc/resolv.conf ever again.
License
MIT
Why Use This Role?
The Problem: Linux DNS configuration is fragmented. NetworkManager, systemd-resolved, resolvconf, and direct /etc/resolv.conf edits all compete. VPNs, containers, and cloud-init add more chaos. The result: DNS that works until it mysteriously doesn't.
The Solution: This role takes an opinionated stance—systemd-resolved is the single source of truth. It handles:
Package management: Installs systemd-resolved and removes conflicting resolvers
Secure defaults: DNSSEC validation and DNS-over-TLS enabled out of the box
Split-horizon DNS: Route specific domains to different DNS servers (VPNs, internal networks)
Multi-homed hosts: Per-interface DNS configuration that actually works
DNS Service Discovery: Advertise services on the local network via mDNS
Production hardening: LLMNR disabled by default to prevent credential harvesting
Observable: Prometheus metrics exported for every configuration knob
Version-aware: Auto-detects systemd version, skips unsupported features gracefully
Quick Start
# Basic: Use Cloudflare DNS with DNSSEC and DoT
- hosts: serversroles:
- role: dnsvars:
dns_servers:
- 1.1.1.1
- 1.0.0.1
# DNS-SD: Advertise services on the local network
- hosts: serversroles:
- role: dnsvars:
dns_mdns: truedns_mdns_interfaces:
- eth0dns_sd_enabled: truedns_sd_services:
- name: "%H Web Server"type: "_http._tcp"port: 80
- name: "Home Assistant on %H"type: "_home-assistant._tcp"port: 8123
Security & Compliance
This role is designed to meet strict security and compliance requirements (NIST 800-53, PCI DSS 4.0).
See COMPLIANCE.md for a detailed control mapping and feature explanation.
Requirements
Requirement
Version
systemd
243+ (basic), 250+ (all features)
Platform
Debian 11+, Ubuntu 22.04+
Ansible
2.15+
Collections
ansible.utils
Platform Support
Distribution
Version
systemd
Feature Support
Distribution
Version
systemd
Feature Support
-------------
---------
---------
-----------------
Debian
14 (Forky)
258+
Full
Debian
13 (Trixie)
256
Full
Debian
12 (Bookworm)
252
Full
Debian
11 (Bullseye)
247
Limited*
Ubuntu
25.10 (Plucky)
258+
Full
Ubuntu
24.04 (Noble)
255
Full
Ubuntu
22.04 (Jammy)
249
Limited*
Rocky Linux
10
256+
Full (via NetworkManager)
Rocky Linux
9
252
Full (via NetworkManager)
Rocky Linux
8
239
Limited* (via NetworkManager)
Fedora
43
258+
Full (via NetworkManager)
*Limited: No StaleRetentionSec, CacheFromLocalhost. Role auto-detects and skips.
RHEL / Rocky Linux Support
On RHEL-based systems (Rocky, Alma, Fedora), NetworkManager is the default network renderer. This role automatically configures NetworkManager to use systemd-resolved as its DNS backend by creating /etc/NetworkManager/conf.d/dns.conf.
Note: Ensure NetworkManager package is installed (default on minimal installs).
Note: This role manages the systemd-resolved service, but DNS settings (search domains, servers) pushed via DHCP will be handled by NetworkManager and passed to resolved.
Role Variables
Core Settings
Variable
Default
Description
dns_enabled
true
Enable/disable this role
dns_resolved_enabled
true
Enable systemd-resolved service
dns_install_package
true
Install systemd-resolved package
dns_disable_conflicts
true
Disable conflicting resolvers
dns_config_filename
dns.conf
Config file in resolved.conf.d
Conflict Resolution
Variable
Default
Description
dns_remove_resolvconf
true
Remove resolvconf package
dns_disable_avahi
{{ dns_sd_enabled }}
Disable avahi-daemon (when DNS-SD enabled)
dns_disable_dnsmasq
false
Disable dnsmasq
dns_disable_unbound
false
Disable unbound
DNS Servers
Variable
Default
Description
dns_servers
[]
Primary DNS servers (empty = DHCP/network defaults)
dns_fallback_servers
['1.1.1.1', '8.8.8.8']
Fallback DNS servers
dns_domains
[]
Search domains
Per-Link DNS
Variable
Default
Description
dns_link_dns
[]
Per-interface DNS and routing domains (runtime only)
Security
Variable
Default
Description
dns_dnssec
allow-downgrade
DNSSEC mode: true, false, allow-downgrade
dns_over_tls
opportunistic
DoT mode: true, opportunistic, false
dns_llmnr
false
LLMNR (disabled for security)
dns_validate_ips
true
Validate IP addresses before deployment
Caching
Variable
Default
Description
dns_cache
true
Enable DNS caching
dns_stale_retention_sec
0
Serve stale records when upstream fails [systemd 246+]