Network
The resolvectl command
Resolves names and inspects the DNS settings of systemd-resolved.
Most useful options
-4, -6Requests only IPv4 (-4) or only IPv6 (-6) addresses when resolving a name-i, --interface= INTERFAZRuns the query on one interface, by name or index. Has no effect with system-wide DNS-p, --protocol= PROTOCOLOLimits the query to dns, llmnr or mdns. It can be repeated; help lists the values-t, --type= TIPOAsks for a specific record (A, AAAA, MX...) instead of the address of the name--legend= BOOLWith no, drops the headers and the response metadata. Useful in scripts--cname= BOOLWith no, a CNAME or DNAME met while resolving returns an error instead of being followed--no-pagerDoes not send the output to a pagerCopy-ready examples
$ resolvectl statusthe DNS servers in use, global and per interface.$ resolvectl query example.comresolves the name to its addresses and says which protocol delivered the answer.$ resolvectl --legend=no -t MX query yahoo.comonly the MX records, without headers, ready to process in a script.$ resolvectl flush-cachesempties the local cache of systemd-resolved. Useful after changing a DNS record.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| nope.invalid: resolve call failed: 'nope.invalid' not found | The name does not exist in DNS. It may be misspelled, or the search domain is not the one you expected. | Check the name and see the DNS servers in use with resolvectl status. |
Typical mistakes
- With -t or -c, single-label names do not use the search domains: write the full name (FQDN).
- Without systemd-resolved running, resolvectl cannot query anything, even when the network works.
- On Debian 12, resolvectl comes in the systemd-resolved package, which is installed separately. On Debian 11 it came inside the systemd package.
Differences from similar commands
- nslookup: queries the configured DNS server directly. resolvectl asks systemd-resolved, which uses its cache and its per-interface settings.
- dig: shows the full DNS answer, with timings and flags. resolvectl gives the resolved answer, with the protocol and whether the data is authenticated.
- host: translates names with a short output. resolvectl adds the interface and the protocol each piece of data came through.
FAQ
How do I get a fresh answer instead of a cached one?
Empty the cache with resolvectl flush-caches and run the query again. The new lookup can no longer use the cache you just emptied.
What does resolvectl statistics show?
Resolver counters: whether DNSSEC is enabled and available, and figures for resolutions and validations. reset-statistics sets them back to zero and needs root.
Can I request other record types, such as SRV or TLSA?
Yes. For SRV use service with the service type and the domain, for example resolvectl service _xmpp-server._tcp gmail.com. For TLS certificates, use tlsa.
More Network commands
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course