Linux resolvectl Command: Inspect systemd DNS Resolution

resolvectl checks the DNS servers used by systemd-resolved, per-link domain settings, and name resolution results. It is used when investigating DNS issues in a systemd-resolved environment.

What is the resolvectl command?

Each link can use different DNS servers or search domains, and split DNS can be applied with VPNs. status shows overall and per-link settings, while query shows name resolution results via resolved. This tool does not apply to systems that do not use systemd-resolved.

Basic syntax

resolvectl [command] [name or link]

Installed implementations and options may vary depending on the distribution. Check the description of the current system with man resolvectl.

Examples

Checking DNS settings

Reads DNS server and domain information for both the whole system and per-interface.

resolvectl status

Name resolution test

Checks how domains are resolved through the current resolved path.

resolvectl query example.com

Check query statistics

Look at cache and processing related statistics.

resolvectl statistics

Distinguishing System DNS and Interface DNS

resolvectl status shows the DNS servers, domains, and per-interface settings managed by systemd-resolved.

resolvectl status

Part of the example output (server addresses are for illustration purposes):

Global
    Current DNS Server: 192.0.2.53
Link 2 (eth0)
    DNS Servers: 192.0.2.53

If global settings and per-link settings exist simultaneously, the server actually used for a query can vary according to domain routing rules. Check the query result with resolvectl query example.com. On distributions that do not use systemd-resolved, the command may not exist or may not match the current DNS configuration.

Main Options and Format

Options/Format Description
status Display DNS settings per link or overall.
query name Resolve a host name or address.
statistics Display DNS query statistics.
dns [link] Check or set DNS servers per link.
domain [link] Check or set the search and routing domains.
flush-caches Clear the DNS cache. This affects diagnostic results.

Precautions when using

If you change settings like resolvectl dns interface server, the DNS query path may change, so distinguish between querying and changing. NetworkManager or DHCP may overwrite the values again. Do not judge the entire split DNS policy based solely on the contents of /etc/resolv.conf.

Frequently Asked Questions

What if the resolvectl command is missing or does not work?

The system in use may not use systemd-resolved. First, check how the actual DNS management service is connected to /etc/resolv.conf.

Official Documentation

You can check the exact behavior of options and implementation differences in the official resolvectl documentation.

More in This Category
Linux resolvectl Command: Inspect systemd DNS Resolution

Linux resolvectl Command: Inspect systemd DNS Resolution

Learn how to inspect systemd DNS Resolution with the Linux resolvectl command, including practical examples, key options, and important precautions.

Linux mv Command: Move and Rename Files and Directories

Linux mv Command: Move and Rename Files and Directories

Learn how to move and rename files or directories with Linux mv, avoid unwanted overwrites, clarify destination paths, and handle cross-filesystem moves.

Linux dirname Command: Extract the Directory Part of a Path

Linux dirname Command: Extract the Directory Part of a Path

Learn how to use the Linux dirname command to remove the final component of a path and return its directory portion, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.

Linux uname Command: Check Kernel and System Architecture

Linux uname Command: Check Kernel and System Architecture

Learn how to check Kernel and System Architecture with the Linux uname command, including practical examples, key options, and important precautions.

Linux rmdir Command: Remove Empty Directories

Linux rmdir Command: Remove Empty Directories

Learn how to remove empty directories with Linux rmdir, delete empty parent paths, diagnose failures, and understand when rm -r is different.

Linux scp Command: Copy Files over SSH

Linux scp Command: Copy Files over SSH

Learn how to copy Files over SSH with the Linux scp command, including practical examples, key options, and important precautions.

Linux apk Command: Manage Packages on Alpine Linux

Linux apk Command: Manage Packages on Alpine Linux

Learn how to manage Packages on Alpine Linux with the Linux apk command, including practical examples, key options, and important precautions.

Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux tac Command: Print Lines in Reverse Order

Linux tac Command: Print Lines in Reverse Order

Learn how Linux tac prints records from last to first, handles multiple files and custom separators, and helps inspect recent log entries in reverse order.