The issue I am facing:
After running the install script
curl -sSL https://install.pi-hole.net | bash
my pi-hole host OS cannot do local name resolution of other devices on my network. The pi-hole itself is correctly resolving these.
Symptoms:
sudo gives a non-fatal error: myhost : Jul 4 08:14:10 : www-data : unable to resolve host myhost
nslookup myhost will fail
logs showing myhost : Jul 4 08:14:10 : www-data : problem with defaults entries ; TTY=unknown ; PWD=/var/www/html/admin ; USER=root ;
Related posts
- Pi-hole's host machine can't resolve local domains - #12 by deHakkelaar
- *** SECURITY information for my-server *** problem with defaults entries
Details about my system:
Rpi4 hardware
Ubuntu 20.04 LTS
Basic install - I specified custom DNS servers
The hostname of my pi-hole is "myhost".
What I have changed since installing Pi-hole:
Plenty - but for the purpose of this question - this can be reproduced by doing the install only
What I think is going on
This line in the install: pi-hole/basic-install.sh at 4736e03108763cc2d5659f48d8a1e8a64d9b2608 ยท pi-hole/pi-hole ยท GitHub
is doing a few things
# we can append these lines to dhcpcd.conf to enable a static IP
echo "interface ${PIHOLE_INTERFACE}
static ip_address=${IPV4_ADDRESS}
static routers=${IPv4gw}
static domain_name_servers=${PIHOLE_DNS_1} ${PIHOLE_DNS_2}" | tee -a /etc/dhcpcd.conf >/dev/null
# Then use the ip command to immediately set the new address
ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}"
# Also give a warning that the user may need to reboot their system
printf " %b Set IP address to %s\\n" "${TICK}" "${IPV4_ADDRESS%/*}"
printf " %b You may need to restart after the install is complete\\n" "${INFO}"
Many base OS installs will have a default configuration which gets the IP address from the network DHCP server. I would expect that most pi-hole installs are running down this logic path and updating the /etc/dhcpcd.conf file to change to a static address.
In this change - the DNS server is being set to what was configured as the PI_HOLE_DNS1 / PI_HOLE_DNS1. This seems wrong - as it will immediately break local resolution.
Maybe this is because I specified custom DNS servers? (vs using google/quad9/etc)
My core question here is why is the install script like this? Sure - I've 'fixed' the problem by modifying /etc/hosts to read
$ cat /etc/hosts
127.0.0.1 localhost myhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
By doing this - sudo now can resolve 'myhost' and is happy - and the www-data errors have also gone away.
I suspect many users have installed pi-hole this way - and aside from the web UI being a bit slower - they are unaware as they are not checking any emails going to root@myhost and they aren't watching their logs either.
This is a great community - I value the time and effort people put in to help others here.