Today we are open-sourcing OpenResolve – a Docker image for domain information as a REST-like API. OpenResolve was built as a Master’s Project by Ryan Piaget and Kevin Funk during an internship at OpenDNS. Learn more about the project at OpenResolve.com.

About the Team

2014-12-03 17.21.10 HDR We are graduating Master’s Students at the University of San Francisco who’ve been interning at OpenDNS the last four months working on our Master’s Project.

For our project, we designed and built a public API for retrieving domain information as a REST-like service. This guest post will share the results of our work.

Motivation

OpenResolve aims to address three issues in the realm of domain name lookup:

    

  1. DNS lookup typically requires command line tools like dig, or manual interaction with an HTML interface. Our API makes DNS resolution available as a web service for any application.
  2. DNS lookups are typically conducted over UDP, which offers no security regarding the data being transferred. Performing DNS resolution over HTTP and SSL ensures the data has not been altered.
  3. Most DNS resolution returns output in a human readable format, but isn’t easily accessible programmatically. By transferring data in a commonly consumed format, JSON, we make it convenient for even high-level applications to use the data returned from a resolver.

How It Works

OpenResolve is implemented as a simple python server using the Flask framework, running behind nginx. DNS lookups are performed using the dnspython library and then parsed into JSON before being returned to the client. We implement the provisional RFC draft-bortzmeyer-dns-json-00 for the return format. The server runs inside a container built from a custom Docker image and is hosted on OpenDNS infrastructure.

How to Use It

The API lives at api.openresolve.com and can be queried for standard lookups by making a GET request to:

 api.openresolve.com/<record-type>/<domain-to-lookup>

The response is returned in JSON. Here’s the result of making a request for ‘A’ type records for the domain www.opendns.com:

curl api.openresolve.com/a/www.opendns.com
{
    AA: false,
    ReturnCode: "NOERROR",
    AD: false,
    AdditionalSection: [ ],
    AnswerSection: [
        {
            Class: "IN",
            Address: "67.215.92.218",
            Type: "A",
            Name: "www.opendns.com.",
            TTL: 30
        }
    ],
    ID: 45762,
    AuthoritySection: [ ],
    QuestionSection: {
        Qclass: "IN",
        Qtype: "A",
        Qname: "www.opendns.com."
    },
    RD: true,
    RA: true,
    Query: {
        Duration: 0.003942966461181641,
        Server: "208.67.222.222"
    },
    TC: false
}

We support lookups for these record types:
A, AAAA, CNAME, LOC, MX, NAPTR, NS, PTR, SOA, TXT

We also support internationalized domains via punycode conversion. So, querying: api.openresolve.com/a/ąćęłńóśźż.pl will work just fine!

Additionally, OpenResolve provides support for reverse lookups:

curl api.openresolve.com/reverse/67.215.92.211
{
    AA: false,
    ReturnCode: "NOERROR",
    AD: false,
    AdditionalSection: [ ],
    AnswerSection: [
        {
            Class: "IN",
            Target: "www.opendns.com.",
            Type: "PTR",
            Name: "211.92.215.67.in-addr.arpa.",
            TTL: 764
        }
    ],
    ID: 58757,
    AuthoritySection: [ ],
    QuestionSection: {
        Qclass: "IN",
        Qtype: "PTR",
        Qname: "211.92.215.67.in-addr.arpa."
    },
    RD: true,
    RA: true,
    Query: {
        Duration: 0.004873037338256836,
        Server: "208.67.222.222"
    },
    TC: false
}

Next Steps

In the near future we plan to add the ability to perform ANY-type queries as well as support for who-is lookups. We’ve open-sourced the project and made the source available under a BSD License. Fork it on Github, pull the docker image, or try the demo at API.OpenResolve.com.

For more information check out OpenResolve.com.

This post is categorized in: