Originally published at: FTLDNS: Pi-hole’s Own DNS/DHCP server – Pi-hole
What Is FTLDNS™?In a sentence, FTLDNS™ is
dnsmasqblended with Pi-hole's special sauce. We bring the two pieces of software closer together while maintaining maximum compatibility with any updates Simon adds to
The ProblemsWe have used
dnsmasqas our DNS/DHCP server since Pi-hole began. However, as the project has grown and evolved, we reached a point where we started looking into providing our own powerful resolver for a few reasons:
- With FTL, we generate a variety of statistics by interpreting
dnsmasq's log file. While this works, doing it through a middleman (a log file) is obviously quite inefficient
- If a user chooses to disable logging, we're unable to compute any statistics at all
- There are some details of the DNS server we do not have access to (like cache usage) through the log file alone
- Each OS distribution provides a different version of
dnsmasqand this can prevent users for getting a flawless Pi-hole experience
The SolutionAll these problems lead us to the idea of actually integrating a DNS resolver directly into FTL. The obvious choice for this is, of course, to base it on
dnsmasq. We have a proof-of-concept implementation of FTL already developed and running. So we're officially announcing FTLDNS™ and you can find it right here.
One of the many ways to support us is purchasing from our Swag Store. Get your hands on this sweet mug to help spread the word.
The Non-technical Details
FTLDNS has many benefits for you as user:
- No more
dnsmasqversion compatibility issues since we develop and provide the DNS resolver and FTL together
- Upstream updates to
dnsmasqcan easily be integrated into our code since we don't modify its code heavily
- Processing will be much faster since we interact directly with the resolver instead of periodically parsing a log file
- We can provide stats on cache usage and probably much more, which has been previously unavailable
- Due to the direct integration into the resolver (using "FTL hooks"), we can compute statistics without any need for a log file. Instead of a "must have", the log file will become an "opt-in" feature!
The Technical DetailsWe implement
dnsmasqinto our code using the modular nature of the C language. FTL v4.0 has always been multi-threaded for speed and efficiency. On startup, it launches a number of threads, each dedicated for specific tasks. We extend the already existing multi-threading in FTL to provide an even faster experience. After the historic information has been imported from the database, we start the DNS/DHCP resolver.
dnsmasqwith the addition of having threads orbiting it that provide the known FTL statistics on a dedicated Unix socket as well as on a Telnet-like interface. Furthermore, we add some minor speed improvements to enhance the user's experience on low-performance devices when using huge blocking lists.
dnsmasqto the functional minimum to be able to easily upgrade to any future
dnsmasqlater on almost impossible as these customizations would have to be reimplemented and carefully tested each time. Also, changing parts of the resolver's source code could introduce new bugs to a code base that is extensively tested. We clearly want to avoid that! Stability and speed are the two drivers for the development of FTLDNS.
FTLDNS ( FTL v4.0 ), with its integrated resolver is beneficial in many ways
- We can never be sure which version we can expect on user's systems as they run a variety of operating systems. This makes adding new features problematic as old versions of
dnsmasqcould, and have , fail(ed) if provided with unknown options. This will be resolved as we are in direct control of which version of the resolver is getting compiled into our binary. It makes both development and bug-tracing much easier
- We will still leave logging enabled in the early days of FTL v4.0 to ease debugging in cases where it is needed. However, the user will be free to disable the logging at any time without losing any statistics
- Due to that fact that everything is one binary, we have full access to the resolver's internal data structure and can easily provide users with more information, e.g. on cache usage (which has been a feature request for some time now). Although this additional functionality might not be there in the initial release, it will come soon afterwards