Writing a MicroPython Pi-hole for the ESP8266
Pi-hole is a self-hosted, domain-blocking DNS resolver, which I've been running as my home network's primary DNS server for a while (using Docker). It's excellent software, and can run on very low-power hardware -- even a Raspberry Pi Zero! However, I wanted to take things a step further. I had a few ESP8266-based NodeMCU V3 boards loaded with MicroPython lying around, so I set out to replicate (some) of the Pi-hole featureset on a platform with 128 kilobytes of RAM. NodeMCU V3 board I found this incredibly useful blog post written by James Routley detailing a bit-level breakdown of DNS queries and responses with some sample Python code, which I used to help me write the packet parsing/creation functions. I quickly ran into my first problem -- MicroPython omits a lot of default Python3 modules, like binascii, for the sake of saving space. So, I ended up only importing the modules socket (to send/recieve data), gc (MicroPython garbage collection, so I could manuall...