For a client exmaple, and quick primer on how DNSBLs work, see my other post about how to perform DNSBL lookups with Node.js. This post will assume you have a basic understanding of how DNSBL servers work, and how to use them so if you are not familiar with DNSBL servers, I recommend reading that post first.
Libraries:
The libraries that I used for this example are:
- dns2: This is used for running the actual DNS server.
- ip-cidr: This is used to match IP addresses against CIDR string (eg- Check if 172.16.1.0/24 contains 172.16.1.42)
The code
This is a quick and dirty example. In an actual production implimentation you would need to use a database such as MySQL. I would also recommend checking against a limited set of IP ranges (CIDR matches from the database) based on the incoming request data.
You can save this example as dnsbl.js, run chmod +x dnsbl.js, and then run the script with ./dnsbl.js.
Remember to customize the configuration and the code to suit your needs.
undefined
If everything is working correctly, you should see something similiar to this when you run the dig command:
undefined