בס״ד

NAPTR Lookup

A NAPTR record is a DNS record that maps a domain to a rewrite rule, telling a client which service to use and which DNS lookup to perform next. NAPTR is defined in RFC 3403 and is used mainly for SIP server location and ENUM. DNSX resolves the full NAPTR to SRV to A chain in a single query.

$ curl https://dnsx.dev/dns/naptr/sipgate.de # full NAPTR/SRV chain as JSON
$ dig NAPTR sipgate.de +short

What is a NAPTR record?

A NAPTR record (Naming Authority Pointer) is a DNS resource record that holds a rewrite rule rather than an address. Where an A record answers "where is this host", a NAPTR record answers "which services does this domain offer, and what should I look up next to reach them". NAPTR was introduced in RFC 2915 and is now specified by RFC 3403 as the DNS binding of the Dynamic Delegation Discovery System (DDDS).

A NAPTR record has six fields in a fixed order: order, preference, flags, service, regexp and replacement. A client collects every NAPTR record at a name, sorts them by order and then by preference, and applies the first rule whose service field it supports. The flags field decides what happens next: another NAPTR lookup, an SRV lookup, an address lookup, or a finished URI.

Two applications account for almost all NAPTR records in the public DNS. The first is SIP server location (RFC 3263), where a VoIP client uses NAPTR to discover which transports a domain supports before it queries SRV. The second is ENUM (RFC 6116), where a telephone number is turned into a domain name under e164.arpa and NAPTR records there map it to SIP, email or web URIs.

What do the NAPTR fields mean: order, preference, flags, service, regexp, replacement?

Every NAPTR record carries the same six fields. Here is a real SIP record decoded field by field:

example.com.  3600  IN  NAPTR  10 50 "S" "SIP+D2T" "" _sip._tcp.example.com.
                              │  │   │       │      │            │
                            order │ flags  service regexp    replacement
                              preference
FieldValueWhat it means
Order10Evaluated first. Obeying it is mandatory, so every record with order 10 must be examined before any record with order 20.
Preference50Advisory tie-breaker among records that share order 10. Lower is preferred.
Flags"S"Terminal. The replacement is a name whose SRV record is looked up next.
Service"SIP+D2T"SIP carried over TCP. The syntax is protocol+resolutionservice.
Regexp""Empty, because this record uses the replacement field instead. Exactly one of regexp and replacement is used.
Replacement_sip._tcp.example.com.The SRV owner name to query next. Fully qualified, with the trailing dot.

The regexp and replacement fields are mutually exclusive. A record uses the replacement field when the next name is a fixed string, and the regexp field when the next name has to be derived from the input. That is why ENUM records, which rewrite a phone number, always use regexp and set replacement to a single dot.

The regexp field uses the form !pattern!replacement!, a POSIX extended regular expression substitution with a delimiter character (conventionally ! ) at the start, middle and end. Backreferences \1 through \9carry captured groups from the pattern into the output.

What do the NAPTR flags S, A, U and P mean?

The flags field is a quoted, case-insensitive string that tells the client what kind of result the rule produces. A terminal flag stops the DDDS rewrite loop, and the client uses the result as it stands. An empty flags string leaves the rule non-terminal, so the loop runs again. Four flags are defined for NAPTR in DNS.

FlagTerminal?Next lookupMeaning
STerminalSRV lookupThe replacement field is a domain name. Look up its SRV record to get the host and port. This is the flag used by RFC 3263 SIP server location.
ATerminalA / AAAA lookupThe replacement field is a hostname. Look up its A or AAAA record directly. No SRV step, so the port must come from the application default.
UTerminalNone (chain stops)The output of the regexp is a complete URI. Use it as-is. This is the flag every ENUM record uses.
PTerminalApplication-definedThe rest of the resolution is protocol-specific and defined outside the DDDS algorithm. Rare in production zones.
(empty)Non-terminalNAPTR lookup againThe replacement is a new domain name. Query NAPTR at that name and run the rewrite loop again.

In practice you will only ever meet two of these on the public internet. SIP domains publish "S" records that point at SRV names, and ENUM zones publish "U" records that produce a finished sip: or mailto:URI. The "A" flag skips the SRV step and gives up port discovery with it, and the "P" flag hands control to an application-specific algorithm that DNS itself does not define.

How does the NAPTR → SRV → A resolution chain work?

RFC 3263 defines how a SIP client locates a server for a domain, and it is the clearest worked example of the chain. The client does not know in advance whether the domain wants UDP, TCP or TLS, so it asks the domain to tell it. Take a domain that publishes both TCP and UDP:

; 1. NAPTR at the domain: which transports does it support?
example.com.            IN NAPTR 10 50 "S" "SIP+D2T" "" _sip._tcp.example.com.
example.com.            IN NAPTR 20 50 "S" "SIP+D2U" "" _sip._udp.example.com.

; 2. Order 10 wins, and the "S" flag says look up SRV at the replacement
_sip._tcp.example.com.  IN SRV   10 60 5060 sip1.example.com.
_sip._tcp.example.com.  IN SRV   10 40 5060 sip2.example.com.

; 3. SRV gives host + port; resolve the target to an address
sip1.example.com.       IN A     198.51.100.10
sip1.example.com.       IN AAAA  2001:db8::10

; 4. Result: connect to 198.51.100.10:5060 over TCP

Three DNS round trips produce one connectable endpoint. Order 10 is processed before order 20, so the domain has declared TCP preferable to UDP. Within _sip._tcp.example.com both SRV records share priority 10, so the weights split the traffic 60/40 between sip1 and sip2.

If a domain publishes no NAPTR records at all, RFC 3263 tells the client to skip straight to SRV and try _sips._tcp, _sip._tcp and _sip._udp in turn. If there are no SRV records either, it falls back to an A/AAAA lookup on the domain itself and uses the default port, 5060 for SIP and 5061 for SIPS.

DNSX walks this whole chain for you in one request. The NAPTR lookup resolves each rule to its SRV records and each SRV target to its A and AAAA addresses, and it annotates every resolved address with geolocation and ASN. You get to see whose network the chain actually lands on, not just that it resolves.

See the chain visualised

The DNS lookup tool renders the NAPTR → SRV → A/AAAA chain as a flow, with a ranked list of resolved endpoints.

Open the chain view

What is ENUM, and how does E2U+SIP map a phone number to a SIP URI?

ENUM (E.164 Number Mapping, RFC 6116) uses DNS to translate a telephone number into a set of URIs. The transformation is mechanical: take the number in full E.164 form, drop every character that is not a digit, reverse the digit order, put a dot between each digit, and append e164.arpa.

+1 202 555 0100                     ; the E.164 number
12025550100                         ; digits only
00105552021                         ; digits reversed
0.0.1.0.5.5.5.2.0.2.1.e164.arpa     ; dot-separated, under e164.arpa

$ORIGIN 0.0.1.0.5.5.5.2.0.2.1.e164.arpa.
  IN NAPTR 100 10 "u" "E2U+sip"   "!^.*$!sip:[email protected]!"    .
  IN NAPTR 102 10 "u" "E2U+email" "!^.*$!mailto:[email protected]!" .

Three things mark these out as ENUM records. The flag is u, because the result is a finished URI and no further DNS lookup happens. The service field starts with E2U, short for "E.164 to URI", followed by the scheme: E2U+sip, E2U+email, E2U+web, E2U+pstn. And the replacement field is a single dot, because the regexp field is doing the work.

The regexp !^.*$!sip:[email protected]! matches the whole input and replaces it with a fixed SIP address. More interesting zones use backreferences. The regexp !^\+1(.*)$!sip:\[email protected]! keeps the national part of the number and routes it to a PBX. The order field lets a subscriber express routing preference across schemes: try SIP at order 100, fall back to email at order 102.

Public ENUM under e164.arpa was never widely deployed, and most countries never delegated their prefix. The same mechanism is very much alive in private ENUM: carriers and PBX vendors run their own ENUM trees on internal domains for least-cost routing and number portability, using exactly the record format above.

NAPTR vs SRV: which comes first?

NAPTR comes first, and it exists to answer a question SRV cannot. An SRV lookup requires the client to already know the service and protocol labels it wants: _sip._tcp.example.com is only queryable if the client has decided on TCP. A NAPTR lookup is made at the bare domain, and the domain answers with the list of transports it actually supports and the order it prefers them in.

So use SRV alone when the service and protocol are fixed by the application, as they are for Minecraft, Autodiscover and Active Directory. Use NAPTR when transport selection belongs to the domain owner rather than the client, which is the case for SIP, and when the input is not a domain name at all, which is the case for ENUM.

NAPTR is also the more expensive record to publish and to consume. It adds a round trip, its rules are harder to write correctly, and client library support is patchier than it is for SRV. If your service does not need transport discovery, publish SRV and stop there. See the SRV record lookup page for how the SRV half of the chain behaves.

How do I look up NAPTR records on Windows, macOS and Linux?

This is the reason most people end up on a web tool. Windows has no built-in way to query a NAPTR record: nslookup on Windows does not accept NAPTR as a type, and PowerShell's Resolve-DnsName does not expose NAPTR in its -Type set either. Windows administrators need WSL, a BIND install, or a tool like this one.

# Linux (and WSL): dig ships with the bind-utils / dnsutils package
dig NAPTR example.com +short
dig -t NAPTR example.com @8.8.8.8        # ask a specific resolver
kdig -t NAPTR example.com                # knot-dnsutils
drill NAPTR example.com                  # ldns

# macOS: dig ships with the system. If it is missing on your version:
brew install bind
dig NAPTR example.com +short

# Windows: nslookup and Resolve-DnsName cannot query NAPTR. Use WSL,
# or curl the DNSX API, which needs nothing installed at all:
curl https://dnsx.dev/dns/naptr/example.com

# Any platform: the full chain as JSON, SRV and A/AAAA included
curl https://dnsx.dev/dns/naptr/sipgate.de | jq .

One gotcha when reading dig output directly: an empty regexp or replacement field prints as a bare pair of quotes or a lone dot, which is easy to misread as a broken record. Nothing is wrong with it. Exactly one of the two fields is meant to be empty in every valid NAPTR record.

Frequently Asked Questions

What is a NAPTR record?
A NAPTR (Naming Authority Pointer) record is a DNS record that maps a domain name to a rewrite rule, letting a client discover which service and which further DNS lookup to perform next. It is defined in RFC 3403 and used mainly for SIP/VoIP service discovery and ENUM.
What does the S flag mean in a NAPTR record?
The S flag is terminal and means the replacement field is a domain name whose SRV record should be looked up next. A means look up an A or AAAA record instead, and U means the regexp output is already a complete URI and no further DNS lookup is needed.
What is the difference between NAPTR order and preference?
In a NAPTR record, order is evaluated first, and obeying it is mandatory. The client must process the lowest order value before any higher one. Preference only breaks ties within the same order value, and it is advisory.
What is ENUM?
ENUM maps an E.164 telephone number to URIs in DNS. The digits are reversed, dot-separated and appended to e164.arpa, so +1 202 555 0100 becomes 0.0.1.0.5.5.5.2.0.2.1.e164.arpa. NAPTR records at that name carry the E2U+sip service with a regexp that rewrites the number into a SIP URI.
Can Windows nslookup query NAPTR records?
No. Neither Windows nslookup nor PowerShell's Resolve-DnsName supports the NAPTR type, which is why NAPTR lookups usually have to be done with dig or a web tool.
When should I use NAPTR instead of SRV?
Use SRV when the service and protocol are already known (_sip._tcp.example.com). Use NAPTR when the client must discover which transports a domain supports before it knows which SRV name to query, which is exactly what RFC 3263 SIP server location does.

Standards this page follows

RFC 2915 defined the original NAPTR resource record in 2000. It is now superseded.

RFC 3403 is DDDS Part Three, the DNS database, and it is the current NAPTR specification.

RFC 3263, SIP: Locating SIP Servers, defines the SIP+D2U / SIP+D2T / SIP+D2S service fields and the NAPTR → SRV → A procedure.

RFC 6116 is the E.164 to URI DDDS application (ENUM). It defines the E2U+ service fields and the e164.arpa tree.

RFC 2782 defines the SRV record, the second hop of the chain.

Related Tools