Question

DNS resolution has stopped working on my Ubuntu 16.04 droplet

Having some issues with dns resolution on my Ubuntu 16.04 droplet with dns.

$ dig google.com

; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com
;; global options: +cmd
;; connection timed out; no servers could be reached

No changes were made to network configuration before I tried to troubleshoot this issue. I’ve tried changing the nameservers in /etc/network/interfaces.d/50-cloud-init.cfg to no avail.

/etc/resolv.conf is empty (except for some comments). If I manually add a nameserver to /etc/resolv.conf, it does work. Of course this doesn’t solve the issue because changes won’t be persisted over reboot.

$ cat /etc/resolv.conf && dig google.com
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 1.1.1.1

; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39462
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             221     IN      A       216.58.195.78

;; Query time: 1 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Sun Sep 29 19:31:00 UTC 2019
;; MSG SIZE  rcvd: 55

Anyone have similar issues?

EDIT

50-cloud-init.cfg contents (ip’s redacted):

$ cat /etc/network/interfaces.d/50-cloud-init.cfg 
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
    dns-nameservers 67.207.67.3

auto eth0
iface eth0 inet static
    address XXX.XXX.XXX.XXX/20
    gateway XXX.XXX.XXX.XXX

# control-alias eth0
iface eth0 inet static
    address XXX.XXX.XXX.XXX/16

Originally there was a second nameserver defined (next to 67.207.67.3) but I deleted it when messing around and now don’t remember what it was.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @joek1010

You can edit ``` /etc/network/interfaces.d/50-cloud-init.cfg

Check that your block looks like this:

auto eth0
iface eth0 inet static
    address XXX.XXX.XXX.XXX/20
    gateway XXX.XXX.XXX.XXX
    dns-nameservers 67.207.67.3

# control-alias eth0
iface eth0 inet static
    address XXX.XXX.XXX.XXX/16
    dns-nameservers 67.207.67.3

$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 67.207.67.3

Before making any changes, please make sure to create a copy of the file in case the change does not make a difference so you can revert everything back.

The other option will be to edit your interface configuration, which is located in: /etc/network/interfaces as this is something a lot of people use. I personally have two resolv.conf files in order to prevent any issues with the DNS resolution.

Let me know if you have any questions.