LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   Howto lock Resolv.conf from changing nameserver (https://www.linuxquestions.org/questions/fedora-35/howto-lock-resolv-conf-from-changing-nameserver-4175433068/)

mickeyboa 10-19-2012 10:08 AM

Howto lock Resolv.conf from changing nameserver
 
F17

how does one lockin nameserver in resolv.conf.

It keeps changing nameserver to 192.168.1.1 which is my Router gateway IP.

unSpawn 10-19-2012 10:43 AM

Add DNS{0,1,2}= statements to the /etc/sysconfig/network-scripts/ifcfg-%{devicename} configuration file?

mickeyboa 10-19-2012 06:05 PM

This is my new ifcfg-p128p1 (which is eth0)
It still changes resolv.conf to nameserver 192.168.1.1, Is it possible that NetworkManger is doing the changes instead of ifcfg-p128p1 ?

UUID="e676da02-6018-4567-8c0f-ab849ac673cb"
NM_CONTROLLED="yes"
HWADDR="78:E3:B5:95:98:2C"
BOOTPROTO="dhcp"
DEVICE="p128p1"
ONBOOT="yes"
PEERDNS=no
DNS1=8.8.8.8
DNS2=8.8.0.0

PEERDNS=no is not suppose to change resolv.conf if it is already set to 8.8.8.8.

unSpawn 10-19-2012 08:36 PM

Quote:

Originally Posted by mickeyboa (Post 4810312)
This is my new ifcfg-p128p1 (which is eth0)
It still changes resolv.conf to nameserver 192.168.1.1, Is it possible that NetworkManger is doing the changes instead of ifcfg-p128p1 ?

IIRC in F16 we still had a dhclient.conf in which you could prepend, append or override DNS entries. Sure enough there's a nm-dhclient-device.conf in /var/run/ in F18 (I decided to skip F17) but given the "nm" it's obvious NM "manages" it. I know you can use the NM GUI to configure the device and opt for Automatic DHCP addresses only after which you can enter DNS addresses but if you run multi-user.target (ye aulde runlevel 3) then I don't know how to accomplish the same using nm-tool or nmcli.

SharpyWarpy 10-20-2012 09:38 AM

Ahh, the beauty of bloatware. Alas, over the last two or three years I've watched as Linux developers push new "management" software that does things behind the scenes like Windows. Pulseaudio, NetworkManager, SELinux, all three of which I either disable or remove after every upgrade, much to the chagrin of these well meaning programmers. Here I go again, after I swore to myself not to bite the hand that feeds me - in this case all the Linux developers that make it possible for me to run a free, good operating system. My recommendation in your case is remove NetworkManager.
Code:

yum remove NetworkManager
Take back control of your computer. Now, before I catch he** from the developers just let me say this. Linux started out as a way to have complete control without background supervision. What happened? When did it become so important to be like Windows?

Glennzo 10-25-2012 05:10 AM

Wouldn't making the file immutable do the trick?

Code:

chmod +i /etc/resolv.conf

SharpyWarpy 10-25-2012 05:42 PM

Quote:

Originally Posted by Glennzo (Post 4814494)
Wouldn't making the file immutable do the trick?

Code:

chmod +i /etc/resolv.conf

Yes it most certainly would do the trick. The only problem (please bear in mind I'm an old man nursing a poor memory) is remembering you have done that next time you want to play with that file!

Glennzo 10-25-2012 05:58 PM

Yes, remembering could be an issue. The "why can't I edit that file" thing might drive one temporarily insane.

unSpawn 10-25-2012 06:59 PM

Quote:

Originally Posted by Glennzo (Post 4814494)
Wouldn't making the file immutable do the trick?

It would but there's a difference between making things work like they should (requiring knowledge of individual components and their interaction) and brute force. And while SharpyWarpy may have a point wrt things becoming complicated in some distros (deities know I haven't mastered systemd yet) it's not like SW has no documentation.


Quote:

Originally Posted by SharpyWarpy (Post 4814994)
Yes it most certainly would do the trick. The only problem (..) is remembering you have done that next time you want to play with that file!

Not with DE apps but a wrapper should work if you edit files from the CLI. May look something like:
Code:

nano() { i=($(lsattr "$1")); i=${i[0]}; case ${i//-/} in *i*) chattr -iu "$1";; esac; nano "$1"; chattr =$i "$1"; }
As is obvious it doesn't handle other attributes you may set (or not!) and it's an untested example so YMMV(VM).


All times are GMT -5. The time now is 09:31 AM.