Networking & Embedded Systems

How a $5 Microchip Blocks Ads for an Entire Home Network

An open-source engineer built a full home DNS ad-blocker on a $5 ESP32 microcontroller that holds over half a million blocking rules in just 50KB of memory — showing that the right algorithm beats a powerful server every time.

Blocking ads across a whole house usually means running a small server like Pi-hole on a Raspberry Pi, constantly checking a growing list of millions of advertising domains against every web request your TV, phone and laptop make. That works, but it eats power, needs its own machine, and stores a heavy file in working memory. A software engineer named Mohammed Abozaid asked a different question: what if the whole thing ran on a microcontroller that costs less than a coffee?

The answer hinged on one insight most people miss: you do not need the actual domain names in RAM, only something that represents them. The firmware takes every domain on the block list, runs it through a hash function to produce a fixed-length 40-bit number, and writes those hashes in sorted order directly into the chip’s flash storage. RAM — the tiny 50KB that the $5 ESP32 actually has — is left free to handle the network traffic itself.

When a device asks, “where is that ad network?”, the firmware hashes the query the same way and runs a binary search through the sorted list. A binary search halves the remaining candidates with each step, so even 537,000 entries are resolved in about 10 milliseconds. The matched query gets a fake address and the ad never loads. The whole technique is the same principle that lets your phone keep millions of contacts searchable in a fraction of a second: represent the data compactly, sort it, and search by elimination rather than by reading every entry.

Published as open source, the project has become a favorite example of how algorithmic cleverness can shrink a server-sized task onto the smallest, cheapest hardware imaginable. It is a reminder that in embedded engineering, the bottleneck is rarely the processor — it is usually the way we choose to store a single list.