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 timedatectl Command: Check Time Zone and Time Synchronization

Linux timedatectl Command: Check Time Zone and Time Synchronization

Learn how to check Time Zone and Time Synchronization with the Linux timedatectl command, including practical examples, key options, and important precautions.

Linux mktemp Command: Create Secure Temporary Files and Directories

Linux mktemp Command: Create Secure Temporary Files and Directories

Learn how to create unpredictable temporary files and directories with Linux mktemp, use templates and TMPDIR, clean up with trap, and avoid unsafe dry runs.

Best Linux Distributions for Web Servers: Ubuntu, Debian, or Rocky Linux?

Best Linux Distributions for Web Servers: Ubuntu, Debian, or Rocky Linux?

Compare Ubuntu Server, Debian, and Rocky Linux for web hosting based on support lifecycle, package freshness, documentation, operational stability, and application requirements.

Linux journalctl Command: Read systemd Logs

Linux journalctl Command: Read systemd Logs

Learn how to read systemd Logs with the Linux journalctl command, including practical examples, key options, and important precautions.

Linux pgrep Command: Find Process IDs by Name or Criteria

Linux pgrep Command: Find Process IDs by Name or Criteria

Learn how to find Process IDs by Name or Criteria with the Linux pgrep command, including practical examples, key options, and important precautions.

Linux dpkg Command: Inspect and Install Local DEB Packages

Linux dpkg Command: Inspect and Install Local DEB Packages

Learn how to inspect and Install Local DEB Packages with the Linux dpkg 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 cp Command: Copy Files and Directories

Linux cp Command: Copy Files and Directories

Learn how to copy files and directories with Linux cp, control overwrites, preserve attributes, handle symlinks, and verify important copies.

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Use pwd, ls, cd, and tree to find your current location, inspect directories, navigate paths, and check where each command takes you.

Linux curl Command: Make URL Requests and Inspect HTTP Responses

Linux curl Command: Make URL Requests and Inspect HTTP Responses

Learn how to make URL Requests and Inspect HTTP Responses with the Linux curl command, including practical examples, key options, and important precautions.