HTTPDNS

HTTPDNS provides domain name resolve services over the HTTP interface, with features such as domain name anti-hijacking, precise scheduling, and real-time resolution.

Enable HTTPDNS

  • Enable DNS in the global configuration / DNS page:

  • Add a partition port in the Global Configuration/Configure Partition Port page and select httpdns as the type:

  • Adding an HTTP/HTTPS application to the Application page:

  • Add upstream to the application, select the loopback address of the node upstream, and enter the httpdns partition port from the httpdns port added in the step above:

  • Adding Page Rules to the application:

    • Set the HTTP header so that httpdns gets the client IP correctly. Select Action, add action Set Proxy Header, fill in X-Real-IP in the header, and set the value to Built-In Variable - Client Address.

    • Select Proxy, upstream select the upstream added in the previous step.

At this point, the HTTPDNS configuration is complete, add DNS applications and records to DNS and you can use HTTPDNS for queries.

HTTPDNS Query

Request URL:http://{your app}/?host={your domain}&query=4,6&ip={client ip}

Request method:GET

Request parameters:

NameRequiredDescription
hostyesthe domain name to resolve.
ipnoSource IP of customer, If this parameter is not specified, the source IP of the requested connection is used by default.
querynoSpecifies the type of the resulting IP, either 6(IPv6) or 4(IPv4). The default is 4.
typeNoSpecifies the format of the query result, currently only “json” is supported.

Response:

NameDescription
hostDomain to Query
ipsThe resolved IPv4 result of the domain, it’s a list, may contain 0, 1 or more IP address.
ipsv6The resolved IPv6 result of the domain, it’s a list, may contain 0, 1 or more IP address.
ttlThat domain resolve result TTL cache time
origin_ttlThe original TTL for the domain name, i.e., the TTL value for the domain name configured on the authoritative NS.

Error code:

Error codeHTTP StatusDescription
MethodNotAllowed405The HTTP request method is not allowed.
MissingArgument400Missing query parameters, such as host.
UnsupportedType400The URL parameter type specifies a type that is not supported.
InvalidHost400The URL parameter host specifies an invalid domain name.
InvalidIP400The client IP specified by the URL parameter IP is invalid.
InvalidQuery400The version of IP specified by the URL parameter query is invalid.
InternalError500Server internal errors.
QueryError500Domain name search error.

Query examples

Example of a single result query: A single result query when only a single host and a single IP are specified.

  • Request Example 1: http://www.test.com:80/?host=www.a.com
  • Request Example 2: http://www.test.com:80/?host=www.a.com&ip=1.2.3.4
  • Request Example 3: http://www.test.com:80/?host=www.a.com&ip=1.2.3.4&query=6
  • Request Example 4: http://www.test.com:80/?host=www.a.com&ip=1.2.3.4&query=4,6

Response examples:

{
    "client_ip": "1.2.3.4",
    "ips": ["127.0.0.1"],
    "host": "www.a.com",
    "ttl": 300,
    "origin_ttl": 300
}

Example of a multi-result query: A multi-result query when multiple hosts or multiple IP are specified.

  • Request examples 1: http://www.test.com:80/?host=www.a.com,www.b.com
  • Request examples 2: http://www.test.com:80/?host=www.a.com&ip=1.1.1.1,2.2.2.2&query=4,6
  • Request examples 3: http://www.test.com:80/?host=www.a.com,www.b.com&ip=1.1.1.1,2.2.2.2&query=4,6
  • Request examples 4: http://www.test.com:80/?host=www.a.com,www.b.com&ip=1.1.1.1&query=4,6

Response examples:

{
    "dns": [{
        "client_ip": "1.1.1.1",
        "ipsv6": {},
        "host": "www.a.com",
        "ttl": 300,
        "ips": {}
    }, {
        "client_ip": "2.2.2.2",
        "ipsv6": {},
        "host": "www.a.com",
        "ttl": 300,
        "ips": {}
    }]
}