- Documented commands for flushing DNS cache using `resolvectl` and `systemd-resolve`. - Included instructions for enabling and restarting `systemd-resolved` service. - Added usage examples for `dig` and `nslookup` to query DNS records. - Provided contextual explanations and legacy tool considerations.
1.7 KiB
1.7 KiB
DNS
Table of Contents
Flush DNS Cache
- Clear the DNS cache to ensure that the system resolves domain names with the most up-to-date information.
resolvectl flush-caches
systemd-resolve --flush-caches
- Use
resolvectlfor newer systems orsystemd-resolvefor older systems (pre-2020).
systemctl
- This command enables the
systemd-resolvedservice if it is not already running, ensuring DNS resolution throughsystemd.
systemctl enable systemd-resolved.service
Explanation of the command:
systemd-resolve --flush-caches: This command clears the DNS cache maintained bysystemd-resolved, which can help resolve issues with outdated or incorrect DNS entries.- After flushing the cache, it may be necessary to restart the
systemd-resolvedservice to ensure proper operation.
systemctl restart systemd-resolved
service systemd-resolved restart
- To restart the service, use
systemctl restart systemd-resolved(preferred). Theservicecommand is available but is considered legacy.
dig
dig domain.com
dig +short NS domain.com
nslookup
nslookupis a legacy tool but still useful for querying DNS. You can also specify custom DNS servers, such as1.1.1.1(Cloudflare) or8.8.8.8(Google), to query DNS directly without using the system’s default resolver.
nslookup domain.com
nslookup -q=cname domain.com
nslookup -q=cname domain.com 1.1.1.1
nslookup -q=cname domain.com 8.8.8.8
nslookup -q=mx domain.com
nslookup -q=txt domain.com