Resolv.conf

Folks,

I am trying to resolve a spasmodic problem on my network with one computer.

I have PiHole set in my Router as my DSN server and give no alternative. Obviously PiHole has the fall back DNS servers it its own settings.

In a Linux system, if I put my ISP's DNS in the resolv.comf file will that specific computer now use that instead of the router setting of PiHole?

Geffers

Yes, a local override is preferred over the more global defaults. However, you may have a tool or system process controlling resolv.conf, so you should go through that process instead of directly modifying that file.

depends on your system. you'll probably find that if you're using Ubuntu or a Debian based setup that even if you edit /etc/resolv.conf it's just gonna continually be overwritten with garbage all the time and screw it all up

you can make /etc/resolv.conf on that machine immutable so nothing else can modify it on reboot or just whenever it feels like

sudo chattr -i /etc/resolv.conf

You're right, it did :face_with_raised_eyebrow:

May do, don't want to mess too much with normal system file operations.

Think I can set things in /etc/network/interfaces

Geffers

After posting I read up a wee bit on chattr and then tried it as SuperUser and it seems to have worked.

sudo didn't appear to work and got no error messages but using lsattr was helpful to see if changes made.

Thanks for pointer.

Geffers

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Just tried sudo chatrr -i /etc/resolv.conf and for some reason after reboot it still gets overwritten.

Even tried using sudo chmod to 444 to make it read only but still gets overwritten.

I'm going round in circles here, it is a Raspberry Pi device running Raspian Stretch, all I want to try is to prevent this one computer on my network using Pi-Hole.

I've added the DNS servers I want to use in the /etc/network/interfaces file and they get added to resolv.conf after reboot BUT the Pi_hole server has the first listing and temporarily I want to stop using Pi-Hole but just for this one computer.

Geffers

-i unlocks the file, use +i.

1 Like

That should be a +i as @firestorrrm mentioned.

This solution does work, but the underlying processes will still be trying to modify file--but they won't be able to.

NetworkManager NetworkMangler is notorious for modifying this file. It can work well if you let it, but lots of people find it annoying hence it's affectionate nickname. Also, dhclient tries to own the file in a similar manner.

2 Likes

Used to be so straightforward but now, what should be a simple task, becomes awkward.

Never mind, sorted now thansk to this forum.

Geffers

2 Likes

yeah woops I typed - and should be + :wink:

networkmanager also phones home every 300 seconds another good reason to nuke it from orbit

And folks wonder why I like sticking with Debian Jessie: better the devil you know :stuck_out_tongue:

1 Like

I've got a Pi Zero that has one job, it has an ADS-B tuner attached and logs aircraft. Headless and runs 24/7

For some reason if I alter the hostname and copy that in to hosts file for some reason the network connections on that device completely fail every so often. Random time, sometimes hours, sometimes minutes. Fixed IP disappears, all interface connection settings seem to disappear.

Restarting network service does not resolve anything(I can still get into device with serial-usb connection) but reboot does.

Log files show it losing connection but as yet not found out why.

If I leave the deafult name for the Zero all works fine. Why should that happen?

The mysteries of the network.

Geffers