kobak
Posts: 2
Joined: Wed Feb 07, 2018 10:15 pm

resolv.conf rewrites to 127.0.0.1

Sat May 05, 2018 2:16 pm

My resolv.conf always rewrites the nameserver to 127.0.0.1. I had pi-hole installed for a while, but didn't need it anymore. It should be simple, but can't find what is rewriting my nameserver to 127.0.0.1.

Thanks.

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: resolv.conf rewrites to 127.0.0.1

Sun May 06, 2018 4:25 pm

Usually resolv.conf points to the localhost when a DNS service is installed. Do you have dnsmasq installed?
It works as a local cache (and resolver) so it might be a good thing to keep it and tweak /etc/dnsmasq.conf. Unless your DNS service is handled elsewhere already.

This being said, does /etc/resolv.conf start with this?

Code: Select all

# 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
If the answer is yes, have a look at resolvconf.conf (...) and then look in the /etc/resolvconf directories. There could be a script called dnsmasq somewhere in there, move it out of the way, reboot and see how it fares.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: resolv.conf rewrites to 127.0.0.1

Wed May 09, 2018 3:31 pm

Are you running dsnmasq? It will re-write your /etc/resolv.conf

One way to protect it is sudo chattr +i /etc/resolv.conf after you've edited it to have sensible contents. That prevents anyone updating it unless they run sudo chattr -i /etc/resolv.conf first.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: resolv.conf rewrites to 127.0.0.1

Wed May 09, 2018 4:15 pm

Making /etc/resolv.conf immutable has to be one of the worst hacks around.
Don't do that. When the resolver is hosed your machine is hosed.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 39303
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: resolv.conf rewrites to 127.0.0.1

Wed May 09, 2018 8:20 pm

epoch1970 wrote:
Wed May 09, 2018 4:15 pm
Making /etc/resolv.conf immutable has to be one of the worst hacks around.
Don't do that. When the resolver is hosed your machine is hosed.
I disagree.

I do it on all of my fixed RPis that are permanently booted and connected. It saves a bunch of hassle when things like dhcp and dnsmasq want to tamper with my settings. I've got complete control including adding the IPv6 & IPv4 addressed of my bind9 system to /etc/resolv.conf in the other fourteen raspberries.

If I'm taking a Raspberry out of my network I'll undo it. Not being able to resolve a domain to an IP is no big deal and is a trivial problem to diagnose and cure.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: resolv.conf rewrites to 127.0.0.1

Thu May 10, 2018 11:47 am

dnsmasq is not an insignificant program, people could learn how to use it.
Abusing a system lib is bad practice, no need to promote that.

(Named here, too.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: resolv.conf rewrites to 127.0.0.1

Thu May 10, 2018 12:06 pm

epoch1970 wrote:
Thu May 10, 2018 11:47 am
dnsmasq is not an insignificant program, people could learn how to use it.
Abusing a system lib is bad practice, no need to promote that.

(Named here, too.)
Let not this generally correct principle blind you (or anyone else) to the cold, hard fact that stuff has bugs in it. There are situations where you have to do stuff like this (e.g., use "chattr" to freeze a file) because it is just not practical to fix the underlying system software bugs.

Being able to whip up fixes like this on the fly is an important skill.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: resolv.conf rewrites to 127.0.0.1

Fri May 11, 2018 9:15 am

Except in this instance, there is no bug.
If there is one, please post to the dev lists of resolvconf or dnsmasq.

Last time. Making /etc/resolv.conf immutable is sloppy.
It will get you into trouble once you've forgotten you had the bright idea to pass that command, or whoever else uses the machine.
man resolvconf, man dnsmasq is all you need.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: resolv.conf rewrites to 127.0.0.1

Fri May 11, 2018 10:43 am

First principle of computer programming: All code has bugs in it.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

Return to “Troubleshooting”