LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   DNS settings get overwritten (https://www.linuxquestions.org/questions/debian-26/dns-settings-get-overwritten-4175512641/)

kbnuts 07-29-2014 01:27 PM

DNS settings get overwritten
 
Hi guys, Redhat guy trying to learn Debian here.

I've set up my interfaces ok and set them to static and I set up a bind server for DNS. But it seems like every so often resolv.conf gets overwritten with the DNS from DHCP. Network manager doesn't seem to be running and I can't understand why it keeps getting overwritten. Sure I could make it immutable using chattr (assuming that works ok in debian) but that's working round the issue.

Any ideas why this is happening or what I can do to stop it?

Guttorm 07-29-2014 02:15 PM

When a DHCP server gives you a DNS server address, shouldn't it be updated?

My resolv.conf has this comment:

Quote:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
Code:

man resolvconf

kbnuts 07-29-2014 02:19 PM

Quote:

Originally Posted by Guttorm (Post 5211531)
When a DHCP server gives you a DNS server address, shouldn't it be updated?

My resolv.conf has this comment:



Code:

man resolvconf

Yeah, I've got a really lightweight console install I've not installed network-manager or resolvconf so it (from what I can gather) shouldn't be being dynamically updated. I guess I should just change the DHCP but it really is just working round the problem. hmm.

kbnuts 07-29-2014 02:25 PM

Ok, and there it goes. I'll have to now figure out how to change the DNS settings in virsh net-edit in KVM.

Tsss... This is really silly. When I tell my network interface to not use DHCP I don't see why it should still try and get DNS settings from DHCP.

kbnuts 07-29-2014 02:30 PM

Sack it. I've just done a chattr +i on it.

Not very elegant, but it'll do the job.

szboardstretcher 07-29-2014 02:37 PM

Well,.. if you are positive it isnt NetworkManager.. You can always use auditing to find out what is changing it:

Code:

# Set up the audit
/sbin/auditctl -w /etc/resolv.conf -p war

# After the file changes use this to see the PID of the process that changed it
/sbin/ausearch -f /etc/resolv.conf


kbnuts 07-29-2014 02:41 PM

Quote:

Originally Posted by szboardstretcher (Post 5211543)
Well,.. if you are positive it isnt NetworkManager.. You can always use auditing to find out what is changing it:

Code:

# Set up the audit
/sbin/auditctl -w /etc/resolv.conf -p war

# After the file changes use this to see the PID of the process that changed it
/sbin/ausearch -f /etc/resolv.conf


Thankyou. Great idea.

What's the process name for networkmanager on debian just to make sure I'm not being a plonker.
I can't see it in services and if I grep -i for net in ps i only get [netns] which I think is network namespace which... I honestly don't know enough about.. It might be the culprit.

evo2 07-29-2014 07:44 PM

Hi,
Quote:

Originally Posted by kbnuts (Post 5211546)
What's the process name for networkmanager on debian just to make sure I'm not being a plonker.
I can't see it in services and if I grep -i for net in ps i only get [netns] which I think is network namespace which... I honestly don't know enough about.. It might be the culprit.

if it is installed, you should be able to find out with
Code:

dpkg -L network-manager |grep bin
However, I suggest you just install resolvconf and let it deal with this issue for you.

Evo2.

kbnuts 07-30-2014 01:26 AM

Thanks guys, next lab machine I build (which will probably be in the next couple of days), I'll user resolvconf on.

cynwulf 07-31-2014 06:16 AM

You have resolvconf* installed, which is trying to handle this for you "automagically". I would suggest removing it for a start. (*not to be confused with the resolv.conf configuration file).

I believe dhclient can still write to your resolv.conf regardless of if you setup a static address, but might be wrong about that. Editing the file and removing resolveconf should be enough.

There are more eloquent solutions but if the chattr solution works...

For DHCP, where you want to get an automatically assigned address, but specify your nameservers locally, edit dhclient.conf and add a suitable "prepend domain-name-servers" stanza.

camelrider 08-01-2014 07:16 PM

I liked your first suggestion (chattr -i)


All times are GMT -5. The time now is 10:07 AM.