🛠 Pi-hole : serveur DNS filtrant sur le NanoPi R5S

NanoPi R5S (FriendlyElec) · intermediaire · Schéma : IMG-nanopi-r5s-intermediaire-3-nanopir5s-pihole-dns.svg — NanoPi R5S routeur hébergeant Pi-hole : requêtes DNS du LAN traversant le port 53, listes de blocage, requêtes autorisées sortant vers le DNS amont

Objectives

Install a filtering DNS server on the NanoPi R5S already acting as a router: either Pi-hole (via DietPi or Docker) or dnsmasq in list-filtering mode. The R5S is ideal for this role: always on, low power consumption, wired Ethernet, and DietPi lists it among supported software titles since v8.20. You will learn how to configure the upstream DNS, redirect port 53 from the LAN, and verify that blocking works.

Hardware

Complete code

#!/bin/bash
# Installation Pi-hole : sur DietPi, dietpi-software installe le paquet
# proprement ; sur Debian, l'installeur officiel (à examiner avant d'exécuter).
sudo apt update && sudo apt install -y pihole   # paquet dispo sur DietPi

# Sur Debian classique, installeur officiel (à examiner avant d'exécuter) :
curl -sSL https://install.pi-hole.net | bash
#   → interface amont : 1.1.1.1 ou le DNS de la box
#   → interface d'écoute : br-lan

# Détourner le DNS du LAN (clients qui ignorent le DHCP) :
sudo iptables -t nat -A PREROUTING -i br-lan -p udp --dport 53 \
    -j DNAT --to-destination 192.168.69.1:53

# Vérifier l'écoute et le filtrage
ss -lunp | grep ':53'
nslookup doubleclick.net 127.0.0.1        # doit répondre 0.0.0.0
nslookup example.com 127.0.0.1            # doit résoudre normalement

# Statistiques / console d'admin
curl -s http://127.0.0.1/admin | head -n 5

Expected verification

ss -lunp shows pihole-FTL listening on port 53. A query for nslookup doubleclick.net returns 0.0.0.0 (blocked), while an allowed domain resolves normally. The admin console at http://192.168.69.1/admin displays LAN queries. DHCP clients point to 192.168.69.1. The RK3568B2 easily handles domestic DNS traffic (several thousand queries/s).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials