The ESP32-C3 Adblock project implements a DNS sinkhole that blocks advertising and tracking domains by storing them as 40-bit FNV-1a hashes in flash memory rather than as strings in RAM. This approach allows the device to maintain a blocklist of 537,000 domains while using only approximately 50 KB of RAM, compared to the ~2.5 MB of RAM required if domain strings were stored directly. The system performs lookups through binary search of the sorted hash table, achieving approximately 10 ms query resolution time as reported in the project documentation.
At its core, the device functions as a UDP DNS sinkhole: when a DNS query arrives, it extracts the domain, calculates its FNV-1a hash (with parent suffixes for subdomain matching), and binary-searches this hash in the flash-stored table. On a match, it returns 0.0.0.0 to effectively block the domain; on a miss, it forwards the query to an upstream DNS resolver and relays the response. The project includes a web dashboard for management, accessible via mDNS at http://c3adblock.local, which allows users to view statistics, ban specific clients, add custom blocked domains, and configure over-the-air updates for both the blocklist and firmware through a browser interface.
The image illustrates the UDP DNS sinkhole mechanism and web dashboard described in the article, showing how the ESP32-C3 adblocker processes DNS queries and provides user management.
Despite its innovative approach, the project acknowledges inherent limitations in its hash-based blocking method. With 40-bit hashes storing 537,000 domains, the system expects approximately one hash collision where a non-blocked domain shares a hash with a blocked domain, resulting in false positives (over-blocking). While the documentation notes that collisions between two blocked domains are inconsequential (both should be blocked anyway), it does not detail mechanisms for resolving false-positive collisions beyond the web dashboard's /unblock API. Additionally, the device's technical constraints mean it cannot implement more sophisticated blocking rules like regex patterns or wildcards, which are skipped during blocklist compilation, limiting its filtering capabilities compared to more advanced solutions.