github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/top-level-functions/REV.md (about)

     1  ---
     2  name: REV
     3  parameters:
     4    - address
     5  parameter_types:
     6    address: string
     7  ts_return: string
     8  ---
     9  
    10  `REV` returns the reverse lookup domain for an IP network. For
    11  example `REV("1.2.3.0/24")` returns `3.2.1.in-addr.arpa.` and
    12  `REV("2001:db8:302::/48")` returns `2.0.3.0.8.b.d.0.1.0.0.2.ip6.arpa.`.
    13  
    14  `REV()` is commonly used with the [`D()`](D.md) functions to create reverse DNS lookup zones.
    15  
    16  These two are equivalent:
    17  
    18  {% code title="dnsconfig.js" %}
    19  ```javascript
    20  D("3.2.1.in-addr.arpa", ...
    21  ```
    22  {% endcode %}
    23  
    24  {% code title="dnsconfig.js" %}
    25  ```javascript
    26  D(REV("1.2.3.0/24", ...
    27  ```
    28  {% endcode %}
    29  
    30  The latter is easier to type and less error-prone.
    31  
    32  If the address does not include a "/" then `REV()` assumes /32 for IPv4 addresses
    33  and /128 for IPv6 addresses.
    34  
    35  # RFC compliance
    36  
    37  `REV()` implements both RFC 2317 and the newer RFC 4183. The `REVCOMPAT()`
    38  function selects which mode is used. If `REVCOMPAT()` is not called, a default
    39  is selected for you.  The default will change to RFC 4183 in DNSControl v5.0.
    40  
    41  See [`REVCOMPAT()`](REVCOMPAT.md) for details.
    42  
    43  
    44  # Host bits
    45  
    46  v4.x:
    47  The host bits (the ones outside the netmask) must be zeros. They are not zeroed
    48  out automatically. Thus, `REV("1.2.3.4/24")` is an error.
    49  
    50  v5.0 and later:
    51  The host bits (the ones outside the netmask) are ignored.  Thus
    52  `REV("1.2.3.4/24")` and `REV("1.2.3.0/24")` are equivalent.
    53  
    54  # Examples
    55  
    56  Here's an example reverse lookup domain:
    57  
    58  {% code title="dnsconfig.js" %}
    59  ```javascript
    60  D(REV("1.2.3.0/24"), REGISTRAR, DnsProvider(BIND),
    61    PTR("1", "foo.example.com."),
    62    PTR("2", "bar.example.com."),
    63    PTR("3", "baz.example.com."),
    64    // If the first parameter is an IP address, DNSControl automatically calls REV() for you.
    65    PTR("1.2.3.10", "ten.example.com."),
    66  END);
    67  
    68  D(REV("2001:db8:302::/48"), REGISTRAR, DnsProvider(BIND),
    69    PTR("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0", "foo.example.com."),  // 2001:db8:302::1
    70    // If the first parameter is an IP address, DNSControl automatically calls REV() for you.
    71    PTR("2001:db8:302::2", "two.example.com."),                          // 2.0.0...
    72    PTR("2001:db8:302::3", "three.example.com."),                        // 3.0.0...
    73  END);
    74  ```
    75  {% endcode %}
    76  
    77  # Automatic forward and reverse record generation
    78  
    79  DNSControl does not automatically generate forward and reverse lookups. However
    80  it is possible to write a macro that does this.  See
    81  [`PTR()`](../domain/PTR.md)   for an example.