I’ve finally had some time to set up Pi-hole on my Raspberry Pi. For most parts, I followed the excellent tutorial on the Raspberry Pi website – more details below.
More recently, I came across this Hackernews thread which mentions some interesting alternatives, including AdGuard Home and NextDNS.
ssh <user>@<host>.local
, for example: mloning@anon.local
(“ânon” meaning little donkey in French).sudo apt-get update && sudo apt-get upgrade --yes && sudo reboot
.A few useful commands:
sudo shutdown -h now
to shut down. To start it again, re-connect the power cablesudo reboot
to restarthtop
for monitoring processes and resource usageFor an easier login experience, you can use an ssh key. This allows you to login without having to type your password every time. From your usual computer:
eval "$(ssh-agent -s)"
.ssh-keygen -f ~/.ssh/<key-name> -C <user>
, for example: ssh-keygen -f ~/.ssh/id_raspberrypi -C <user>
.ssh-copy-id -i ~/.ssh/<key-name>.pub <user>@<host>.local
, for example: ssh-copy-id -i ~/.ssh/id_raspberrypi.pub mloning@anon.local
.You should now be able to connect without your password using: ssh <user>@<host>.local
.
To make this even easier, you can configure ssh settings in ~/.ssh/config
.
For example:
Host anon
HostName anon.local
User mloning
IdentityFile ~/.ssh/id_raspberrypi
UseKeyChain yes
AddKeysToAgent yes
You should now be able to simply run: ssh anon
.
To log out, simply run: exit
.
From the Raspberry Pi, run:
nmcli device status
, or specifically: nmcli device show eth0
for the eth0
interface, to verify that Network Manager manages the devicenmcli connection show
to get the current connection namesudo nmcli connection modify <name> ...
to modify the connection, for example: sudo nmcli connection modify "Wired connection 1" ipv4.method "manual" ipv4.addresses "192.168.1.19/24" ipv4.gateway "192.168.1.1"
sudo systemctl restart NetworkManager
to restart Network ManagerAlternatively, you can use the terminal UI mntui
(see this blog post for details).
You can also set the static IP from your router’s admin page:
If you don’t know the address of your router’s admin page, you can find it using: nmcli -f IP4.GATEWAY device show wlan0
, assuming your computer is connected via wlan0
.
On the Raspberry Pi:
curl -sSL https://install.pi-hole.net | bash
.In the tutorial, the Raspberry Pi is connected via WiFi, with the wlan0
interface being configured in the installation. If you can connect via an Ethernet cable using eth0
for the interface, that’s usually the preferred choice as it’s more reliable.
After the installation, check if Pi-hole is running:
pihole status
,pihole -c
to open the console dashboard.If you want to reconfigure Pi-hole later, you can always run: pihole -r
and select “reconfigure”.
My router did not allow me to set a DNS server, so I configured Pi-hole as my DHCP provider instead. For other options, see the tutorial.
From your router’s admin page:
Next, open the Pi-hole admin dashboard in your browser at: http://<host>/admin/
(for example, http://anon.local/admin/
) using the admin password from the Pi-hole installation step above.
From the Pi-hole admin dashboard:
You may want to restart your router afterwards. On your computer, you can also try to renew your IP address from the DHCP server. Your usual computer should then show up under the “Currently active DHCP leases” on the Pi-hole admin dashboard “DHCP” settings page.
Finally, verify that Pi-hole is working:
To update Pi-hole, run: pihole -up
.