HeadlinesBriefing HeadlinesBriefing.com

ESP32-C3 DNS Ad-Blocker Uses Hash-in-Flash

Hacker News •
×

A Pi-hole-style DNS ad-blocker runs on a $2 ESP32-C3 without PSRAM by storing blocklist domains as sorted 40-bit FNV-1a hashes in flash memory. The project, featured on Tom's Hardware, XDA Developers, and Korben, fits 140,000+ domains in ~0.7 MB of flash with ~10 ms lookup time using only ~50 KB of RAM. Unlike typical ESP32 sinkholes that load domain strings into RAM and require PSRAM, this approach avoids RAM pressure by binary-searching hashes directly from flash.

At 141k domains, hash collisions are negligible (~0); at 537k domains, about one collision occurs. The 40-bit hash size balances flash usage and collision risk—32 bits increases collisions, 64 bits wastes space. The same method scales to larger chips like ESP32-S3, holding ~2.7M domains in 16 MB flash versus ~466k for strings in 8 MB PSRAM.

Hardware requirements include any ESP32-C3 board with 4 MB flash (tested on C3 Super Mini), powered via USB. A printable enclosure is available, with antenna clearance and venting recommended for thermal management. Firmware and blocklist update over Wi-Fi after initial USB flash using PlatformIO.

Web dashboard enables management via /ban, /addblock, etc., protected by WEB_USER/WEB_PASS/OTA_PASS. Build steps involve copying secrets template, building blocklist hash table, and flashing firmware + filesystem.

Source: Hacker News · Summarized by HeadlinesBriefing