4

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?

  • FWIW you probably get the chattr: Opération non supportée error because the thing you are trying to change the attributes of is actually a symbolic link (to run/resolvconf/resolv.conf) - to use chattr -i here, you'd need to remove the link and create a regular file first. However there are much better ways to achieve what you want without brute force, as described in the answers below. – steeldriver Jul 19 '16 at 17:10
  • Hello Arronical and thank. I need find the best solution. Can you know if it's possible change this symbolic link for change everytime /etc/resolv.conf? – Saturne64 Jul 20 '16 at 5:15
5

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 :)

|improve this answer|||||
  • hello user and thank's. I have follow your answer and after that i use nslookup www.free.fr Server: 127.0.1.1 Address: 127.0.1.1#53 my configuration don't working with my dns. Do you have any solution? – Saturne64 Jul 20 '16 at 5:31
  • Potentially, yes; allow me to explain. On my computer, I use dnscrypt as a dns forwarder, and it is bound to port 127.0.2.1 port 53. But Network Manager doesn't allow me to save my dns settings if, for example, I enter "127.0.2.1:53" in the DNS Servers box. Only when I leave off the ":53", I am allowed to save my settings, and they work after issuing the restart command above. I assume this is because Network Manager assumes port 53. Did you enter a port number in the box for your setup, and if so, could you remove it, save your settings, and then restart Network Manager? – user311982 Aug 4 '16 at 15:49
3

You need to set the DNS settings in whatever tool you use to configure your network (for example NetworkManager or /etc/network/interfaces).

Alternatively, you can uninstall resolvconf to revert to a more traditional setup (or old-fashioned, depending on your point of view).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.