Pi-hole server lose awareness of it self

fritzbox

#14

Ok, this tells the DNS to irgnore /etc/hosts. Because it could be changed manually or by other circumstances.

But the local DNS need to know about “pihole.fritz.box” & “pihole” refer to 192.168.0.50 and return this properly to requesting clients. Where is this information local gathered?

As we discovered the “main” local DNS at the FRITZBox doesn’t know the host.


#15

Lets forget Pi-Hole is running a DNS service.
The “/etc/hosts” file main purpose is for telling processes, running on its own host, how to resolve certain hostnames to IP addresses without using a DNS server (suppose the DNS server is down).
Its not intended for other clients on the network to be used for resolution.
So this entry would make perfect sense:

127.0.1.1 pihole.fritz.box

If a local process is asking to resolve “pihole.fritz.box” via the hosts file, it will get “127.0.1.1” returned which is an IP address on its own loopback interface.
Everything on the loopback interface stays internal and is not broadcasted over the physical network interfaces like eth0, wlan0 etc.
Do you now see the advantage of using a loopback IP addresses for the processes to communicate internally to each other ?

Having loopback IP addresses as DNS records in your dnsmasq service is pointless for resolving to for example another host.
But these loopback IP addresses as DNS records could be used for other purposes like for example whats implemented on FritzBox routers:


#16

These records are added to dnsmasq:

$ cat /etc/pihole/local.list
10.0.0.8 noads.dehakkelaar.nl
10.0.0.8 pi.hole

#17

Ok this make sense, because the name resolution is then a part of Pi-hole not done by the host itself.
I restored the /etc/hosts file:

Told Pi-hole to ignore /etc/hosts:

Made the entry in /etc/pihole/local.list:

And restarted the service:

I’m confident that this is the right solution.


#18

Noooo dont do that!
Pi-Hole needs to populate this file " /etc/pihole/local.list" for you.
I believe if you run “pihole -r” for reconfiguring, you will be asked for a hostname and you can change it if you want (set it to a FQDN to avoid trouble and have a short name covered as well).
Chances are that first time you run Pi-Hole updates, the entries you made in that file will be overwritten.

EDIT: Did you see me having a short name in that file from my examples ?

It still works for me:

$ nslookup noads
Server:    10.0.0.8
Address 1: 10.0.0.8 noads.dehakkelaar.nl

Name:      noads
Address 1: 10.0.0.8 noads.dehakkelaar.nl

#19

This means the solution should be to use a FQDN hostname (in /etc/hostname) and tell Pi-hole to ignore /etc/hosts?


#20

Yes but dont forget to change it too in the “/etc/hosts” file for the loopback IP 127…
And reboot just to make sure the new hostname propagates through the system.


#21

Full fix:

  1. Set FQDN in “/etc/hostname” (as this is recommended and sometimes required for some software):

sudo nano /etc/hostname

  1. In “/etc/hosts” alter the line with “127.0.1.1” into a FQDN too:

sudo nano /etc/hosts

  1. Ad ‘localise-queries’ option to have dnsmasq respond depending on interface:

echo 'localise-queries' | sudo tee /etc/dnsmasq.d/localise-queries.conf

  1. Reboot:

sudo reboot

  1. On Pi-Hole, check new hostname with:

hostname; hostname -s; hostname -f

  1. On Pi-Hole, check via ping if “/etc/hosts” is setup correctly by checking the returned IP address which should be “127.0.1.1”:

ping <FQDN>

  1. On Pi-Hole web GUI, check if displayed hostname under settings is correct and if not, run below one to update:

pihole -g

  1. Test from client with:

nslookup <SHORT_HOSTNAME>

Or:

host <SHORT_NAME>

As example:

$ cat /etc/hostname
noads.dehakkelaar.nl

$ hostname; hostname -s; hostname -f
noads.dehakkelaar.nl
noads
noads.dehakkelaar.nl

$ cat /etc/hosts
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1   noads.dehakkelaar.nl

$ ping noads.dehakkelaar.nl
PING noads.dehakkelaar.nl (127.0.1.1) 56(84) bytes of data.

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 127.0.0.1

$ cat /etc/dnsmasq.d/localise-queries.conf
localise-queries

$ host noads
noads.dehakkelaar.nl has address 10.0.0.8

#22

Pew, ready now or did I left something out ?


#23

Added below as this seems to confuse alot of people:

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 127.0.0.1

It says for DNS resolution, use the localhost Pi-Hole dnsmasq daemon who is listening on all interfaces including the 127.0.0.1 loopback interface IP address.
Pi-Hole is not using this file, only local processes that invoke DNS, because Pi-Hole got its own upstream DNS servers configured for resolution.


Google DNS Anzeige obwohl DNS.Watch
#24

Referring to MrD’s post (Teleporter: Add ‘/etc/pihole/local.list’)

pihole -g

should be enough to update /etc/pihole/local.list.


#25

Not sure if running the “-g” option will update all hostname instances for Pi-Hole besides the “/etc/pihole/local.list” file.
Had a quick look at the code but got lost in functions.
For now I would stick with the “-r” option or maybe a dev or someone else knows ?
Ping @MrD


#26

For the hosts issue:

My first ever pull on git :wink:


#27

Looks like the “-g” option is all it needs but not sure:

$ sudo grep noads -R /etc/
/etc/pihole/local.list: 10.0.0.8 noads.dehakkelaar.nl
/etc/hostname: noads.dehakkelaar.nl
/etc/hosts: 127.0.1.1    noads.dehakkelaar.nl

#28

@GR3mGH0n ,
The guys found this little gem:

This to allow users to still add entries in the “/etc/hosts” file that will be read by dnsmasq to share with the clients.
Though the hosts file is not intended for that, allot of us (ab)use it like that anyway just for the ease.
Proper way is to configure dnsmask to load your own list of hosts and IP addresses to be loaded as DNS records.

I already implemented the “localise-queries” directive and without breaking loopback, everything looks dandy.
If you want to help out testing:

sudo rm /etc/dnsmasq.d/no-hosts-file.conf
echo 'localise-queries' | sudo tee /etc/dnsmasq.d/99-localise-queries.conf
sudo service dnsmasq restart


Pi-hole 3.0.1 Fixes And Tweaks
#29

I already read both requests this afternoon and be pleased about the canny solution. I reprocuced the changes on my system and I can confirm: Everything operates flawless so far.


#30

@MrD ,
Discourse derailing a bit but I saw your response.
Thats sweet bc that means you wont have to go through the lengthy procedure of reconfigure.


#31

FYI, I updated:

$ pihole -v
::: Pi-hole version is v3.0 (Latest version is v3.0)
::: Web-Admin version is v3.0 (Latest version is v3.0)

And seem to have lost my entry:

$ sudo grep 'localise-queries' -R /etc

$ host noads.dehakkelaar.nl
noads.dehakkelaar.nl has address 127.0.1.1
noads.dehakkelaar.nl has address 10.0.0.8

So you’ll need to add it again until tested and implemented:

echo 'localise-queries' | sudo tee /etc/dnsmasq.d/localise-queries.conf
sudo service dnsmasq restart

pi@noads:~ $ host noads.dehakkelaar.nl
noads.dehakkelaar.nl has address 127.0.1.1

xbian@arcade ~ $ host noads.dehakkelaar.nl
noads.dehakkelaar.nl has address 10.0.0.8


#32

My file is still there. I named it:

99-localise-queries.conf


#33

Yeah I think I read before that happening if you dont number them high.
Adjusted solution … Thx!