resolvectl — systemd DNS status check
💬 "resolvectl Command"
The resolvectl command is a systemd DNS state checker for checking and managing the DNS settings and cache of systemd-resolved. It is used instead of /etc/resolv.conf.
It checks DNS servers and search domains per interface. DNS cache lookup and flushing is possible.
- Concept: Checks DNS servers and search domains per interface.
- Key Features: DNS cache lookup and flushing is possible.
- Advantage: Checks DNSSEC validation status.
- Usage: Manages DNS-over-TLS settings.
Installation and Download
The resolvectl package is installed via a package manager or an official script.
| Environment | Command |
|---|---|
| Built-in with systemd (235+) | resolvectl status |
| Older versions (below 235) | Uses the name systemd-resolve |
| Activation | sudo systemctl enable --now systemd-resolved |
| Verification | resolvectl --version |
Installation is verified with resolvectl --version.
Commonly Used Options
| Option | Description |
|---|---|
| resolvectl status | Displays the entire current DNS configuration |
| resolvectl query <domain> | Queries DNS for a specific domain |
| resolvectl flush-caches | Flushes the DNS cache |
| resolvectl statistics | Displays DNS query statistics |
| resolvectl revert <iface> | Reverts the DNS settings for an interface |
Top 3 Essential Command Combinations
resolvectl status— Check which DNS server is being usedresolvectl query example.com— Trace the DNS resolution pathresolvectl flush-caches— Resolve cache-related issues
💬 "Show me an example of using resolvectl on a real server"
Here is a step-by-step summary of common situations encountered on production servers.
Step 1: Verify Installation
Check the active status of systemd-resolved.
resolvectl --version && systemctl status systemd-resolved
Step 2: Check DNS Configuration
Check the current DNS servers.
resolvectl status
Step 3: Test Resolution
Check the resolution for a specific domain.
resolvectl query example.com
Actual Execution Screen
This is the result of checking the current DNS configuration with resolvectl status.
!resolvectl command execution result
Production server
How It Is Used in Practice
1. Tracing DNS Paths
Situation — Finding the cause when a specific domain fails to resolve.
resolvectl query example.com
Result — Shows which DNS server responded and which link's configuration was involved.
Key Point — This information cannot be obtained by just looking at /etc/resolv.conf.
2. Cache Flushing
Situation — Flushing the cache when DNS resolution is intermittent.
resolvectl flush-caches && resolvectl query example.com
Result — The cache is cleared, and a new resolution is attempted.
Key Point — Be cautious of sudden traffic spikes during operating hours.
Actual Execution Screen
This is the result of checking resolution and statistics with resolvectl query and statistics.
!resolvectl command execution result 2
Production server
Points of Caution
- If systemd-resolved is disabled, resolvectl will not work.
- On older versions (below 235), the command name is systemd-resolve.
- flush-caches invalidates the DNS cache for all clients. Exercise caution during operating hours.
Source (HTML): https://games.aidebatehub.com/programs/linux/network/resolvectl.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments