4

I'd like to take advantage of the recent Cloudflare 1.1.1.1 DNS service on my Ubuntu (17.10, will be on 18.04 LTS when it lands). I can not get the GUI instruction to work (changing the DNS using Network Manager) as the "Apply" button is always greyed out when a make the changes suggested by Cloudflare (it was never going to be that simple!).

So...I started looking into the other suggested option of editing /etc/resolv.conf. Having read about (and broke things!), I can see that /etc/resolv.conf should not be edited manually. It currently looks like this:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53

search default

I think I should edit the /etc/network/interfaces file as noted in this answer. for me, the interfaces file looks like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Given what I have read, should I just add a line to this file like this to account for the IPV4/6 addresses (using spaces to separate)?:

dns-nameservers 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001

and then reboot the system?

I'm asking first as I have already had to reconfigure resolv conf because I made changes that broke it. This is the first time I've done anything with DNS or even really understood why it would be good to make this change.

5 Answers5

3

Unfortunately setting /etc/resolv.conf directly will not change the DNS permanently and everything will be overridden again after restart.You will have to install resolvconf in not already installed :

sudo apt update
sudo apt install resolvconf

Then check the status:

sudo systemctl status resolvconf.service

Now open the /etc/resolvconf/resolv.conf.d/head configuration file and set the nameserver to cloudlfare:

sudo nano /etc/resolvconf/resolv.conf.d/head

Set nameserver 1.1.1.1

Finally, save your changes and restart the machine in order to take effect. To validate after restart, check that the nameserver 1.1.1.1 is the first entry in /etc/resolv.conf by

cat /etc/resolv.conf
zx485
  • 2,865
2

You can change it from the cli.

  • Edit resolv.conf: sudo vi /etc/resolv.conf
  • Add the new nameserver before any other server: nameserver 1.1.1.1
  • Save the file. See How to exit the Vim editor.
  • Reload networking: sudo service networking restart
0

Maybe try my answer to this question (DNS set to systemd's 127.0.0.53 - how to change permanently?). It involves installing the package resolvconf and how you can use it to add something permanent to resolv.conf.
Lines that need to be at the start of resolv.conf can be put in file /etc/resolvconf/resolv.conf.d/head.

oscar1919
  • 1,747
  • 14
  • 15
0

https://help.ubuntu.com/16.04/ubuntu-help/net-wireless-edit-connection.html

Automatic (DHCP) Get information like the IP address and DNS server to use from a DHCP server. A DHCP server is a computer (or other device, like a router) connected to the network which decides which network settings your computer should have - when you first connect to the network, you will automatically be assigned the correct settings. Most networks use DHCP.

Automatic (DHCP) addresses only If you choose this setting, your computer will get its IP address from a DHCP server, but you will have to manually define other details (like which DNS server to use).

Use the network gui in the bar.

  • click "Edit Connections"
  • highlight the network interface you're using and click "Edit"
  • click the "IPv4 Settings" tab
  • change "Method" to "Automatic (DHCP) addresses only"
  • change "DNS servers" to 1.1.1.1 1.0.0.1 8.8.8.8 (space separated ip addys)
  • reboot computer

If you leave the "Method" on "Automatic (DHCP)", your computer will just use the DNS given by whatever DHCP server gave you your ip addy.

0

All of the above are workarounds really. In Ubuntu 17.10 they changed to netplan to manage networks.

for desktop it is now netplan/networkmanager for server (headerless) it is now netplan/networkd

So basically anything you have edited in the past doesn't really work anymore. To make life more confusing it is all still there, and editing it can just add further layers of problem (that's experience talking). Once I just started working with only the netplan stuff, everything started to work again.

As far as I understand you now edit gui from within the gui (I don't use the gui), if you google ubuntu 18.04 static ip netplan networkd you will probably find what you are looking for. I have only just discovered most of this, and I am still not 100% sure how it all works, which is why I have not told you how I setup my network stuff. Bad advise only makes things worse.

My key info was found here: https://websiteforstudents.com/configure-static-ip-addresses-on-ubuntu-18-04-beta/

Hope this helps.