Query specific DNS server in nodejs with native-dns
The DNS options available to node.js
are a little slim. They only provide a wrapper to c-ares
to the point of doing the simplest of record type lookups. There’s not a useful
or more granular interface for customizing your queries than to modify your
platform’s equivalent of /etc/resolv.conf.
With the idea of customization in mind I created native-dns.
a quick example of how to query the google public DNS servers for the A records
for “www.google.com”. To install native-dns you simply need to “npm install native-dns”.
You of course can use native-dns as a drop in replacement of the builtin ‘dns’
module. And there is even a very basic DNS server which you can use to respond
to DNS requests, semantics of which are beyond the module itself.
You can find the source and more information and examples at the github repository
which is named node-dns because I created it before I realized that was taken in npm.