2017-07-07 13:59:29 -04:00
---
name: PTR
parameters:
- name
- target
- modifiers...
2023-01-12 16:59:42 -05:00
parameter_types:
name: string
target: string
"modifiers...": RecordModifier[]
2017-07-07 13:59:29 -04:00
---
PTR adds a PTR record to the domain.
2022-11-03 09:12:08 -04:00
The name is normally a relative label for the domain, or a FQDN that ends with `.` . If magic mode is enabled (see below) it can also be an IP address, which will be replaced by the proper string automatically, thus
2017-07-10 19:24:55 -04:00
saving the user from having to reverse the IP address manually.
2017-07-07 13:59:29 -04:00
Target should be a string representing the FQDN of a host. Like all FQDNs in DNSControl, it must end with a `.` .
2017-07-10 19:24:55 -04:00
**Magic Mode:**
PTR records are complex and typos are common. Therefore DNSControl
enables features to save labor and
prevent typos. This magic is only
enabled when the domain ends with `in-addr.arpa.` or `ipv6.arpa.` .
*Automatic IP-to-reverse:* If the name is a valid IP address, DNSControl will replace it with
a string that is appropriate for the domain. That is, if the domain
ends with `in-addr.arpa` (no `.` ) and name is a valid IPv4 address, the name
will be replaced with the correct string to make a reverse lookup for that address.
IPv6 is properly handled too.
*Extra Validation:* DNSControl considers it an error to include a name that
is inappropriate for the domain. For example
2023-05-24 22:09:22 +02:00
`PTR("1.2.3.4", "f.co.")` is valid for the domain `D("3.2.1.in-addr.arpa",`
but DNSControl will generate an error if the domain is `D("9.9.9.in-addr.arpa",` .
2017-07-10 19:24:55 -04:00
This is because `1.2.3.4` is contained in `1.2.3.0/24` but not `9.9.9.0/24` .
2017-08-29 13:49:39 -04:00
This validation works for IPv6, IPv4, and
2017-07-10 19:24:55 -04:00
RFC2317 "Classless in-addr.arpa delegation" domains.
*Automatic truncation:* DNSControl will automatically truncate FQDNs
2017-08-29 13:49:39 -04:00
as needed.
2017-07-10 19:24:55 -04:00
If the name is a FQDN ending with `.` , DNSControl will verify that the
name is contained within the CIDR block implied by domain. For example
if name is `4.3.2.1.in-addr.arpa.` (note the trailing `.` )
and the domain is `2.1.in-addr.arpa` (no trailing `.` )
then the name will be replaced with `4.3` . Note that the output
2023-05-24 22:09:22 +02:00
of `REV("1.2.3.4")` is `4.3.2.1.in-addr.arpa.` , which means the following
2017-07-10 19:24:55 -04:00
are all equivalent:
2024-01-11 17:25:31 -05:00
* `PTR(REV("1.2.3.4", ...`
* `PTR("4.3.2.1.in-addr.arpa.", ...`
* `PTR("4.3", ...` // Assuming the domain is `2.1.in-addr.arpa`
2017-07-10 19:24:55 -04:00
All magic is RFC2317-aware. We use the first format listed in the
2023-03-15 23:43:57 +01:00
RFC for both [`REV()` ](../global/REV.md ) and `PTR()` . The format is
2017-07-10 19:24:55 -04:00
`FIRST/MASK.C.B.A.in-addr.arpa` where `FIRST` is the first IP address
of the zone, `MASK` is the netmask of the zone (25-31 inclusive),
and A, B, C are the first 3 octets of the IP address. For example
`172.20.18.130/27` is located in a zone named
`128/27.18.20.172.in-addr.arpa`
2023-03-13 21:30:21 +01:00
{% code title="dnsconfig.js" %}
2023-01-20 13:56:20 +01:00
```javascript
2023-05-24 22:09:22 +02:00
D(REV("1.2.3.0/24"), REGISTRAR, DnsProvider(BIND),
PTR("1", "foo.example.com."),
PTR("2", "bar.example.com."),
PTR("3", "baz.example.com."),
2017-07-07 13:59:29 -04:00
// If the first parameter is a valid IP address, DNSControl will generate the correct name:
2023-05-24 22:09:22 +02:00
PTR("1.2.3.10", "ten.example.com."), // "10"
2017-07-07 13:59:29 -04:00
);
2023-03-13 21:30:21 +01:00
```
{% endcode %}
2017-07-07 13:59:29 -04:00
2023-03-13 21:30:21 +01:00
{% code title="dnsconfig.js" %}
```javascript
2023-05-24 22:09:22 +02:00
D(REV("9.9.9.128/25"), REGISTRAR, DnsProvider(BIND),
PTR("9.9.9.129", "first.example.com."),
2017-07-10 19:24:55 -04:00
);
2023-03-13 21:30:21 +01:00
```
{% endcode %}
2017-07-10 19:24:55 -04:00
2023-03-13 21:30:21 +01:00
{% code title="dnsconfig.js" %}
```javascript
2023-05-24 22:09:22 +02:00
D(REV("2001:db8:302::/48"), REGISTRAR, DnsProvider(BIND),
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
2017-07-07 13:59:29 -04:00
// If the first parameter is a valid IP address, DNSControl will generate the correct name:
2023-05-24 22:09:22 +02:00
PTR("2001:db8:302::2", "two.example.com."), // "2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
PTR("2001:db8:302::3", "three.example.com."), // "3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"
2017-07-07 13:59:29 -04:00
);
2022-02-17 18:22:31 +01:00
```
2023-03-13 21:30:21 +01:00
{% endcode %}
2017-07-07 13:59:29 -04:00
2023-03-17 20:40:09 +01:00
In the future we plan on adding a flag to [`A()` ](A.md ) which will insert
2019-05-11 21:32:52 -04:00
the correct PTR() record if the appropriate `.arpa` domain has been
2017-07-07 13:59:29 -04:00
defined.