1. Library
  2. Dns
  3. Records

Updated 2 hours ago

The telephone system and the Internet grew up separately. Phone numbers follow E.164—a hierarchical system designed for circuit-switched networks. Internet addresses follow DNS—a hierarchical system designed for packet-switched networks. Neither knows how to speak the other's language.

NAPTR records are the translators.

When you dial a phone number and it connects to a VoIP service, or when a SIP client discovers which server handles a domain, NAPTR records are performing the conversion. They take an identifier from one namespace and transform it into an identifier in another namespace through pattern-matching rules.

The Six-Field Structure

NAPTR (Naming Authority Pointer) records have the most complex format of any DNS record type:

example.com. IN NAPTR 100 10 "u" "E2U+sip" "!^.*$!sip:info@example.com!" .

Six fields, each with a specific job:

Order (100): Which records to process first. Lower numbers win. Only records sharing the lowest order value get considered.

Preference (10): Tiebreaker between records with identical order values. Again, lower wins.

Flags ("u"): What to do with the result. "u" means the output is a URI and you're done. "s" means query for SRV records next. "a" means query for A/AAAA records next. Empty means keep processing NAPTR records.

Services ("E2U+sip"): Which service and protocol this rule handles. "E2U" means ENUM (phone number to URI). "SIP+D2T" means SIP over TCP.

Regexp ("!^.*$!sip:info@example.com!"): A regular expression that transforms the input. The delimiters (commonly "!") separate the match pattern from the replacement string.

Replacement (.): Where to look next if more DNS queries are needed. A dot means nowhere—the regexp output is final.

ENUM: Phone Numbers Become Internet Addresses

ENUM (E.164 Number Mapping) is NAPTR's signature application. It answers the question: given a phone number, what Internet resources can reach this person?

The transformation is strange and specific. Take +1-555-123-4567. Strip the formatting, reverse the digits, insert dots between each digit, and append e164.arpa:

7.6.5.4.3.2.1.5.5.5.1.e164.arpa

The phone number becomes a domain name, readable by DNS. Query for NAPTR records at that domain:

7.6.5.4.3.2.1.5.5.5.1.e164.arpa. IN NAPTR 100 10 "u" "E2U+sip" "!^.*$!sip:15551234567@voip.example.com!" .
7.6.5.4.3.2.1.5.5.5.1.e164.arpa. IN NAPTR 100 20 "u" "E2U+email" "!^.*$!mailto:user@example.com!" .
7.6.5.4.3.2.1.5.5.5.1.e164.arpa. IN NAPTR 100 30 "u" "E2U+web:http" "!^.*$!http://www.example.com/contact!" .

Three ways to reach this phone number's owner: SIP call (preference 10), email (preference 20), or web form (preference 30). Applications pick the method they support.

SIP Routing: Choosing Protocols and Servers

Session Initiation Protocol systems use NAPTR to answer a different question: when connecting to a SIP domain, which transport protocol and server should I use?

A client wanting to reach user@example.com queries NAPTR records at example.com:

example.com. IN NAPTR 100 10 "s" "SIP+D2T" "" _sip._tcp.example.com.
example.com. IN NAPTR 100 20 "s" "SIP+D2U" "" _sip._udp.example.com.
example.com. IN NAPTR 100 30 "s" "SIPS+D2T" "" _sips._tcp.example.com.

The "s" flag means: take the replacement field and query for SRV records there. This creates a resolution chain:

  1. NAPTR records determine the transport protocol (TCP preferred over UDP, both preferred over TLS)
  2. SRV records at _sip._tcp.example.com identify specific servers, ports, and load balancing weights
  3. A/AAAA records provide the actual IP addresses

Three DNS lookups, each answering a different question: which protocol, which server, which address.

The Delegation Chain

NAPTR records rarely work alone. The typical pattern:

  1. Query NAPTR to determine service and protocol
  2. NAPTR's "s" flag delegates to SRV records
  3. Query SRV to find servers, ports, priorities, weights
  4. Query A/AAAA to resolve server names to IP addresses
  5. Connect

This separation matters. Administrators can change server infrastructure (SRV and A/AAAA records) without touching service policies (NAPTR records). Protocol preferences and load balancing live in different layers, updated independently.

Regular Expression Power

The regexp field can do more than simple substitution. Pattern groups enable sophisticated transformations:

e164.arpa. IN NAPTR 100 10 "u" "E2U+sip" "!^\\+1(555)([0-9]{7})$!sip:\\2@sip.example.com!" .

This pattern matches +1-555 numbers, captures the seven-digit local portion, and constructs a SIP URI using only that portion. Different area codes could route to different servers. Premium numbers could route to specialized handlers.

Where NAPTR Records Live

Most DNS administrators never touch NAPTR records. They appear in specialized environments:

  • Telephony infrastructure: Carriers and enterprises implementing ENUM or SIP routing
  • Large service providers: Organizations offering multiple protocols through unified identifiers
  • Standards-mandated integrations: Systems implementing RFCs that require NAPTR

The complexity demands careful testing. A malformed regular expression breaks resolution entirely. Incorrect flags create infinite loops or dead ends. Debugging requires tracing the complete chain—NAPTR to SRV to A/AAAA—since a failure at any step produces the same symptom: connection refused.

Caching makes this worse. If your NAPTR record has a 1-hour TTL but your SRV records have 24-hour TTLs, you can update the NAPTR to point to new infrastructure and clients will still follow the cached SRV to decommissioned servers for up to a day. The resolution chain is only as fresh as its stalest link.

Frequently Asked Questions About NAPTR Records

Was this page helpful?

😔
🤨
😃