Overview
I turned a Raspberry Pi into a DNS sinkhole that filters ads, trackers, and known malicious domains for every device on my network, with no software installed on each device. I also set it up to work with a travel router, so the filtering follows me beyond my home network.
Later I added a live status display on an ESP32 and turned an old HP EliteDesk into a home file server. Those builds are covered further down.
What it does
Every time a device visits a website, it first asks a DNS server to translate the name (like google.com) into an IP address. Normally that server is your ISP’s or a public one like Google’s.
With Pi-hole in place, the flow looks like this:
- A device asks the Pi-hole for the IP of a domain.
- If the domain is on a blocklist (ad networks, trackers, malware hosts), Pi-hole answers with a dead-end response and it never loads.
- If the domain is good, Pi-hole forwards the request to an upstream resolver (Cloudflare, Quad9, etc.) and returns the real answer.
Benefits:
- Network-wide ad and tracker blocking, including on devices that can’t run ad blockers (smart TVs, IoT devices, game consoles)
- Protection against known malicious domains
- Visibility: a dashboard and query log show every domain each device requests
- Faster browsing, since blocked content never downloads
Hardware and software
- Raspberry Pi (preferably wired over Ethernet)
- microSD card
- Raspberry Pi OS Lite, flashed with Raspberry Pi Imager
- Pi-hole
- Home router with editable DHCP/DNS settings
- Travel router/repeater (for the portable part)
Step 1: Flash and prepare the Raspberry Pi
- Use Raspberry Pi Imager to write Raspberry Pi OS to the SD card.
- In the Imager’s advanced settings, set a hostname, enable SSH, create a username and password, and (if not using Ethernet) enter Wi-Fi credentials.
- Boot the Pi and connect over SSH.
- Update the system:
sudo apt update && sudo apt full-upgrade -y
Step 2: Give the Pi a static IP
DNS clients need to find the Pi-hole at the same address every time. If its IP changes, every device on the network loses DNS. There are two ways to do this:
- DHCP reservation on the router (recommended): tie the Pi’s MAC address to a fixed IP in the router’s DHCP settings.
- Static IP on the Pi itself: set it with
nmclior through Pi-hole’s installer.
I assigned a static address (for example, 192.168.1.50) outside the router’s normal DHCP pool.
Lesson learned: the MAC address changed after reimaging
After reimaging the Pi, my router showed a new MAC address, which broke the reservation. A Pi has separate MACs for Ethernet (eth0) and Wi-Fi (wlan0), and newer Raspberry Pi OS versions using NetworkManager can randomize the Wi-Fi MAC. Running ip link shows the real values. The fixes:
- Use Ethernet, whose MAC stays constant.
- On Wi-Fi, disable randomization:
sudo nmcli connection modify "YourWiFiName" 802-11-wireless.cloned-mac-address permanent
- Update the router’s reservation with the Pi’s current MAC.
Step 3: Install Pi-hole
Run the official installer:
curl -sSL https://install.pi-hole.net | bash
During setup, I:
- Confirmed the static IP
- Chose an upstream DNS provider (Cloudflare or Quad9)
- Kept the default blocklist
- Enabled query logging
Afterward, I set the admin password with pihole setpassword and logged in to the web dashboard at http://<pi-ip>/admin.
Important: the upstream DNS setting (Settings → DNS) is where Pi-hole sends its questions. It should never point to the Pi-hole itself or, generally, to the router.
Step 4: Point the network at the Pi-hole
Running Pi-hole doesn’t protect anything until devices actually use it. The router needs to hand out the Pi-hole’s IP as the DNS server to every client.
- Log in to the router and find the DHCP / LAN settings.
- Set the DNS server to the Pi-hole’s static IP (
192.168.1.50). - Remove any secondary DNS (like
8.8.8.8). Devices will sometimes use it and bypass the filtering. - Save and apply. A full factory reset isn’t needed; at most a router reboot helps.
Lesson learned: the router’s direction matters
My first attempt didn’t work because I thought about it backwards. The router points to the Pi-hole, not the other way around. Also, many routers have separate WAN/Internet DNS and DHCP/LAN DNS fields. The WAN one only affects the router itself, while the DHCP/LAN one is what gets handed to clients.
If a router (often ISP-provided) won’t let you change DHCP DNS, the fallback is to disable the router’s DHCP server and enable DHCP in the Pi-hole (Settings → DHCP) so it controls everything.
Step 5: Refresh the clients
Devices keep their old DNS until their DHCP lease renews. To force it:
- Toggle Wi-Fi or airplane mode on phones
- Windows:
ipconfig /release, thenipconfig /renew, andipconfig /flushdns - Mac:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Or simply reboot the device
Step 6: Verify it works
- On a client, run
nslookup google.com. The “Server” line should show the Pi-hole’s IP. - Open the Pi-hole dashboard and confirm queries from your devices appear in the Query Log.
- Visit an ad-heavy site, or a public ad-block test page, to confirm ads disappear.
Step 7: Extending it to a travel router
My travel router/repeater was handing out its own DNS settings, so I removed all of them and set only the Pi-hole’s IP as the DNS server, with the option to override DNS for all connected clients.
There was one catch. The travel router creates its own subnet (for example, 192.168.8.x) separate from the home network (192.168.1.x), and Pi-hole ignores queries from outside its local subnet by default. The fix is in the Pi-hole: Settings → DNS → Interface settings → Permit all origins. This is safe as long as the Pi-hole is not exposed to the internet.
Two side effects to note:
- Because the travel router uses NAT, the Pi-hole sees all those devices as a single client: the travel router.
- This only works while the travel router can reach the Pi-hole’s local IP, meaning at home. Away from home, that private address isn’t reachable, so the setup would need a secure tunnel back home or a switch to public DNS.
Step 8: Blocklists and allowlists
In the web dashboard under Domains (and Lists), you can add a blocklist or allowlist from a URL, such as a list maintained on GitHub, or type in individual domains yourself.
Steven Black’s list is enabled by default, which covers a good portion to start with, and there are plenty of community lists worth skimming.
The more you add to the blocklist, the higher the chance that someone on the network complains that a site or app is broken. Add aggressively, but keep the allowlist handy.
Troubleshooting cheat sheet
| Symptom | Likely cause | Fix |
|---|---|---|
| No change after setting DNS | Entered in WAN field, not DHCP/LAN | Move it to the DHCP/LAN DNS field |
| Device still shows old DNS | Old DHCP lease | Renew lease or reconnect |
| Some ads still appear | Secondary DNS set, hardcoded DNS, or DNS-over-HTTPS in the browser | Remove secondary DNS, disable browser DoH |
| Pi-hole ignores some devices | Different subnet | Permit all origins |
| Everything broke after reimaging | New MAC, so the reservation no longer matches | Update reservation or use Ethernet |
| Internet down entirely | Pi-hole is offline or its IP changed | Check Pi power and IP |
Security notes
- Never expose the Pi-hole’s port 53 or web interface to the public internet.
- Use a strong admin password.
- Keep the Pi and Pi-hole updated (
pihole -up). - Blocking is DNS-based. It won’t stop ads served from the same domain as the content (like some YouTube ads).
Part 2: An ESP32 Pi-hole display
The hardware
- Inland ESP-WROOM-32 dev board (an ESP32 with a Silicon Labs CP210x USB-to-serial chip)
- Waveshare 2-inch IPS LCD, 240×320, ST7789 controller, SPI interface
- A prebuilt project: PlatformIO firmware, a 320×240 animated GIF, and flash scripts
Step 0: Will this project work with my hardware?
Before flashing anything, I inspected the project files. Three checks mattered:
- Display driver. The build config selected the ST7789 driver at 240×320 with color inversion on. Waveshare’s panel normally needs inversion, so that matched.
- Pin map. The firmware expected a specific wiring (table below). All pins were valid general-purpose GPIOs.
- Storage. The GIF was 320×240, 54 frames, about 820 KB. The default ESP32 4 MB partition layout leaves roughly 1.4 MB for a filesystem, so it fits. The compiled firmware used about 76% of its 1.3 MB app partition.
| Screen pin | ESP32 GPIO |
|---|---|
| VCC | 3V3 |
| GND | GND |
| DIN (MOSI) | 23 |
| CLK (SCK) | 18 |
| CS | 5 |
| DC | 27 |
| RST | 33 |
| BL (backlight) | 32 |
Step 1: Does the PC see the board?
The CP210x chip turns the ESP32’s UART into a USB serial port. Windows needs its driver, and then the board shows up in Device Manager → Ports (COM & LPT) as “Silicon Labs CP210x USB to UART Bridge (COMx)”. The flashing tool (esptool, installed by PlatformIO) finds the COM port itself.
Common failure: a charge-only USB cable. If the port never appears, swap cables before blaming drivers.
Step 2: Flashing
The included flash.bat creates a Python virtual environment, installs PlatformIO, downloads the ESP32 toolchain and libraries, then does two uploads:
- Firmware (the compiled program) into the app partition.
- Filesystem image (the GIF) into a separate LittleFS partition.
The first run took over five minutes, almost all of it downloads. The log showed the chip as an ESP32-D0WD-V3, the COM port auto-detected, and “Hash of data verified” after each write. That line is your proof the bytes on the chip match the file you sent.
Mistake #1: “I don’t see the GIF anywhere”
Both stages printed SUCCESS, but I couldn’t find the GIF and assumed the upload failed. Two things were going on:
- The GIF isn’t a file on the PC after flashing. It lives inside the ESP32’s flash memory, in its own partition, and only the firmware can read it.
- I hadn’t wired the screen yet, so there was nothing to display it on.
Lesson: “flash succeeded” and “I can see output” are different checkpoints. Verify the log first, then the hardware.
Mistake #2: Unlabeled wires and mismatched pin names
The display came with an 8-wire cable, and the ESP32 headers used labels like “IO23” while my instructions said “D23”. Both refer to GPIO 23. Always match the number.
Worse, I guessed the cable colors from Waveshare’s usual scheme (red for VCC, black for GND, and so on). The guess was wrong. The actual cable was:
| Wire color | Signal |
|---|---|
| Purple | VCC |
| White | GND |
| Green | DIN |
| Orange | CLK |
| Yellow | CS |
| Blue | DC |
| Brown | RST |
| Grey | BL |
Lesson: wire colors are not a standard. Trust the labels printed on the board, and double-check power and ground before applying power. Reversing VCC and GND is the one mistake here that can destroy a part.
How the display actually works
- SPI is a serial bus: MOSI (labeled DIN here) carries data, SCK (CLK) is the shared clock, and CS selects the chip. The ESP32 is the controller and the screen is the peripheral, so only one data direction is needed.
- DC (data/command) tells the ST7789 whether the byte on the bus is a command (like “set the drawing window”) or pixel data.
- RST hard-resets the controller at startup. BL switches the backlight.
- Pixels are sent as 16-bit RGB565. That’s why color-order and byte-swap settings exist, and why wrong settings give red/blue swapped or negative-looking colors.
- The AnimatedGIF library decodes the GIF one scanline at a time and hands each line to a callback, which pushes it to the screen through TFT_eSPI. This keeps RAM use low, because the whole frame never has to sit in memory.
- A LittleFS partition holds the GIF separately from the firmware. That’s why you can change the animation without recompiling the program.
Mistake #3: Wrong Pi-hole IP
The animation played, but the counters stayed at ---.
The first clue came from the router: the ESP32 appeared in the connected-devices list. That proved the Wi-Fi credentials were correct and the board was on the network, which cut the problem in half. The remaining suspects were the Pi-hole address and Pi-hole authentication.
I tried the Pi-hole’s API in a browser from another device. It failed, so the address was wrong. The firmware pointed at ...208; the Pi-hole was actually at ...209. One digit. I corrected the address, re-ran flash.bat, and the counters came alive with green status squares.
Why it works: Pi-hole v6 exposes a REST API. The ESP32 runs the networking in a separate task (so a slow HTTP request never freezes the animation), requests the summary stats over HTTP, parses the JSON with ArduinoJson, and updates the counters. If the Pi-hole has a web password set, the firmware must authenticate first. A wrong IP produces exactly the symptom I saw: everything looks healthy except the data.
Lesson: get the real IP from your router’s device list, then give the Pi-hole a DHCP reservation so it never moves.
Security notes for the display
- Wi-Fi and Pi-hole credentials are compiled into the firmware as plain text. Anyone with the firmware file (or the project zip) can read them. Don’t share the project publicly without removing them.
- The ESP32 only needs to reach the Pi-hole on your LAN. Keep it off guest networks, and never port-forward to it.
- Use a DHCP reservation for both the ESP32 and the Pi-hole to avoid mystery outages after a router reboot.
Part 3: Turning an old PC into a file server
The plan: TrueNAS
My first idea was TrueNAS Community Edition. It’s free and built on ZFS. A few facts shaped what happened next:
- TrueNAS is a dedicated operating system. It takes over the whole machine, so you can’t run it alongside Windows as a normal desktop.
- It wants its own boot drive, separate from the storage drives, and advises against USB sticks because cheap ones wear out quickly.
- ZFS benefits from plenty of RAM (8 GB is a sensible floor) and from multiple drives for redundancy.
My machine was an HP EliteDesk with a single 1 TB drive holding personal files, and I couldn’t add a second drive.
Mistake #4: Choosing the tool before checking the constraints
Installing TrueNAS on that one drive would have wiped the personal files and turned the entire disk into a boot drive with no room for storage. With only one drive, TrueNAS’s best features (redundancy, snapshots across a pool) also wouldn’t apply.
Decision: keep Windows and share a folder over SMB instead. It costs nothing, risks no data, and meets the actual goal: reach files from other devices on the network.
How Windows file sharing works
Windows file sharing uses the SMB protocol over TCP port 445. A client connects, authenticates with a username and password, and then Windows decides what that user may do. Three layers have to agree:
- Network. Is port 445 reachable? That depends on the network profile (Private vs. Public) and the firewall rules for “File and Printer Sharing”.
- Authentication. Does the account exist, and is the password right? Local accounts must have a password for network logins (blank-password network logins are blocked by default).
- Authorization. There are two permission sets: the share permissions (Advanced Sharing) and the NTFS permissions (Security tab). The effective access is the more restrictive of the two, so both must allow the user.
I used a dedicated local account just for network access, instead of my main login or an administrator account. That’s the principle of least privilege: if those credentials leak, the damage is limited to one folder.
Step 1: Prepare the machine
- Wired Ethernet to the router (more reliable than Wi-Fi).
- Set the network profile to Private.
- Turn on Network discovery and File and printer sharing for Private networks.
- Power settings: sleep set to Never while plugged in.
- BIOS: set “After power loss” to Power On, so the machine recovers by itself after an outage.
Step 2: Create the account and share
Create a local user with a password, create a folder, then share it with that user under Advanced Sharing → Permissions, and grant the same user rights on the Security tab.
Error: “An object named … cannot be found.” In the permissions picker, typing the username returned this. The picker was searching the wrong location, or the account didn’t exist yet. Fix:
- Run
net userin an administrator Command Prompt to see the accounts that exist. - Create the account if needed:
net user <name> <password> /add. - In the picker, click Locations, choose the PC’s own name (not a domain), then use Check Names.
Step 3: Connecting from another device
The sharing account is the identity that clients present when they connect. The server itself keeps running under your normal login. A test from the server’s own desktop isn’t meaningful, because it uses your own permissions and never exercises the share account. Always test from a second device.
The network test that narrowed everything down, from the client PC:
Test-NetConnection <server-ip> -Port 445
The result was TcpTestSucceeded : True. That one line ruled out the firewall, the Private-profile setting, and the Wi-Fi path in one go. From that point on, every remaining problem was authentication or permissions.
System error 1326, “user name or password is incorrect.” The server was reachable but rejected the credentials: an authentication failure. Fixes:
- Use the form
COMPUTERNAME\username(get the name withhostname). - Use a simple password (letters and numbers) while testing, because symbols like
^,&, and%can be mangled by the command line. - Clear stale saved logins with
net use * /delete. (If it prints “There are no entries in the list,” that’s not an error. There was just nothing to clear.)
System error 5, “Access is denied.” This was the most instructive one. Error 1326 means the login failed. Error 5 means the login succeeded and the server then refused access. So progress had been made: the account and password were right, but authorization was failing.
My shared folder was on the Desktop. Folders inside a user profile are locked down to that user, so other accounts can be denied even when the share settings look correct. I rebuilt the share on a plain folder at the root of the drive (C:\NAS) and re-applied permissions. That led to two more detours:
icacls“The system cannot find the file specified”: the folder didn’t exist yet. Fix:mkdir C:\NASand confirm withdir C:\NASbefore applying permissions.icacls“Invalid parameter”: the command used parentheses for inheritance flags, like(OI)(CI)M. PowerShell parses those differently from Command Prompt. Fix: switch tocmd, quote the argument (icacls C:\NAS /grant "user:(OI)(CI)M"), or use the folder’s Properties → Security tab.
After rebuilding the folder and share permissions, the connection finally worked:
net use \\<server-ip>\NAS /user:COMPUTERNAME\<account>
To be honest about the root cause: I never isolated exactly which single setting caused error 5. The likely culprits were the profile-folder permissions or share/NTFS permissions that hadn’t been applied correctly, and what cured it was starting clean on a root-level folder with explicit permissions on both layers.
Step 4: Using it from other devices
- Windows: File Explorer →
\\<server-ip>\NAS, or Map network drive with “Reconnect at sign-in”. - iPhone: Files app → ••• → Connect to Server →
smb://<server-ip>→ Registered User. - Mac: Finder → Go → Connect to Server →
smb://<server-ip>. - Android, TVs, and streaming boxes: apps such as Solid Explorer, VLC, Kodi, or Infuse can browse SMB shares.
Error cheat sheet
| Symptom | Layer | What it means | Fix |
|---|---|---|---|
Counters show ---, ESP32 visible on router | Application | Wi-Fi fine, wrong Pi-hole address or auth | Correct the IP, add the password if needed, re-flash |
| ”SUCCESS” but no GIF visible | Expectation | GIF is inside ESP32 flash, no screen attached | Wire the screen |
| ”Object cannot be found” in the share picker | Account lookup | Wrong search location or account missing | net user, then Locations → PC name |
TcpTestSucceeded : True | Network | Port 445 reachable | Look at login and permissions next |
| System error 1326 | Authentication | Wrong username or password | Use PCNAME\user, simple password |
| System error 5 | Authorization | Login OK, access refused | Move to a root-level folder, set both share and NTFS permissions |
icacls “cannot find the file” | Filesystem | Folder doesn’t exist | mkdir, then dir to confirm |
icacls “Invalid parameter” | Shell parsing | PowerShell mangled the syntax | Use cmd, quote the argument, or use the GUI |
Hardening and reliability checklist
- Never expose SMB to the internet. Port-forwarded file sharing has a long history of worm and ransomware exploitation. For remote access, use a VPN such as WireGuard or Tailscale.
- Replace test passwords with long, unique ones once everything works.
- Least privilege. Use a dedicated, non-administrator account for the share.
- Keep it patched, and avoid enabling legacy SMBv1.
- DHCP reservations for the server, the Pi-hole, and the ESP32 so their IPs never change.
- Back it up. A single drive is a single point of failure, and RAID wouldn’t replace backups anyway. Follow the 3-2-1 rule: three copies, two media types, one off-site.
- Power recovery. Sleep off, BIOS set to power on after AC loss.
Takeaways
- Direction matters. The router points to the Pi-hole, and the DHCP/LAN DNS field is the one clients see, not the WAN field.
- Verify each layer before moving to the next. Device Manager, then the flash log, then the screen, then the network, then the credentials. Every bug I hit lived in exactly one layer.
- Read the error number, not just the message. 1326 versus 5 told me whether I had an authentication problem or an authorization problem.
- Check constraints before choosing tools. TrueNAS is excellent, but not on one drive holding data you want to keep.
- Don’t trust guesses about hardware. My assumed wire colors were wrong. The labels on the board were right.
- Credentials in code and config are a security issue. Treat any project zip containing Wi-Fi details like a password.