This refers to ubuntu 18.04
By default, Ubuntu is using network-manager to manage network connections, and systemd-resolved is managing dns resolution
We're going to:
- Disable
systemd-resolved
all together - Set up
network-manager
to run its own dnsmasq and point /etc/resolv.conf at its dnsmasq instance
sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved
/etc/NetworkManager/NetworkManager.conf
:
under [main]
, add:
dns=dnsmasq
rc-manager=symlink
/etc/NetworkManager/dnsmasq.d/dnsmasq.conf
resolv-file=/etc/NetworkManager/resolv.conf
address=/ec2.internal/127.0.0.1
synth-domain=ec2.internal,0.0.0.0,255.255.255.255,ip-
/etc/NetworkManager/resolv.conf
#prefer cloudflare's DNS
nameserver 1.1.1.1
nameserver 1.0.0.1
#but fall back to google public DNS if that's not working
nameserver 8.8.8.8
service network-manager restart
- Check network-manager status and see potential error logs
systemctl status network-manager
- See where resolv.conf is pointing
ls -l /etc/resolv.conf
cat /etc/resolv.conf