Skip to content

Commit a1ded8c

Browse files
committed
Pi-hole: docs to setup DNS for esphome devices
1 parent 0067812 commit a1ded8c

File tree

1 file changed

+59
-4
lines changed

1 file changed

+59
-4
lines changed

docs/Containers/Pi-hole.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,63 @@
11
# Pi-hole
2-
Pi-hole is a fantastic utility to reduce ads
2+
Pi-hole is a fantastic utility to reduce ads.
33

4-
The interface can be found on `"your_ip":8089/admin`
4+
The interface can be found on `http://"your_ip":8089/admin`
55

6-
Default password is `pihole`. This can be changed in the `~/IOTstack/services/pihole/pihole.env` file
6+
Default password is `IOtSt4ckP1Hol3`. This can be changed with:
7+
```
8+
docker exec pihole pihole -a -p myNewPassword
9+
```
710

8-
To enable your router to use the pihole container edit your DNS settings on your router to point to your Pi's IP address
11+
## DNS server for ESPhome devices
12+
13+
If you want to avoid hardcoding your Raspberry Pi ip on your ESPhome devices, you need
14+
a DNS server that will do the resolving. This can be done using the Pi-hole container.
15+
16+
Assuming your pihole hostname is `raspberrypi` and has the IP `192.168.1.10`:
17+
18+
1. Go to the Pi-hole web interface: `http://raspberrypi.local:8089/admin` and Login
19+
2. From Left menu: Select Local DNS -> DNS Records
20+
3. Enter Domain: `raspberrypi.home.arpa` and IP Address: `192.168.1.10`. Press Add.
21+
4. Go to your DHCP server, usually your Wireless Access Point / WLAN Router web interface:
22+
5. Find where DNS servers are defined
23+
6. Change all DNS fields to `192.168.1.10`.
24+
7. All local machines have to be rebooted or have their DHCP leases released. Without this they will continue to use the old DNS setting from an old DHCP lease for quite some time.
25+
26+
Now you can use `raspberrypi.home.arpa` as the domain name for the Raspberry Pi in your whole local network.
27+
28+
For the Raspberry Pi itself to also use the Pi-hole DNS server, run:
29+
```bash
30+
echo "name_servers=127.0.0.1" | sudo tee -a /etc/resolvconf.conf
31+
echo "name_servers_append=8.8.8.8" | sudo tee -a /etc/resolvconf.conf
32+
echo "resolv_conf_local_only=NO" | sudo tee -a /etc/resolvconf.conf
33+
sudo resolvconf -u # Ignore "Too few arguments."-complaint
34+
```
35+
Quick explanation: resolv_conf_local_only is disabled and a public nameserver is added, so that in case the Pi-hole container is stopped, the whole Raspberry won't completely lose DNS functionality.
36+
37+
### Testing & Troubleshooting
38+
39+
Install dig:
40+
```
41+
apt install dnsutils
42+
```
43+
44+
Test that pi-hole is correctly configured (should respond 192.168.1.10):
45+
```
46+
dig raspberrypi.home.arpa @192.168.1.10
47+
```
48+
49+
To test on your desktop if your network configuration is correct, and an ESP will resolve its DNS queries correctly, restart your desktop machine to ensure DNS changes are updated and then use:
50+
```
51+
dig raspberrypi.home.arpa
52+
```
53+
This should produce the same result as the previous command.
54+
55+
If this fails to resolve the IP, check that the server in the response is `192.168.1.10`.
56+
If it's `127.0.0.xx` check `/etc/resolv.conf` begins with `nameserver 192.168.1.10`.
57+
58+
## Why .home.arpa?
59+
60+
Instead of `.home.arpa` - which is the real standard, but a mouthful - you may use `.internal`.
61+
Using `.local` would technically also work, but it should be reserved only for mDNS use.
62+
63+
Note: There is a special case for `.local` addresses. If you do a `ping raspberrypi.local` on your desktop linux or the RPI, it will first try using mDNS/bonjour to resolve the IP address raspberrypi.local. If this fails it will ask the DNS server. Esphome devices can't use mDNS to resolve an IP address, so you need a proper DNS server to respond to queries made by an ESP. As such, `dig raspberrypi.local` will fail, simulating ESPhome device behavior. This is as intended.

0 commit comments

Comments
 (0)