Skip to content

Commit a15ae1f

Browse files
Pi-hole: improve docs
includes some changes from #501 Fixes #500 Co-authored-by: ukkopahis <[email protected]>
1 parent 383d213 commit a15ae1f

File tree

1 file changed

+82
-25
lines changed

1 file changed

+82
-25
lines changed

docs/Containers/Pi-hole.md

Lines changed: 82 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,82 @@
11
# Pi-hole
22
Pi-hole is a fantastic utility to reduce ads.
33

4-
The interface can be found on `http://"your_ip":8089/admin`
4+
The web interface can be found at `http://«your_ip»:8089/admin`
5+
where «your_ip» can be:
56

6-
Default password is `IOtSt4ckP1Hol3`. This can be changed with:
7+
* The IP address of the Raspberry Pi running Pi-hole.
8+
* The domain name of the Raspberry Pi running Pi-hole.
9+
* The multicast DNS name (eg "raspberrypi.local") of the Raspberry Pi running
10+
Pi-hole.
11+
12+
Default password is random, it can be changed by running:
713
```
8-
docker exec pihole pihole -a -p myNewPassword
14+
docker-compose exec pihole pihole -a -p myNewPassword
915
```
1016

11-
## Pi-hole as DNS server
17+
References:
18+
19+
* [Pi-hole on GitHub](https://github.com/pi-hole/docker-pi-hole)
20+
* [Pi-hole on Dockerhub](https://hub.docker.com/r/pihole/pihole)
21+
22+
## Environment variables
23+
24+
Environment variables govern much of Pi-hole's behaviour. If you are running new
25+
menu (master branch), the variables are inline in `docker-compose.yml`. If you
26+
are running old menu, the variables will be in:
27+
`~/IOTstack/services/pihole/pihole.env`
28+
29+
The first time Pi-hole is launched, it checks for the `WEBPASSWORD` environment
30+
variable. If found, sets the initial password.
31+
32+
Pi-hole supports a [long list of environment
33+
variables](https://github.com/pi-hole/docker-pi-hole#environment-variables).
34+
35+
## Using Pi-hole as your DNS resolver
36+
37+
In order for the Pi-hole to ad-block or resolve anything, it needs to be
38+
defined as the DNS server. This can either be done manually to each device or
39+
you can define it as a DNS-nameserver for the whole LAN.
1240

13-
In order for the Pi-hole to work, it needs to be defined as the DNS server.
14-
This can either be done manually to each device or you can define it as a
15-
DNS-nameserver for the whole LAN.
41+
Note that using Pi-hole for clients on your network pretty much **requires** the
42+
Raspberry Pi running Pi-hole to have a fixed IP address.
1643

17-
Assuming your pihole hostname is `raspberrypi` and has the IP `192.168.1.10`:
44+
Assuming your RPi hostname is `raspberrypi` and has the static IP
45+
`192.168.1.10`:
1846

19-
1. Go to the Pi-hole web interface: `http://raspberrypi.local:8089/admin` and Login
20-
* From Left menu: Select Local DNS -> DNS Records
21-
* Enter Domain: `raspberrypi.home.arpa` and IP Address: `192.168.1.10`. Press Add.
22-
2. Go to your DHCP server, usually this is your Wireless Access Point / WLAN Router web interface.
47+
1. Go to your network's DHCP server, usually this is your Wireless Access Point
48+
/ WLAN Router.
49+
* Login into its web-interface
2350
* Find where DNS servers are defined
24-
* Change all DNS fields to `192.168.1.10`.
25-
3. 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.
51+
* Change all DNS fields to `192.168.1.10`
52+
2. All local machines have to be rebooted. Without this they will continue to
53+
use the old DNS setting from an old DHCP lease for quite some time.
2654

27-
Now you can use `raspberrypi.home.arpa` as the domain name for the Raspberry Pi in your whole local network.
55+
## Adding domain names
2856

29-
For the Raspberry Pi itself to also use the Pi-hole DNS server, run:
57+
Login to the Pi-hole web interface: `http://raspberrypi.local:8089/admin`:
58+
59+
1. Select from Left menu: Local DNS -> DNS Records
60+
2. Enter Domain: `raspberrypi.home.arpa` and IP Address: `192.168.1.10`. Press
61+
Add.
62+
63+
Now you can use `raspberrypi.home.arpa` as the domain name for the Raspberry Pi
64+
in your whole local network. You can also add domain names for your other
65+
devices, provided they too have static IPs.
66+
67+
The Raspberry Pi itself must also use be configured to use the Pi-hole DNS
68+
server. This is especially important when you add your own domains names,
69+
otherwise DNS may work differently on the Pi than on other devices. Configure
70+
this by running:
3071
```bash
3172
echo "name_servers=127.0.0.1" | sudo tee -a /etc/resolvconf.conf
3273
echo "name_servers_append=8.8.8.8" | sudo tee -a /etc/resolvconf.conf
3374
echo "resolv_conf_local_only=NO" | sudo tee -a /etc/resolvconf.conf
3475
sudo resolvconf -u # Ignore "Too few arguments."-complaint
3576
```
36-
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 Raspberry won't lose DNS functionality. It will just fallback to 8.8.8.8.
77+
Quick explanation: resolv_conf_local_only is disabled and a public nameserver
78+
is added, so that in case the Pi-hole container is stopped, the Raspberry won't
79+
lose DNS functionality. It will just fallback to 8.8.8.8.
3780

3881
### Testing & Troubleshooting
3982

@@ -42,29 +85,43 @@ Install dig:
4285
apt install dnsutils
4386
```
4487

45-
Test that pi-hole is correctly configured (should respond 192.168.1.10):
88+
Test that Pi-hole is correctly configured (should respond 192.168.1.10):
4689
```
4790
dig raspberrypi.home.arpa @192.168.1.10
4891
```
4992

50-
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:
93+
To test on your desktop if your network configuration is correct, and an ESP
94+
will resolve its DNS queries correctly, restart your desktop machine to ensure
95+
DNS changes are updated and then use:
5196
```
5297
dig raspberrypi.home.arpa
5398
```
5499
This should produce the same result as the previous command.
55100

56-
If this fails to resolve the IP, check that the server in the response is `192.168.1.10`.
57-
If it's `127.0.0.xx` check `/etc/resolv.conf` begins with `nameserver 192.168.1.10`.
101+
If this fails to resolve the IP, check that the server in the response is
102+
`192.168.1.10`. If it's `127.0.0.xx` check `/etc/resolv.conf` begins with
103+
`nameserver 192.168.1.10`.
104+
105+
## Why .home.arpa?
106+
107+
Instead of `.home.arpa` - which is the real standard, but a mouthful - you may
108+
use `.internal`. Using `.local` would technically also work, but it should be
109+
reserved only for mDNS use.
58110

59111
## Microcontrollers
60112

61113
If you want to avoid hardcoding your Raspberry Pi IP to your ESPhome devices,
62114
you need a DNS server that will do the resolving. This can be done using the
63115
Pi-hole container as described above.
64116

65-
## Why .home.arpa?
117+
!!! info "`*.local` won't work for ESPhome"
66118

67-
Instead of `.home.arpa` - which is the real standard, but a mouthful - you may use `.internal`.
68-
Using `.local` would technically also work, but it should be reserved only for mDNS use.
119+
There is a special case for resolving `*.local` addresses. If you do a
120+
`ping raspberrypi.local` on your desktop linux or the RPI, it will first
121+
try using mDNS/bonjour to resolve the IP address raspberrypi.local. If this
122+
fails it will then ask the DNS server. Esphome devices can't use mDNS to
123+
resolve an IP address. You need a proper DNS server to respond to queries
124+
made by an ESP. As such, `dig raspberrypi.local` will fail, simulating
125+
ESPhome device behavior. This is as intended, and you should use
126+
raspberrypi.home.arpa as the address on your ESP-device.
69127

70-
Note: There is a special case for resolving `*.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 then ask the DNS server. Esphome devices can't use mDNS to resolve an IP address. 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, and you should use raspberrypi.home.arpa as the address on your ESP-device.

0 commit comments

Comments
 (0)