1

I am searching for a solution to the problem of Ubuntu resetting my DNS server settings after reboot.. I have tried sudo chattr +i /etc/resolv.conf to stop resolv.conf from resetting, however it returns chattr: Operation not supported while reading flags on /etc/resolv.conf.. I am super new to Linux since I have just installed it, so I need help over here.. Tried many things and broke the resolv.conf so I couldn't set DNS even for the short period before rebooting (it didn't even set DNS)..Anyone got this problem ? Solutions ? Thanks !! (Using Ubuntu MATE 17.04 - Fresh Install)

Saw many questions on here but always ran into some problems :S

  • Have you tried setting the DNS in Network Manager? https://askubuntu.com/questions/422293/remove-isp-provided-dns/422343#422343 – chili555 Apr 16 '17 at 23:57
  • @chuli555 Hmm, done that and seems like it works, however resolv.conf is still reseting.. Should it happen again ? – Math Newbie Apr 17 '17 at 07:42
  • Is it resetting to 127.0.0.53? That is normal for a 17.04 system running dnsmasq. Is the system running correctly now? Can you browse the web? Open Google, etc.? If so, all is well. – chili555 Apr 17 '17 at 14:13
  • @chili555 Yes, 127.0.0.53 exactly, everything is fine for now.. Thanks :D !! – Math Newbie Apr 17 '17 at 19:38
  • Did you read the notice in capitals in /etc/resolv.conf? If not ... it said DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN . Here is how to do this: https://askubuntu.com/questions/157154/how-do-i-include-lines-in-resolv-conf-that-wont-get-lost-on-reboot – Rinzwind Apr 18 '17 at 11:44
  • @Rinzwind I didn't edit id by hand.. I have tried many things from may posts here, however it is resolved now (keeps resetting, but works) .. Tho thanks I will read it to see maybe haven't tried something !! :D – Math Newbie Apr 18 '17 at 14:35
  • Possible duplicate: https://askubuntu.com/questions/157154/how-do-i-include-lines-in-resolv-conf-that-wont-get-lost-on-reboot – Rakib Fiha May 02 '19 at 10:19

2 Answers2

2

You can try with -f flag with the command as

sudo chattr -f +i /etc/resolv.conf
Kulfy
  • 17,696
  • Why ?? .. setting +i on /etc/resolv.conf won't stop the system from changing ../run/resolvconf/resolv.conf which /etc/resolv.conf is a symlink to. – Soren A May 02 '19 at 10:32
1

What I think you are experiencing is resolvconf modifying your settings.

Check to see if /etc/resolv.conf is a link versus a file. Most likely it is a link as such or similar.

# ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 45 Oct 10  2016 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

You can just delete the link with "sudo rm /etc/resolv.conf" and create the file manually with any text editor via sudo and that should keep your settings to what you want.

# ls -al /etc/resolv.conf
-rw-r--r-- 1 root root 45 Oct 10  2016 /etc/resolv.conf

# cat /etc/resolv.conf
## my simple setup pointing at google then my router.
nameserver 8.8.8.8
nameserver 192.168.1.1

With that said, I'm assuming that you only use a single network setup for this system. On these newer distro's there is a lot going on with NetworkManager, resolvconf and dnsmasq that can bring diverse options for network but most people just one setup a connection that never changes.

  • It says I have no permission to delete the file :S – Math Newbie Apr 17 '17 at 07:50
  • Sorry, so remember you need "admin" i.e. root to change files owned by others most times unless you are also in the group and the files have group write permissions in Linux. So, for this time and all future administration related tasks you can either run sudo su - and then perform all commands as root with or without using sudo as well. Otherwise, you have to run all administrative prefixed with sudo i.e. sudo rm /etc/resolv.conf .. sudo nano /etc/resolv.conf . – wedgeshot Apr 18 '17 at 11:37
  • @wedgeshot please don't remove warnings from /etc/resolve.conf. Where is the DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN that should be in there? – Rinzwind Apr 18 '17 at 11:45
  • One the file is no longer a link the file is not under control of resolvconf and should never change moving forward unless. You can ignore that message and does not need to be included when editing. – wedgeshot Apr 20 '17 at 01:57