github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/domain-modifiers/NAPTR.md (about)

     1  ---
     2  name: NAPTR
     3  parameters:
     4    - subdomain
     5    - order
     6    - preference
     7    - terminalflag
     8    - service
     9    - regexp
    10    - target
    11  parameter_types:
    12    subdomain: string
    13    order: number
    14    preference: number
    15    terminalflag: string
    16    service: string
    17    regexp: string
    18    target: string
    19  ---
    20  
    21  ## Introduction
    22  
    23  NAPTR adds a NAPTR record to the domain. Various formats exist. NAPTR is a part of DDDS such as ENUM (defined by [RFC 6116](https://www.rfc-editor.org/rfc/rfc6116)), SIP ([RFC 3263](https://www.rfc-editor.org/rfc/rfc3263)), S-NAPTR ([RFC 3958](https://www.rfc-editor.org/rfc/rfc3958)) or U-NAPTR ([RFC 4848](https://www.rfc-editor.org/rfc/rfc4848)).
    24  
    25  ## Parameters
    26  
    27  ### `subdomain`
    28  
    29  Subdomain of the domain (e.g. `example.com`) this entry represents.
    30  
    31  #### E164
    32  In the case of E164 (e.g. `3.2.1.5.5.5.0.0.8.1.e164.arpa.`) - where [`terminalflag`](#terminalflag) is `u` - the final digit of the zone it represents, or the zone apex record `@`. For example, the ARPA zone `3.2.1.5.5.5.0.0.8.1.e164.arpa.` represents the phone number block 001800555123*X* (or the synonymous +1800555123*X*), where *X* is the final digit of the phone number string, i.e. the [`subdomain`](#subdomain).
    33  
    34  
    35  ### `order`
    36  
    37  ordinal (1st, 2nd, 3rd, ...) 16 bit number (2^16 i.e. <= 65535) which determines lower entries are sent first (`1`), and  higher, last (`65535`).
    38  
    39  ### `preference`
    40  
    41  16 bit number (2^16 i.e. <= 65535). At the DNS server, this entry is summed with other entries of identical [`order`](#order) value and normalised to a fraction of 100 percent, determining the likelihood that this record is returned by the DNS system. Effective for load balancing services.
    42  
    43  ### `terminalflag`
    44  (case insensitive)
    45  
    46  One of [AaSsUuPp], where:
    47   * `a` (terminal lookup) means that the output of the [`target`](#target) rewrite will be a domain-name for which an [`A`](A.md) or [`AAAA`](AAAA.md) record should be queried
    48   * `p` Protocol specific
    49   * `s` (terminal lookup) indicates that [`target`](#target) points to a [`SRV`](SRV.md) record
    50   * `u` (terminal lookup) indicates that [`target`](#target) is a (SIP) URN or URI
    51   * "" (empty string) - a non-terminal condition defined by the ENUM application ([RFC 6116](https://www.rfc-editor.org/rfc/rfc6116)) to indicate that regexp is empty and the replace field contains the FQDN of another NAPTR RR
    52  
    53  
    54  Mutually exclusive; more than one cannot be combined in the same record. Since there is no place for a port specification in the NAPTR record, when the `a` [`terminalflag`](#terminalflag) is used, the specified protocol must be running on its default port (Note that at least SIP URI forms allow ports to be specified).
    55  
    56  Flags called 'terminal' halt the looping rewrite algorithm of DNS.
    57  
    58  
    59  ### `service`
    60  (case insensitive)
    61  
    62  *`protocol+rs`* where *`protocol`* defines the protocol used by the DDDS application. *`rs`* is the resolution service. There may be 0 or more resolution services each separated by `+`. ENUM further defines this to be a type field and allows a subtype separated by a colon (`:`).
    63  
    64  For E164, typically one of `E2U+SIP` (or `E2U+sip`) or `E2U+email`. For SIP, typically `SIPS+D2T` for TCP/TLS `sips:` URIs, or TLS `sip:` URIs, or `SIP+D2T` for TCP based SIP, or `SIP+D2U` for UDP based SIP. Note that SCTP, WS and WSS are also available.
    65  
    66  
    67  Valid [IANA registered services for ENUM](https://www.iana.org/assignments/enum-services/enum-services.xhtml#enum-services-1):
    68  ```text
    69  E2U+pres
    70  E2U+voice:tel+sms:tel (compound form)
    71  E2U+web:http
    72  E2U+sms:mailto
    73  E2U+sms:tel
    74  E2U+sip
    75  E2U+pstn
    76  E2U+tel
    77  ```
    78  
    79  Valid [IANA registered SIP services](https://www.iana.org/assignments/sip-table/sip-table.xhtml#sip-table-1):
    80  
    81  ```text
    82  SIP+D2T
    83  SIPS+D2T
    84  SIP+D2U
    85  SIP+D2S
    86  SIPS+D2S
    87  SIP+D2W
    88  SIPS+D2W
    89  ```
    90  
    91  ### `regexp`
    92  
    93  [Syntax: `delimit ere delimit substitution delimit flag`] an ERE or extended regular expression which captures any address string `.*` found between the line start `^` and finish `$` anchors (i.e. `!^.*$!`), and redirects it to the stated `sip:`, `sips:`, `tel:` or `mailto:` URI. Other URI forms may be possible. Other delimiter (`!`) forms are possible. The final `flag`, if any, shall be `i`, i.e. case **i**nsensitive.
    94  
    95  Examples (taken from [Zytrax](https://www.zytrax.com/books/dns/ch8/naptr.html#regex-examples)):
    96  ```text
    97  # AUS = Application User String
    98  # all examples use ! as the delimiter for consistency
    99  # and simplicity
   100  # AUS = +441115551234 in all cases
   101  
   102  !(\\+441115551234)!tel:\\1!
   103  # explicit check of all characters in string
   104  # the +441115551234 because of () creates a group
   105  # which is referenced by \1 in substitution
   106  # result = tel:+441115551234
   107  
   108  !^(\\+441115551234)$!tel:\\1!
   109  # this is functionally identical to the expression
   110  # above but uses ^ and $ to anchor both ends of
   111  # the expression, there is no technical reason to do this
   112  # within an ere and the RFCs are silent on the topic
   113  # result = tel:+441115551234
   114  
   115  !(.+)!tel:\\1!
   116  # given the AUS of +441115551234
   117  # the expression (.+) sets back ref 1 = +441115551234
   118  # . = any character, + = 0 or more times
   119  # result = tel:+441115551212
   120  
   121  !\\+44111(.+)!sip:775\\1@some.example.com!
   122  # given the AUS of +441115551234 provides partial replacement
   123  # removes the 44111 part and substitutes 775
   124  # result = sip:7755551234@some.example.com
   125  
   126  !.*!sip:james@sip.example.com!
   127  # reads and ignores AUS using .*
   128  # and is called a simple replacement expression
   129  # result = sip:james@sip.example.com
   130  ```
   131  
   132  U-NAPTR supported regexp fields must be of the form (from the RFC):
   133  
   134  ```text
   135  "!.*!<URI>!"
   136  # the .* (any character 1 or more times)
   137  # is fixed by the RFC and essentially ignores
   138  # the AUS data. The result will always be URI
   139  ```
   140  
   141  
   142  ### `target`
   143  
   144  A (replacement) record for the target - format depends on [`terminalflag`](#terminalflag).
   145   * A [`SRV`](SRV.md), if the [`terminalflag`](#terminalflag) is `s` (syntax: *`_Service._Proto.Name`*)
   146   * An [`A`](A.md) or [`AAAA`](AAAA.md) if the [`terminalflag`](#terminalflag) is `a`
   147   * URI if the [`terminalflag`](#terminalflag) is `u`
   148  
   149  
   150  Not all examples are guaranteed to be standards compliant, or correct.
   151  
   152  ## Examples
   153  
   154  ### Examples for e164 ARPA:
   155  
   156  Individual e164 records
   157  
   158  {% code title="dnsconfig.js" %}
   159  ```javascript
   160  D("3.2.1.5.5.5.0.0.8.1.e164.arpa.", REG_MY_PROVIDER, DnsProvider(R53),
   161    NAPTR("1",  10, 10, "u", "E2U+SIP", "!^.*$!sip:bob@example.com!", "."),
   162    NAPTR("2",  10, 10, "u", "E2U+SIP", "!^.*$!sip:alice@example.com!", "."),
   163    NAPTR("4",  10, 10, "u", "E2U+SIP", "!^.*$!sip:kate@example.com!", "."),
   164    NAPTR("5",  10, 10, "u", "E2U+SIP", "!^.*$!sip:steve@example.com!", "."),
   165    NAPTR("6",  10, 10, "u", "E2U+SIP", "!^.*$!sip:joe@example.com!", "."),
   166    NAPTR("7",  10, 10, "u", "E2U+SIP", "!^.*$!sip:jane@example.com!", "."),
   167    NAPTR("8",  10, 10, "u", "E2U+SIP", "!^.*$!sip:mike@example.com!", "."),
   168    NAPTR("9",  10, 10, "u", "E2U+SIP", "!^.*$!sip:linda@example.com!", "."),
   169    NAPTR("0",  10, 10, "u", "E2U+SIP", "!^.*$!sip:fax@example.com!", "."),
   170  END);
   171  ```
   172  {% endcode %}
   173  
   174  Single e164 zone
   175  {% code title="dnsconfig.js" %}
   176  ```javascript
   177  D("4.3.2.1.5.5.5.0.0.8.1.e164.arpa.", REG_MY_PROVIDER, DnsProvider(R53),
   178    NAPTR("@", 100, 50, "u", "E2U+SIP", "!^.*$!sip:customer-service@example.com!", "."),
   179    NAPTR("@", 101, 50, "u", "E2U+email", "!^.*$!mailto:information@example.com!", "."),
   180    NAPTR("@", 101, 50, "u", "smtp+E2U", "!^.*$!mailto:information@example.com!", "."),
   181  END);
   182  ```
   183  {% endcode %}
   184  
   185  
   186  ### Examples for SIP:
   187  
   188  {% code title="dnsconfig.js" %}
   189  ```javascript
   190  D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
   191    NAPTR("@", 20, 50, "s", "SIPS+D2T", "", "_sips._tcp.example.com."),
   192    NAPTR("@", 20, 50, "s", "SIP+D2T", "", "_sip._tcp.example.com."),
   193    NAPTR("@", 30, 50, "s", "SIP+D2U", "", "_sip._udp.example.com."),
   194    NAPTR("help", 100, 50, "s", "SIP+D2U", "!^.*$!sip:customer-service@example.com!", "_sip._udp.example.com."),
   195    NAPTR("help", 101, 50, "s", "SIP+D2T", "!^.*$!sip:customer-service@example.com!", "_sip._tcp.example.com."),
   196    SRV("_sip._udp", 100, 0, 5060, "sip.example.com."),
   197    SRV("_sip._tcp", 100, 0, 5060, "sip.example.com."),
   198    SRV("_sips._tcp", 100, 0, 5061, "sip.example.com."),
   199    A("sip", "192.0.2.2"),
   200    AAAA("sip", "2001:db8::85a3"),
   201    // and so on
   202  END);
   203  ```
   204  {% endcode %}
   205  
   206  
   207  ### Other RFC based examples:
   208  
   209  {% code title="dnsconfig.js" %}
   210  ```javascript
   211  D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
   212    NAPTR("@",100, 50, "a", "z3950+N2L+N2C", "", "cidserver.example.com."),
   213    NAPTR("@", 50, 50, "a", "rcds+N2C", "", "cidserver.example.com."),
   214    NAPTR("@", 30, 50, "s", "http+N2L+N2C+N2R", "", "www.example.com."),
   215    NAPTR("www",100,100, "s", "http+I2R", "", "_http._tcp.example.com."),
   216    NAPTR("www",100,100, "s", "ftp+I2R", "", "_ftp._tcp.example.com."),
   217    SRV("_z3950._tcp", 0, 0, 1000, "z3950.beast.example.com."),
   218    SRV("_http._tcp", 10, 0, 80, "foo.example.com."),
   219    // and so on
   220  END);
   221  ```
   222  {% endcode %}
   223