Prevent resolv.conf changing on Linux Mint

Problem: default resolv.conf file looks like this:



#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

#127.0.0.53 is the systemd-resolved stub resolver.

#run “systemd-resolve –status” to see details about the actual nameservers.

nameserver 127.0.0.53


But what I want is my own list of DNS servers this machine knows about regardless of what the stupid router knows.

nameserver 1.1.1.1,8.8.8.8
nameserver 127.0.0.53

But DHCP client OVERWRITES THE FILE every time you twitch. reboot, drop wifi/start wiki, change VPN service, etc, every action causes the resolv.conf file to be re-written. VERY ANNOYING.

HOW TO FIX:

Prevent your dhcp client from being able to write the resolv.conf file. Otherwise you have to ferret out how to configure what its actually doing to write. I’m too lazy. Here’s a workaround.

Create hook to avoid /etc/resolv.conf file update

You need to create /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate file under a Debian / Ubuntu Linux:


sudo vi /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate

Append following code into this nodnsupdate file:

#!/bin/sh
make_resolv_conf(){
	:
}

Save and close the file. Set permissions using the chmod command:

sudo chmod +x /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate

Now you can edit the resolv.conf file and it will stay put the way you want it.



WHY DO I DO THIS?



I am running as a server with a static IP address so I can ssh to the machine because I know its IP address. I dont want each office I go to to have to tell the machine its local IP address and DNS servers.
Just use google, opendns, cloudflare, etc etc. Not your local rinky-dink farm country coop dns server in Nebraska wasteland.

They made linux be too much like a microsoft user appliance.

Where might a server will not work? In a coffee shop! But I dont take this server to a coffee shop. I have an appliance laptop for that.

I have maybe 20 servers in my campus, and will be adding some at the western site. they are mostly IOT automation servers made up of raspberry pi computers. I need to log onto them from my desk. and I need to log onto each of them from one of the others, and vice versa. Each machoine has their pre-assigned static IP address, and of course each has a host name.

But the network manager gobbedygook the millenials added to linux is MADDENINGLY COMPLEX AND STUPID.

At my western location i do not have admin control of what the router does. Solution: put in my own surrogate router. But why? No, its just easier to use static IP addresses and and not use DHCP at all.









Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s