Ask Your Question
1

Every reboot regenarate the /etc/resolv.conf

asked 2014-07-29 08:27:10 -0500

Nayana Adassuriya gravatar image

I have changes the /etc/resolv.conf file and added few new name-servers (Google DNS) . But every computer restart regenerate the /etc/resolv.conf file. Any solution for this plz?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
3

answered 2014-07-29 09:32:03 -0500

NikTh gravatar image

The /etc/resolv.conf file isn't statical. Yes, it will be regenerated at every reboot and even at every restart of NetwokrManager . If you read the contents of this file you should aware of this

It says (as a comment)

# Generated by NetworkManager

So, if you want to add nameservers you can do it via NetworkManager.

For a how to, read this similar question/answer.

edit flag offensive delete link more
1

answered 2014-07-30 03:07:37 -0500

abadrinath gravatar image

I know @NikTh has provided a reasonable answer here, but some people may not like to use GUI or Network Manager for that matter. So, edit the files here: /etc/sysconfig/network-scripts. In that directory, there are many scripts and configuration files. To edit DNS, edit ifcfg-eth0 or if that doesn't work, try this command:

for i in $( ifconfig|awk '{print $1}'|grep :|grep -v lo|sed 's/://' ); do ls $i; done

What this command will do is it will identify the name of the file(s) you need to edit (for example, wifi and ethernet to edit). Then, open that file with your favorite editor. It should look something like this:

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=Ethernet
UUID=56d496ef-07a1-4a1c-9e5d-c19b71e2cfbb
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY=no
PREFIX0=24
HWADDR=20:1A:06:95:B9:43

If it doesn't look anything like that, please check you have got the right file. Next, add this line to the end:

DNS1=8.8.8.8 # Or whatever DNS needed

Last, restart the network and/or plug in or out the ethernet cable using:

sudo service NetworkManager restart #or stop/start

It should be working fine now. I had this same issue a while back, and it works fine now.

The GUI method is way easier, but more tedious IMO. Regardless of what desktop environment you have, execute:

nm-connection-editor

Then create New if not already and go to the screen described by @NikTh here: https://ask.fedoraproject.org/en/question/48227/how-do-i-change-my-dns-settings/ . He has a great tutorial there (+1)!

HTH.

edit flag offensive delete link more
0

answered 2014-07-29 17:42:39 -0500

jfms gravatar image

you can set the option "PEERDNS=NO" in the network configuration scripts for the interface

/etc/sysconfig/network-scripts/ifcfg-<whatever>

this lock the number in resolv.conf

also this work too

chattr +i /etc/resolv.conf
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-07-29 08:27:10 -0500

Seen: 7,169 times

Last updated: Jul 30 '14