How to force resolv.conf changes to "stick"?

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
orange_roughy

How to force resolv.conf changes to "stick"?

Post by orange_roughy »

Hi,

I searched the forums but didn't see this exact question answered. I also googled it. When I edit /etc/resolv.conf with custom nameservers, the changes eventually revert. How can I make them "sticky"?

thanks in advance,
orange
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
GeneC

Re: How to force resolv.conf changes to "stick"?

Post by GeneC »

Are you editing it as 'root'?.... :wink:

Code: Select all

gksudo gedit /etc/resolv.conf
orange_roughy

Re: How to force resolv.conf changes to "stick"?

Post by orange_roughy »

GeneC wrote:Are you editing it as 'root'?.... :wink:

Code: Select all

gksudo gedit /etc/resolv.conf
Yes, I am. The changes are saved until I reboot. I do not know if takes a single reboot or multiple before the change, or maybe it is when I connect to a different wifi system. The nameserver changes from (my edits) 8.8.8.8 to 192.168.1.1, which is the gateway/router.
remoulder
Level 17
Level 17
Posts: 7621
Joined: Fri May 09, 2008 1:14 pm

Re: How to force resolv.conf changes to "stick"?

Post by remoulder »

If you are using network manager then you set nameservers in the connection properties, manual edits to resolv.conf will be overwritten.
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
joshh

Re: How to force resolv.conf changes to "stick"?

Post by joshh »

You can make it write-protected with:

Code: Select all

sudo chattr +i /etc/resolv.conf
if in the future you want to undo this to change it again:

Code: Select all

sudo chattr -i /etc/resolv.conf
orange_roughy

Re: How to force resolv.conf changes to "stick"?

Post by orange_roughy »

remoulder wrote:If you are using network manager then you set nameservers in the connection properties, manual edits to resolv.conf will be overwritten.
I've done it that way, too. Doesn't seem to stick.
garrath

Re: How to force resolv.conf changes to "stick"?

Post by garrath »

I'm just posting to maybe help you. I think I figured it out. if you

Code: Select all

edit /etc/NetworkManager/NetworkManager.conf
comment out the line that says

Code: Select all

dns=dnsmasq
i.e.

Code: Select all

#dns=dnsmasq

Code: Select all

sudo restart network-manager
that should be it! Check

Code: Select all

cat /etc/resolv.conf
for the correct dns server.
If there are problems, make sure that in network manager, there are no stray dns servers.

hope that helps.
Locked

Return to “Networking”