ESP32 Blocks 537,000 Domains for Ad Blocking, a Clever $5 Implementation
An Egyptian developer uses an ESP32-C3 microcontroller to build a DNS filter capable of blocking 537,000 domains. Leveraging 40-bit FNV-1a hashing, it fits within 4MB of flash memory.
According to a report by Tom’s Hardware journalist Zak Killian, Egyptian full-stack developer ZedAxis has implemented a DNS filter on a $5 microcontroller board that can block 537,000 domains.
Tackling Extreme Resource Constraints
ZedAxis used the ESP32-C3 “SuperMini” board, which has only 400KB of RAM and 4MB of flash memory. Common ad blocklists in plain text range from several MB to over a dozen MB, making direct storage impossible.
ZedAxis addressed this issue with a classic yet effective method: hash compression. Specifically, he adopted a 40-bit FNV-1a hash. A 32-bit hash would cause too many collisions (different domains producing the same hash value), while 64-bit would waste memory. The 40-bit option provided the optimal balance.
This approach successfully stored 537,000 domains in just 4MB of flash memory. The firmware’s RAM usage is kept to about 50KB, and the response time for block determinations reaches a practical 10 milliseconds.
The Cleverness of the Build Process
The true value of this project lies not just in hashing, but in the design of the entire build process. ZedAxis’s system downloads publicly available blocklists during build time, removes duplicate entries and comments, converts each domain into a 40-bit FNV-1a hash value, and writes the sorted hash table to the ESP32’s flash memory.
When a DNS query arrives, the device hashes the requested hostname using the same algorithm, performs a binary search on the sorted hash table. If a match is found, the query is blocked; if not, it is forwarded to an upstream DNS server. This mechanism consumes minimal computational resources for each query.
Positioning in Real-World Use
ZedAxis designed this device as a backup for his home network’s primary DNS filter, Pi-hole (an ad-blocking DNS server running on a Raspberry Pi). The ESP32-based filter automatically takes over processing when the Pi-hole is rebooting or unavailable for any reason.
The ESP32 family is widely known as a Wi-Fi-capable embedded microcontroller, and such network processing is within its capabilities. The ESP32-C3 is a cost-reduced version, lacking the 8MB PSRAM found in higher-priced models. Nevertheless, ZedAxis’s method extracts practical performance from limited resources.
Comparison with Existing Similar Projects
Pi-hole runs on the Raspberry Pi Foundation’s single-board computer and requires a full operating system. Considering the overall power consumption and cost of the system, the ESP32-based solution is orders of magnitude cheaper and consumes extremely low power.
However, Pi-hole offers DHCP server functionality, detailed statistics, and advanced custom filter configuration, so it is not a complete replacement for Pi-hole in terms of features. ZedAxis’s implementation is specifically tailored for backup purposes, extracting only the most critical function (DNS filtering) from limited resources, which is its key value.
Technical Challenges and Limitations
When using 40-bit hash values, the risk of collisions is lower than with 32 bits, but not zero. For 537,000 entries, a 40-bit hash space (about 1 trillion possibilities) is not sufficiently large, and the possibility of incorrect blocking cannot be ruled out, though rare.
Additionally, this implementation requires rebuilding and reflashing the entire firmware to update the blocklist. It does not support dynamic list updates; each time a new ad domain is added, the build process must be executed. This is a clear limitation compared to Pi-hole, which automatically updates periodically.
Potential as Open Source
ZedAxis has published the project on GitHub. By releasing the source code, other developers can customize it for their own use or add new features. The current version also includes a basic GUI for displaying statistics and configuring custom blocked domains.
This project is an excellent example of overcoming embedded system resource constraints through clever algorithms. Particularly, achieving practical performance on low-cost devices like the ESP32 provides insights applicable to IoT and edge computing fields.
Editorial Opinion
This case is highly commendable as an implementation of data compression and search in a severely resource-constrained environment. In the short term, it has practical utility as a backup DNS filter for home networks. For users already running Pi-hole, building a similar backup with an ESP32-C3 (about $5) offers extremely high cost-effectiveness. However, whether the risk of false blocks is acceptable depends on the individual operational environment.
From a long-term perspective, this combination of 40-bit hashing and binary search can be applied to uses beyond ad blocking. Malware domain blocking, parental controls, and access restrictions in corporate networks are among the many areas where this approach can be applied. By adjusting the hash size, it could also support larger datasets.
The editorial team would like to see third-party verification of the actual false positive rate and performance impact of such a lightweight implementation. There may be differences between theoretical collision probability and real-world measurements.
References
- ” Clever hacker fits 537,000 domains in a tiny $5 ESP32 ad-blocking dongle — firmware uses only around 50KB of RAM and can answer blocked lookups in 10 milliseconds ”, by Zak Killian — Tom’s Hardware, 2026-07-19T10:00:00.000Z (ARR)
- Source URL: https://www.tomshardware.com/networking/clever-hacker-fits-537-000-domains-in-a-tiny-usd5-esp32-ad-blocking-dongle-firmware-uses-only-around-50kb-of-ram-and-can-answer-blocked-lookups-in-10-milliseconds
Frequently Asked Questions
- Where can I buy the ESP32-C3?
- It is available on AliExpress, Amazon, and Japanese electronic component mail-order sites. Prices start at around $5. Note that there are multiple variants of the ESP32-C3, so pay attention to flash memory capacity.
- Can I use this ESP32 filter as a main replacement for Pi-hole?
- In terms of features, it is not a complete replacement for Pi-hole. It lacks DHCP server functionality, a detailed management interface, and automatic updates. In particular, dynamic addition of custom filters and fixing false blocks are not easy, so Pi-hole is recommended for primary use.
- How do I update the blocklist?
- Currently, you must download and hash the blocklist on a host PC, rebuild the firmware, and flash it to the ESP32. Automatic update functionality is not implemented.
Comments