$linuxjunkies
>

resolvectl(1)

Resolve hostnames, IP addresses, resource records, and services using systemd-resolved.

UbuntuDebianFedoraArch

Synopsis

resolvectl [OPTION...] {COMMAND} [NAME|ADDRESS]...

Description

resolvectl is a command-line tool for querying the DNS resolver service managed by systemd-resolved. It allows you to look up hostnames, reverse-resolve IP addresses, query DNS records, and inspect resolver configuration and statistics.

Results are shown for all configured DNS servers and link-specific settings. The tool can display detailed information about which DNS server answered each query and how long lookups took.

Common options

FlagWhat it does
-4Query IPv4 addresses only (A records)
-6Query IPv6 addresses only (AAAA records)
-i INTERFACEQuery using a specific network interface
-p PROTOCOLRestrict queries to specified protocol (dns, llmnr, mdns)
-t TYPEQuery specific DNS record type (A, AAAA, MX, NS, TXT, SOA, etc.)
-c CLASSQuery specific DNS class (IN, CH, HS)
--no-pagerDo not pipe output into a pager
--legend=yes|noShow or hide headers and legend information
-j, --json=short|prettyOutput results in JSON format
--statisticsShow resolver cache statistics and hit rates

Examples

Resolve hostname to IPv4 and IPv6 addresses using all configured DNS servers

resolvectl query example.com

Resolve hostname to IPv4 addresses only

resolvectl -4 query google.com

Perform reverse DNS lookup on IP address 8.8.8.8

resolvectl reverse 8.8.8.8

Query mail exchange (MX) records for a domain

resolvectl query example.com -t MX

Query text (TXT) records for a domain, useful for SPF and DKIM checks

resolvectl query example.com -t TXT

Display DNS resolver configuration and status for all network interfaces

resolvectl status

Show DNS cache statistics including total queries and cache hit rate

resolvectl statistics

Resolve hostname using DNS servers configured for eth0 interface only

resolvectl -i eth0 query example.com

Related commands