DNS Configuration
SproutDNS uses a DNS zone configuration similar to DNS configuration for a regular authoritative DNS server; there are just two changes.
An authoritative DNS server accepts questions - a hostname and a query type - and in the simplest case it returns zero or more answers that match that question. In a regular zone file the questions and answers are fixed, and the server will respond when the hostname and query type match exactly.
Here any TXT query with the hostname example.com
will return a TXT record containing the string v=spf1 -all
.
SproutDNS extends this functionality using regular expressions.
With SproutDNS the "name" is a regular expression - in this example it will match any hostname that starts with any word, then "._domainkey." then any word and ".example.com". We label the first word <selector>
and the second word <customer>
. That lets us use the values of those words in the result.
So a query for k1._domainkey.customer_one.example.com
would return a CNAME record pointing at k1._dkim.example.com
.
And a query for key2._domainkey.other_customer.example.com
would return a CNAME record pointing at keys._dkim.example.com
.
In the json configuration file any name can be either a literal hostname or a regular expression. The regular expression will be matched against the hostnames of incoming requests.
Answers that are CNAME
, TXT
, NS
, MX
or PTR
records will have anything that looks like ${variable_name}
replaced with the matching word from the hostname of the query. Records of any other type will be return literally, without any variable replacement.
For clarity we suggest using this syntax, but the full Go regexp template language is supported:
In the template, a variable is denoted by a substring of the form (?P<name>...)
syntax. A reference to an out of range or unmatched index or a name that is not present in the regular expression is replaced with an empty slice.
In the
To insert a literal