- Newest
- Most votes
- Most comments
Setting Up DNS Caching on Amazon Linux 2023 with dnsmasq
On Amazon Linux 2023, the default DNS handling has moved to systemd-resolved, and the stub listener is disabled by default. To enable local DNS caching efficiently, follow these steps:
-
Use
dnsmasq:- Install
dnsmasq:sudo yum install dnsmasq - Configure
dnsmasqto act as a caching server. Add this to/etc/dnsmasq.conf:cache-size=1000 listen-address=127.0.0.1 - Start and enable the service:
sudo systemctl enable dnsmasq sudo systemctl start dnsmasq
- Install
-
Point
/etc/resolv.conftodnsmasq:- Edit
/etc/resolv.confto use the local DNS cache:nameserver 127.0.0.1
- Edit
-
Ensure persistence: To prevent changes to
/etc/resolv.conffrom being overwritten by network configuration:- Use the
resolvconftool or create a static file:sudo chattr +i /etc/resolv.conf
- Use the
Alternatively, you can stick to systemd-resolved and manually enable the DNS stub listener. However, given Amazon Linux's configuration, dnsmasq offers a simpler and more predictable setup.
Let me know if you'd like further clarification!
Cheers, Aaron 😊
answered a year ago
I've posted steps on how to do this in the following post: https://repost.aws/questions/QU5b2tZh7cSxmuKlKqHWq5YA/how-do-i-a-setup-a-local-dns-caching-service-on-amazon-linux-2023
answered 2 years ago
Relevant content
asked 2 years ago
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated 3 months ago
