Hi all, I could use some help trying to figure out below issue.
I have a RaspiOS Buster Pi-hole setup running on a dedicated Raspi model 1B with Unbound configured upstream and Pi-hole doing DHCPv4 for my network.
The problem is, the Pi-hole hostname is resolved to a localhost address 127.0.1.1 and not to the actual address when doing lookups from a client:
C:\>nslookup ph5a
Server: ph5a
Address: 10.0.0.2
Name: ph5a.dehakkelaar.nl
Address: 127.0.1.1
The Pi-hole host is configured as followed:
pi@ph5a:~ $ cat /etc/hostname
ph5a
pi@ph5a:~ $ cat /etc/dhcpcd.conf
[..]
interface eth0
static ip_address=10.0.0.2/24
static routers=10.0.0.1
static domain_name=dehakkelaar.nl
static domain_name_servers=10.0.0.1
pi@ph5a:~ $ 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 ph5a.dehakkelaar.nl ph5a
And seems to work as expected:
pi@ph5a:~ $ hostname
ph5a
pi@ph5a:~ $ hostname -f
ph5a.dehakkelaar.nl
pi@ph5a:~ $ dnsdomainname
dehakkelaar.nl
What I figured out is that the ph5a name in below file will be ignored if it isn't a FQDN:
pi@ph5a:~ $ cat /etc/pihole/local.list
10.0.0.2 ph5a
10.0.0.2 pi.hole
And the localise-queries logic in dnsmasq will produce the 127.0.1.1 IP from the /etc/hosts file instead of the preferred local.list entry.
I believe below code is related and it prefers content from the /etc/hostname file over that of the hostname -f output:
Do any of you have the same with only the short name (not a FQDN one) reflected in the /etc/hostname file?
I havn't checked/cant recollect but isnt a fresh RaspiOS OOTB also configured with only a short hostname "raspberrypi" or something?
I know I can configure the hostname to be a FQDN one but shouldn't above also work?