Ubuntu – Ubuntu 16.04 erases /etc/resolv.conf after restart

dnsnetworking

I'm new user on Ubuntu and I need your help.

I would like to configure DNS in /etc/resolv.conf, so I used this command:

sudo nano /etc/resolv.conf

I changed my DNS server and it was OK but, after restarting, my changes to /etc/resolv.conf were removed and the default configuration was restored.

I have tried the command below but it failed:

sudo chattr +i /etc/resolv.conf
chattr: Opération non supportée lors de la lecture des drapeaux sur /etc/resolv.conf

in english:
chattr : Operation not supported when reading flags on /etc/resolv.conf

What can I do?

Best Answer

Hello Saturne64 and welcome to Askubuntu! The contents of /etc/resolv.conf are ultimately overwritten, but we can still set your DNS server of choice for your computer through the Network Manager. Please follow these steps:

  1. Click the wifi icon at the top-right of your screen and choose "Network Connections"
  2. Click "Edit"
  3. Click the "IPV4 Settings" tab
  4. Next to "Method: ", click "Automatic (DHCP)" and choose "Automatic (DHCP) addresses only"
  5. In the text box adjacent to "DNS Servers: ", type the address of your preferred DNS server.
  6. Click "Save" and in a terminal, run sudo systemctl restart network-manager.service.

Let me know if you need further assistance :)