resolvectl is a command-line tool that is a part of the systemd system and service manager used in Linux operating systems. It provides a simple and efficient way to manage and troubleshoot the Domain Name System (DNS) resolution process on your system.
Here are some of the main functionalities of resolvectl:
- Resolve domain names and IP addresses: resolvectl can be used to resolve domain names to IP addresses (both IPv4 and IPv6) and vice versa. This can be helpful in troubleshooting network connectivity issues.
- Manage DNS configuration: resolvectl allows you to manage the DNS configuration of your system. This includes configuring DNS servers, search domains, and DNSSEC settings.
- Introspect the DNS resolver: resolvectl provides a detailed view of the DNS resolver running on your system, including the list of DNS servers being used, the current DNS domain being searched, and the current DNS resolution configuration.
- Reconfigure the DNS resolver: resolvectl allows you to reconfigure the DNS resolver on your system by adding or removing DNS servers or changing the search domains. This can be useful in situations where you want to switch to a different DNS provider or troubleshoot DNS resolution issues.
If you encounter the below error while running the command resolvectl:
resolvectl: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install systemd |
Ubuntu | apt-get install systemd |
Arch Linux | pacman -S systemd |
Kali Linux | apt-get install systemd |
CentOS | yum install systemd |
Fedora | dnf install systemd |
Raspbian | apt-get install systemd |
resolvectl Command Examples
1. Show DNS settings:
# resolvectl status
2. Resolve the IPv4 and IPv6 addresses for one or more domains:
# resolvectl query domain1 domain2 ...
3. Retrieve the domain of a specified IP:
# resolvectl query ip_address
4. Retrieve an MX record of domain:
# resolvectl --legend=no --type=MX query domain
5. Resolve an SRV record, for example _xmpp-server._tcp gmail.com:
# resolvectl service _service._protocol name
6. Retrieve the public key from an email address from an OPENPGPKEY DNS record:
# resolvectl opengpg email
7. Retrieve a TLS key:
# resolvectl tlsa tcp domain:443
Summary
Overall, resolvectl is a powerful tool that provides a range of functionalities for managing and troubleshooting the DNS resolution process on your system. It can be a valuable tool for network administrators, developers, and anyone who needs to manage and troubleshoot network connectivity issues on their Linux system.