systemd-resolve
Resolve domain names to IP addresses
TLDR
View documentation for resolvectl
SYNOPSIS
systemd-resolve [OPTIONS...] [HOSTNAME|IP_ADDRESS]
PARAMETERS
-s, --status
Show the current DNS server status and resolver configuration.
-f, --flush-caches
Flush all DNS, LLMNR, and mDNS resolver caches.
--interface=IFACE
Specify the network interface to use for the query or configuration.
--set-dns=IP...
Set DNS servers for a specific network link (e.g., --link=eth0).
--set-domain=DOMAIN...
Set search domains for a specific network link.
--type=TYPE
Specify the DNS record type to query (e.g., A, AAAA, MX, PTR).
[HOSTNAME|IP_ADDRESS]
Perform a DNS lookup for the given hostname or IP address.
-h, --help
Show a help message and exit.
--version
Show version information and exit.
DESCRIPTION
systemd-resolve is a command-line utility for interacting with the systemd-resolved.service, which provides network name resolution for local applications. This service acts as a caching and validating DNS/DNSSEC resolver, as well as an LLMNR (Link-Local Multicast Name Resolution) and mDNS (Multicast DNS) responder. systemd-resolve allows users to inspect the current DNS configuration, view active DNS servers, flush the DNS cache, and perform specific hostname or IP address lookups. It plays a crucial role in managing the system's name resolution by handling the /etc/resolv.conf file, typically by symlinking it to a stub resolver file provided by systemd-resolved itself.
CAVEATS
systemd-resolve operates directly with the systemd-resolved.service. If this service is not running, the command will not function as expected.
While still functional, systemd-resolve is largely considered a legacy command. The resolvectl(1) command is the modern, preferred tool for interacting with systemd-resolved and offers a more comprehensive and user-friendly interface for configuration and queries.
COMMON USE CASES
Check the current DNS server configuration: systemd-resolve --status
Flush the DNS cache for troubleshooting: systemd-resolve --flush-caches
Resolve a specific hostname: systemd-resolve example.com
Resolve a hostname with a specific record type: systemd-resolve --type=MX example.com
INTERACTION WITH /ETC/RESOLV.CONF
systemd-resolved typically manages /etc/resolv.conf by creating a symlink from it to /run/systemd/resolve/stub-resolv.conf. This ensures that all applications querying DNS through glibc's resolver will use the local systemd-resolved stub listener.
HISTORY
systemd-resolve emerged as part of the broader systemd ecosystem, aiming to consolidate and standardize various system services, including network name resolution. It was introduced to manage the systemd-resolved daemon, which offers a more advanced and integrated approach to DNS, LLMNR, and mDNS compared to traditional methods relying solely on /etc/resolv.conf and separate DNS services. Over time, the functionality of systemd-resolve has largely been migrated to the resolvectl(1) utility, which is now the recommended command-line interface for systemd-resolved.
SEE ALSO
resolvectl(1), systemd-resolved(8), dig(1), host(1), nmcli(1), resolv.conf(5)