LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-01-2014, 09:18 PM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,338

Rep: Reputation: 54
How do I stop stuff from overwriting /etc/resolv.conf?


It seems lot of distros are resorting to overcomplicating networking and changing everything and doing it differently each time, and also overwriting config files like /etc/resolv.conf, which is needed to set DNS.

Is there a way to stop this from happening? I want to be able to set network info by simply editing a file, as I usually don't install a GUI on servers.
 
Old 07-01-2014, 09:41 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,907

Rep: Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816Reputation: 2816
resolv.conf

Define "stuff" please.
Generally things that overwrite or replace the resolv.conf file are part of the networking. (Network Manager is famous for this.)
The answer is to configure the search domain and nameservers in the file that application uses to dynamicly create resolv.conf. Ok, that or simplify the networking and do away with those applications: but know what you are doing.

Something like network manager is very nice if you use WIFI on a laptop that travels a lot. It pulls down the right settings for the connection you are using NOW. IF you have something that does not travel, network manager can be a pain. There are ways to manage it that make things better, and I do recommend finding one before ripping out and replacing your networking software. (Google may help here.)

I am a Network/System Admin with 20+ years of experience and do things like this for fun, but not to my primary production machines. Look at your situation and the information available online that might help your problem, and think well before deciding on your approach. You have not provided enough information about your own knowledge, or system situation, to allow for better advice than that.

Good luck, and please return here to let us know what you decide and how it goes.

PS. One way to avoid this is to load your own system using something like Debian, or even Gentoo, to include ONLY the packages you want or need. No specific distribution can fit your use better than one you design yourself. Derivatives like Fedora and Ubuntu make a lot of assumptions about usage, and load a default setup that will fit "well enough" for most users. IF you are not "most users" then know that you are free to choose a different road.

Last edited by wpeckham; 07-01-2014 at 09:47 PM. Reason: Incomplete answer.
 
Old 07-01-2014, 09:51 PM   #3
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,338

Original Poster
Rep: Reputation: 54
I don't know what "stuff" is as it seems to differ between distros. I know networkmanager is one bad one, I always uninstall that. Basically in the config files it will usually even say to not edit it directly because it will get overwritten. But then if I google "how to change nnn" it will tell me to edit that exact file.

Gateway is another oddball one that seems to differ a lot. Usually it's in /etc/sysconfig/network but in some distros (Debian based) that sysconfig folder does not actually exist.

Is there a way to configure this stuff using ifconfig? It would be nice if I could just stick all the commands in /etc/rc.local and that way it would be consistent across all machines no matter what the distro is.

Funny you mention making a custom distro as it's actually something I want to look into at some point. Been reading up Linux From Scratch and other stuff so I can get a better understanding of the back end of Linux. It seems lot of distros are obscuring a lot of that stuff.

Even editing ~/.bashrc has become crazy in some distros, they shove so much crap in there.
 
Old 07-01-2014, 09:58 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

the resolvconf package tries to address this. It tries to keep track of everything that wants to write to /etc/resolv.conf and then keep that file in the state the you have told it to. As discussed above this is a non-trivial problem so it may take a little reading to understand what it is doing and how to configure it to your liking. See the README for details (/usr/share/doc/resolvconf/README.gz on Debian based systems).

Evo2.
 
Old 07-01-2014, 10:26 PM   #5
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
Here is a fix:

https://wiki.archlinux.org/index.php...to_resolv.conf
 
Old 07-01-2014, 10:29 PM   #6
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by ceyx View Post
Can you elaborate?

Evo2.
 
Old 07-01-2014, 10:32 PM   #7
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
The relevant part of the link you want is something like this :

Quote:
NetworkManager will attempt to write DNS information from DHCP into /etc/resolv.conf, overwriting the existing contents. To prevent this, you can set the immutable bit on the file (as root):

# chattr +i /etc/resolv.conf

To modify the file in the future, first remove the immutable bit:

# chattr -i /etc/resolv.conf
 
Old 07-01-2014, 10:40 PM   #8
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
Also

One could add the line below to the 'interfaces' file

Quote:
sudo nano /etc/network/interfaces

dns-nameservers 192.168.0.XXX
or add this to resolv.conf:

Quote:
sudo nano /etc/resolv.conf ( on ubu 12 had to put it into "base" in /etc/resolvconf/resolv.conf.d/ )
nameserver 192.168.0.xxx
domain whatever.com
search whatever.com
One of the above 3 should work for you...
 
Old 07-01-2014, 10:57 PM   #9
ceyx
Member
 
Registered: May 2009
Location: Fort Langley BC
Distribution: Kubuntu,Free BSD,OSX,Windows
Posts: 342

Rep: Reputation: 59
evo2 :

I just checked the link above - I suppose the Arch folks have been busy updating their pages; the info posted above has moved to :

https://wiki.archlinux.org/index.php...e_DNS_settings

Good luck !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Prevent WICD Overwriting /etc/resolv.conf tronayne Slackware 2 12-19-2013 09:13 AM
Prevent VPNC from overwriting /etc/resolv.conf ALInux Linux - Software 1 08-26-2011 07:37 AM
Something is overwriting my /etc/resolv.con cov Linux - Networking 5 02-20-2010 03:23 PM
DNS Hosts.conf or resolv.conf problem mac_casey SUSE / openSUSE 0 03-26-2006 09:21 AM
DHCP client overwriting resolv.conf... how to stop it? gauge73 Linux - Networking 6 05-04-2005 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration