Version: v1.1.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2018 License: Apache-2.0 Imports: 14 Imported by: 0




reverse - allows for dynamic responses to PTR and the related A/AAAA requests.


If a request matches a regular expression (see Template Syntax below) this plugin will generate a response. This is only done for "address" records (PTR, A and AAAA).


reverse NETWORK... {
    hostname TEMPLATE
    [ttl TTL]
    [fallthrough [ZONES...]]
  • NETWORK one or more CIDR formatted networks to respond on.
  • hostname injects the IP and zone to a template for the hostname. Defaults to "ip-{IP}.{zone[1]}". See below for template.
  • ttl defaults to 60
  • fallthrough if zone matches and no record can be generated, pass request to the next plugin. If [ZONES...] is omitted, then fallthrough happens for all zones for which the plugin is authoritative. If specific zones are listed (for example and, then only queries for those zones will be subject to fallthrough.
  • wildcard allows matches to catch all subdomains as well.
Template Syntax

The template for the hostname is used for generating the PTR for a reverse lookup and matching the forward lookup back to an IP.


The {ip} symbol is required to make reverse work. For IPv4 lookups the IP is directly extracted With IPv6 lookups the ":" is removed, and any zero ranged are expanded, e.g., "ffff::ffff" results in "ffff000000000000000000000000ffff"


The {zone[i]} symbol is optional and can be replaced by a fixed (zone) string. The zone will be matched by the zones listed in this configuration stanza. i needs to be replaced with the index of the configured listener zones, starting with 1.


arpa compute.internal {
    # proxy unmatched requests
    proxy .

    # answer requests for IPs in this network
    # PTR 3600 ip-
    # A ip- 3600
    # v6 is also possible
    # PTR 3600 ip-fd010000000000000000000000000001.compute.internal.
    # AAAA ip-fd010000000000000000000000000001.compute.internal. 3600 fd01::1
    reverse fd01::/16 {
        # template of the ip injection to hostname, zone resolved to compute.internal.
        hostname ip-{ip}.{zone[2]}

        ttl 3600

        # Forward unanswered or unmatched requests to proxy
        # without this flag, requesting A/AAAA records on compute.internal. will end here.
} {

    reverse {
        # template of the ip injection to hostname, zone resolved to
        hostname "ip-{ip}.v4.{zone[2]}"

        ttl 3600

        # fallthrough is not required, will be only answered here

    # cidr closer to the ip wins, so we can overwrite the "default"
    reverse {
        # its also possible to set fix domain suffix
        hostname ip-{ip}

        ttl 3600




This section is empty.


This section is empty.


This section is empty.


type Reverse

type Reverse struct {
	Next     plugin.Handler
	Networks networks

	Fall fall.F

Reverse provides dynamic reverse DNS and the related forward RR.

func (Reverse) Name

func (re Reverse) Name() string

Name implements the Handler interface.

func (Reverse) ServeDNS

func (re Reverse) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL