What overwrites /etc/resolv.conf on every boot? <SOLVED>

a very small Live CD shaped to look and act like Puppy Linux.


Moderator: fredx181

Post Reply
dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

What overwrites /etc/resolv.conf on every boot? <SOLVED>

Post by dcung »

Lately, I noticed that my browsing pages were slow to appear.
I tracked the issue to /etc/resolv.conf, ie. it's fast when I used DNS server not supplied by my DHCP - so I just changed it manually for now.

I probably could do a script and put in Startup (not tried yet), but I'd like to know other ways.
And probably will be overwritten again when lease expired.

Code: Select all

#!/bin/sh
echo "nameserver 1.1.1.1" > /etc/resolv.conf

Now, how do I stop whatever it is that overwrites /etc/resolv.conf when lease expired or reboot (LXQT Dog)?

I tried making the file read-only, but it still gets overwritten.
Tried to search here, not finding solution yet. So, while I keep searching, I thought to ask.

I read this and still not able to solve the issue.
https://unix.stackexchange.com/question ... every-boot

Last edited by dcung on Sat Feb 01, 2025 5:02 am, edited 1 time in total.
williwaw
Posts: 2151
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 196 times
Been thanked: 414 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by williwaw »

the easiest solution I have found is to set DNS at the router.

User avatar
Marv
Posts: 474
Joined: Fri Dec 20, 2019 3:09 am
Has thanked: 220 times
Been thanked: 128 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by Marv »

I now set my DNS server in my router too but here are a couple of threads that might be of interest:
viewtopic.php?p=136368&hilit=dns+changer.sh#p136368
search.php?keywords=resolv.conf.head

My pups: LxPupSc64 and Voidpup64 with LXDE ydrv and synaptics touchpad drivers, using small savefiles for customizations. Ydrv based NoblePup64 and Fossapup64-low (both LXDE/PCManFM with no savefiles). Small common custom fdrv throughout. :thumbup2:

User avatar
rcrsn51
Posts: 1486
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 424 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by rcrsn51 »

The first question anyone should be asking here is "What connection manager are you using?"

If it's PeasyWifi, you can override DNS with: echo "nameserver 1.1.1.1" > /etc/resolv.conf.head
Reboot.

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by dcung »

rcrsn51 wrote: Sat Feb 01, 2025 3:12 am

If it's PeasyWifi, you can override DNS with: echo "nameserver 1.1.1.1" > /etc/resolv.conf.head
Reboot.

I am using PeasyWifi. Learnt something about PeasyWifi today... :)
I tried it and it works - sort of.

I don't turn off my laptop, only put it to sleep.
And I noticed when it wakes up (after long period) and lease expired, /etc/resolv.conf gets overwritten.
Now, I assume that I will still have this issue?

That's why ideally I'd like to know, what is overwriting the file from time to time.

williwaw wrote: Sat Feb 01, 2025 2:31 am

the easiest solution I have found is to set DNS at the router.

I know setting DNS on my router, will solve this.
But that does not answer my question of what script is doing the overwriting.
Sort of, knowing 'root' of the issue... :)

User avatar
rcrsn51
Posts: 1486
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 424 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by rcrsn51 »

PWF uses udhcpc and the script /etc/pwf/udhcpc/default.script.
Line 28 of the script handles this DNS override situation.
The script ordinarily gets run when PWF makes a connection - either through WiFi or Ethernet.
But udhcpc is also running in the background. I'm guessing that if a lease expires, it takes over and runs by itself, ignoring PWF's script.
This allows auto-DNS to happen instead of the override.

User avatar
rcrsn51
Posts: 1486
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 424 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by rcrsn51 »

Try this: Put a copy of the above script at /etc/udhcpc/default.script
This is the default location of the script and might run when udhcpc renews a lease by itself.

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: What overwrites /etc/resolv.conf on every boot?

Post by dcung »

rcrsn51 wrote: Sat Feb 01, 2025 4:20 am

Try this: Put a copy of the above script at /etc/udhcpc/default.script
This is the default location of the script and might run when udhcpc renews a lease by itself.

I guess this the default location of the script is what I'm looking for.

In the link I put in first post, they mentioned /usr/share/udhcpc/default.script - didn't exist in mine.
/etc/udhcpc/default.script also didn't exist in mine.

I guess, I'll try to create it and see what happened.

Thanks @rcrsn51

dcung
Posts: 510
Joined: Fri Sep 25, 2020 4:31 am
Has thanked: 68 times
Been thanked: 70 times

Re: What overwrites /etc/resolv.conf on every boot? <SOLVED>

Post by dcung »

I shorten my lease time to 5 mins to test it.
And ...
/etc/udhcpc/default.script
is the default location.

When lease expired - it refreshed using the script.
<I put dummy DNS in /etc/resolv.conf.head and it gets updated with it>

@rcrsn51 Thank you.

User avatar
rcrsn51
Posts: 1486
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 424 times

Re: What overwrites /etc/resolv.conf on every boot? <SOLVED>

Post by rcrsn51 »

Excellent.

A better way to do this would be with a symlink: ln -sf /etc/pwf/udhcpc/default.script /etc/udhcpc/default.script

Post Reply

Return to “DebianDogs”