Resolvectl Command Examples (with examples)
- Linux
- November 5, 2023
Show DNS settings
The resolvectl status
command can be used to display the current DNS settings on the system.
resolvectl status
Motivation: This command can be useful when troubleshooting network connectivity issues or verifying the DNS configuration on a system.
Explanation: This command retrieves and displays the current DNS settings, including the DNS server addresses and search domains.
Example Output:
Global
Scope: global
DNSSEC: no
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
18.19.20.21.in-addr.arpa
32.172.in-addr.arpa
101.200.100.10.in-addr.arpa
Resolve the IPv4 and IPv6 addresses for one or more domains
The resolvectl query
command can be used to resolve the IPv4 and IPv6 addresses for one or more domains.
resolvectl query domain1 domain2 ...
Motivation: This command allows you to quickly check the IP addresses associated with a domain name, which can be helpful for network troubleshooting or verifying DNS records.
Explanation: This command queries the DNS resolver for the IPv4 and IPv6 addresses associated with the specified domains.
Example Output:
domain1:
192.168.0.1
2001:db8:1234::1
domain2:
172.16.0.1
2001:db8:5678::1
Retrieve the domain of a specified IP address
The resolvectl query
command can also be used to retrieve the domain associated with a specified IP address.
resolvectl query ip_address
Motivation: This command can be useful for reverse DNS lookup, where you have an IP address and want to find the corresponding domain name.
Explanation: This command queries the DNS resolver for the domain associated with the specified IP address.
Example Output:
172.16.0.1:
domain1.example.com
Flush all local DNS caches
The resolvectl flush-caches
command is used to flush all local DNS caches.
resolvectl flush-caches
Motivation: Flushing DNS caches can be helpful when troubleshooting DNS-related issues, as it forces the system to retrieve updated DNS information.
Explanation: This command clears the local DNS caches, including the resolver cache and negative cache.
Example Output:
Caches cleared successfully.
Display DNS statistics
The resolvectl statistics
command is used to display DNS statistics.
resolvectl statistics
Motivation: This command provides information about the DNS resolver, including transaction counts, cache usage, and DNSSEC validation statistics.
Explanation: This command retrieves and displays various statistics related to the DNS resolver on the system.
Example Output:
Statistics:
Transactions: 501
Cache entries: 250
DNSSEC verdicts: Secure: 250, Insecure: 120
Retrieve an MX record of a domain
The resolvectl query
command can be used to retrieve the MX (Mail Exchanger) record of a domain.
resolvectl --legend=no --type=MX query domain
Motivation: This command can be used to check the mail server configuration of a domain.
Explanation: This command queries the DNS resolver for the MX record of the specified domain.
Example Output:
domain:
10 mail.domain.com
Resolve an SRV record
The resolvectl service
command is used to resolve an SRV (Service) record.
resolvectl service _service._protocol name
Motivation: This command can be useful when verifying the service discovery mechanism of a network application.
Explanation: This command resolves the specified SRV record for the given service and protocol.
Example Output:
_service._protocol:
Priority: 0
Weight: 1
Port: 5269
Target: xmpp-server.domain.com
Retrieve a TLS key
The resolvectl tlsa
command is used to retrieve a TLSA (Transport Layer Security Authentication) key.
resolvectl tlsa tcp domain:443
Motivation: This command can be used to obtain the TLSA record for a specific TLS secured service.
Explanation: This command retrieves the TLSA record for the specified domain and port (protocol is optional, default is TCP).
Example Output:
70 00 01 41d56a3b6715...