scripts-fabq/notes/dns.md
Fabrice Quenneville 115eec5c62 feat(dns): add comprehensive DNS notes
- 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.
2024-12-05 15:49:54 -05:00

1.7 KiB
Raw Blame History

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 resolvectl for newer systems or systemd-resolve for older systems (pre-2020).

systemctl

  • This command enables the systemd-resolved service if it is not already running, ensuring DNS resolution through systemd.
systemctl enable systemd-resolved.service

Explanation of the command:

  • systemd-resolve --flush-caches: This command clears the DNS cache maintained by systemd-resolved, which can help resolve issues with outdated or incorrect DNS entries.
  • After flushing the cache, it may be necessary to restart the systemd-resolved service to ensure proper operation.
systemctl restart systemd-resolved
service systemd-resolved restart
  • To restart the service, use systemctl restart systemd-resolved (preferred). The service command is available but is considered legacy.

dig

dig domain.com
dig +short NS domain.com

nslookup

  • nslookup is a legacy tool but still useful for querying DNS. You can also specify custom DNS servers, such as 1.1.1.1 (Cloudflare) or 8.8.8.8 (Google), to query DNS directly without using the systems 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