5 ms·
Query DNS via a RESTful HTTP interface
- tlrobinson 17y agoVery cool. It even supports JSONP. Here's a tiny page I threw together to lookup domains: http://tlrobinson.net/misc/domaincheck.html http://tlrobinson.net/misc/domaincheck.html
- yannis 17y agoLove the jq comment!:) +1
- moe 17y agoWhy?
- jf 17y agoThis is part of a domain name registration service that I'm writing with Jeff Lindsay. It's also part of a larger project to make it trivial to work with DNS from "the web". Soon your web server will also be a DNS server.
- tav 17y agoNice work! It's very useful for app developers on platforms like App Engine which don't provide a server-side DNS API. Is http://dig.jsondns.org http://dig.jsondns.org for demonstration only or can we use that as an official deployment to use in our apps? Thanks!
- jf 17y agoFeel free to use http://dig.jsondns.org http://dig.jsondns.org in your applications. I'm glad it's useful! I just can't make any guarantees regarding response time or uptime. If you need guarantees for either of those, you can run the service yourself, the code is on github: http://github.com/jpf/jsondns http://github.com/jpf/jsondns
- bretthoerner 17y ago> Soon your web server will also be a DNS server. Why?
- jf 17y agoSetup, configuration, and maintenance of DNS servers isn't simple. They need to run as root on a server with a static IP. Hosted DNS solutions cost money, don't always support all record types, and rarely have programmatic interfaces. In short, it'll make my life easier. Hopefully yours too.
- sorbits 17y agoI would love a simple way to manage my DNS entries, like a version controlled text file :) I presently use a free service (http://gratisdns.dk http://gratisdns.dk) and also run bind9 for one domain (the free service can act as my backup NS) — I looked at http://cr.yp.to/djbdns.html http://cr.yp.to/djbdns.html in my quest for something simpler, but I wasn’t swayed. Your comment made me optimistic, but correct me if I am wrong, but dig.jsondns.org is completely unrelated to any of this — what I would need is http://github.com/jpf/eventdns http://github.com/jpf/eventdns and dig.jsondns.org is more of a test server for EventDNS if I am not mistaken?
- jf 17y agoSo yeah, after I make some changes to eventdns, you'll be able to use that to host DNS from a text file. The path to the files and format will be the same as what dig.jsondns.org returns.
- est 17y ago> Setup, configuration, and maintenance of BIND servers isn't simple. FTFY
- cperciva 17y agoOf course, in order for this to work, your HTTP client starts by doing a DNS lookup for dig.jsondns.org...
- jf 17y agoOf course! I'm not looking to replace DNS, just make it easier to use.
- timdorr 17y agoOnly problem I see is that the results are cached. If you're trying to build a live lookup tool, then that sort of kills it. I would love an API for DNS that is non-cached so I can build tools for my support techs.
- jf 17y agoThese results are cached on my end and also by the server I'm querying (Google Public DNS). Non-cached (non recursive) queries are part of the standard that I'm coding towards. I just haven't implemented them yet.
- tlrobinson 17y agoHTTP caching maps nicely to DNS TTLs...
- jf 17y agoYes they do: http://github.com/jpf/jsondns/blob/master/jsondns.rb#L66 http://github.com/jpf/jsondns/blob/master/jsondns.rb#L66 HTTP Status Codes also map pretty nicely to DNS RCODEs.
- IsaacSchlueter 17y agoPlease serve JSON with the application/json content-type, not text/html. If you want to debug it more easily in a browser, you can install the JSONView Firefox extension. It's quite handy: https://addons.mozilla.org/en-US/firefox/addon/10869 https://addons.mozilla.org/en-US/firefox/addon/10869
- qeorge 17y agoUnfortunately, IE chokes on application/json. So its actually safer to use application/javascript, or even text/html instead. This was still present in IE7, but they may have fixed it in IE8.
- diN0bot 17y agothen let IE choke.
- bkudria 17y agoUm, so? Why exactly would you be using IE to retrieve JSON? It's an API, right?
- litewulf 17y agoPresumably as part of an AJAX request?
- qeorge 17y agoThere's all kinds of client side uses for APIs. Facebook Connect logins for instance, which can't be initiated server side. Sending application/json to older versions of IE can cause it to pop up Save As dialogs, even in AJAX requests. They did the same thing with application/xml+xhtml.
- i386 17y agoHow about serve up different mime types for different agents? That way its only broken for the broken browser.
- erbuhqergwer 17y agoI notice you're using Googles DNS servers to do the lookups. This means it will "incorrectly" return NXDOMAINs for any spamhaus.org DNSBL lookup. For example: http://dig.jsondns.org/IN/2.0.0.127.zen.spamhaus.org/A http://dig.jsondns.org/IN/2.0.0.127.zen.spamhaus.org/A Yet doing the lookup using my own DNS server: root@haven:~# host -t a 2.0.0.127.zen.spamhaus.org 2.0.0.127.zen.spamhaus.org A 127.0.0.2 2.0.0.127.zen.spamhaus.org A 127.0.0.4 2.0.0.127.zen.spamhaus.org A 127.0.0.10 root@haven:~#
- jf 17y agoInteresting. Do you have any suggestions for a better DNS server to use?
- erbuhqergwer 17y agoYou'll probably end up with the same issues with any publicly accessible recursive resolver. The only way to be sure you're getting "good" DNS responses is to use your own.
- jf 17y agoThe DNS library I'm using supports doing recursive queries - that'll likely be the next feature I'll add to dig.jsondns.
- erbuhqergwer 17y agoIt doesn't appear to handle SRV records either. These are used for various things eg the extremely widely used SIP protocol.
- jf 17y agoReally? It should support SRV records. Can you give me an example to help me track down the bug?
- erbuhqergwer 17y agoMy mistake. I was looking up the SRV record for _sip._tcp.grepular.com and assumed that the reason it failed was because it didn't support SRV. The failure was the underscores though, which you've now fixed.
- erbuhqergwer 17y agoHmmm, I think it might have problems with underscores in hostnames. Before you say that underscores aren't valid, they very much are. They're used for DKIM and SIP for example: root@haven:~# host -t txt dkim1._domainkey.grepular.com dkim1._domainkey.grepular.com TXT "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwe0CGlJQq6Y0poniuhn80rsC1kKrcVg19STXqgM8wxe4HidRjr8KfSfCo0wcgqVq8saqsB0JCt2WOquRlUG5qRtrZag6G/wpYkRYCjYm8VsaJDxNZFpiauXeyz9HGKkHTo2QxLVIYFzkSo7ZtRQNnUB1N12/v5BscLk6X1DlmawIDAQAB" root@haven:~# host -t srv _sip._tcp.grepular.com _sip._tcp.grepular.com SRV 10 0 5060 voip.grepular.com root@haven:~# Not just underscores. You can shove almost anything in the hostname part of a dns lookup...
- jf 17y agoHmm, I guess I was being overzealous with my validation. Thanks for the feedback. I'll fix it when I get home tonight.
- jf 17y agoFixed. http://dig.jsondns.org/IN/dkim1._domainkey.grepular.com/TXT http://dig.jsondns.org/IN/dkim1._domainkey.grepular.com/TXT http://dig.jsondns.org/IN/_sip._tcp.grepular.com/SRV http://dig.jsondns.org/IN/_sip._tcp.grepular.com/SRV http://dig.jsondns.org/IN/_jabber._tcp.gmail.com/SRV http://dig.jsondns.org/IN/_jabber._tcp.gmail.com/SRV
- erbuhqergwer 17y agoYou should be able to send multiple dns queries in a single http request.