Skip to content

Instantly share code, notes, and snippets.

@hospadar
Created April 15, 2019 14:47
Show Gist options
  • Save hospadar/e2d7c60fb796f9e79f853cfed96427cf to your computer and use it in GitHub Desktop.
Save hospadar/e2d7c60fb796f9e79f853cfed96427cf to your computer and use it in GitHub Desktop.

Setting up dnsmasq on ubuntu

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:

  1. Disable systemd-resolved all together
  2. Set up network-manager to run its own dnsmasq and point /etc/resolv.conf at its dnsmasq instance

steps:

Disable and stop systemd-resolved:

sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved

Reconfigure network-manager

/etc/NetworkManager/NetworkManager.conf:
under [main], add:

dns=dnsmasq
rc-manager=symlink

Add dsnmasq config

/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

Restart network manager:

service network-manager restart

Useful commands:

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment