How to use the HTTP API |
Simple DNS Plus v. 5.0 Copyright © 1999-2008 JH Software ApS |
Simple DNS Plus can be prompted to perform different actions through HTTP - either directly from a browser, or any other program that can communicate through HTTP.
This functionality is not intended as a direct user interface, but rather a way to communicate with Simple DNS Plus from other applications over the network (for example, ASP pages running on IIS, PHP pages on Apache, etc.).
By default, Simple DNS Plus listens for HTTP requests on IP address 127.0.0.1 port 8053.
With this default configuration, you can open a web-page that lists the available commands in your browser using http://127.0.0.1:8053
Port 8053 is used to avoid conflicts with any web server software using the standard port 80 on the same machine.
Please note that only the same computer can connect to IP 127.0.0.1, so if you need to access this from another computer, you will need to configure Simple DNS Plus to listen on a different IP address.
You can change these setting in the Options dialog / HTTP API section.
Simple DNS Plus accepts both HTTP "GET" and "POST" requests - use whichever is more convenient for your situation.
When using "GET", all fields and values must be part of the URL.
When using "POST", all fields and values must be in the HTTP request message body.
The response will either be a document (text, XML, or HTML depending on the parameters of the request) containing the result, an error 404 for unrecognized commands, or error 406 for requests that could no be performed.
The request document/path name must be one of the commands described below.
For example, to list the contents of the zone file for example.com, you could use the following (with GET):
http://127.0.0.1:8053/getzone?zone=example.com
Commands:
| • | status Returns server status and request counters. Optionally include the field "format" with the value "text" (the default), "html", or "xml". |
| • | clearcache Clears the DNS cache. Same as selecting "Clear Cache" from the main window / File menu. |
| • | reloadall |
Reloads all zone data from disk.
| • | zonelist |
Returns a list of all zone names on the server.
Optionally include the field "listtype", being either "simple" (the default), "primary" (primary zones only), "secondary" (secondary zones only), "extended", or "xml".
Optionally you may specify a numeric ID in the field "zonegroup" matching a group ID in the "editrecs.config.xml" file to limit the list to a single zone group.
| • | getzone |
Returns the text of a zone file.
Specify the zone name in the field "zone".
| • | loadzone |
Reloads an existing zone from disk.
Specify the zone name in the field "zone".
NOTE: You don't need to reload zones updated with other HTTP API commands. However this command can be used if the zone file on disk has been updated from another process.
| • | removezone |
Removes an existing zone from the server.
Specify the zone name in the field "zone".
| • | updatehost |
Updates, creates, or deletes an A-record or AAAA-record (host address).
A parent zone must already exist for the host name.
Specify the host name in the field "host".
Specify an IP address (IPv4 or IPv6) in the field "data".
If no data (IP address) is specified, the record is deleted.
| • | updatezone Updates or creates a new zone on the server. Specify the zone name in the field "zone". Specify the zone data in the field "data" (formatted as a standard zone file). For secondary zones, specify the primary server IP address in the field "masterip". Optionally specify a numeric ID in the field "zonegroup" matching a group ID in the "editrecs.ini" file. Make sure to increment the SOA-record serial number when using this command. |
| • | addrecord, updaterecord, removerecord |
Adds, updates, or removes a DNS record.
Specify the zone name in the field "zone".
Specify the record name in the field "name" using zone file format (@ = zone name, etc.)
Specify the record type in the field "type" (for example: 'A' or 'MX')
Specify the record data in the field "data" using zone file format (optional for removerecord)
Optionally specify the record TTL in the field "ttl" in seconds.