TryLearn More

Use SIP trunks, WebRTC & Apps

Slash your Phone Bill by 80%

3CX SIP Trunk DNS Record Resolution Mechanism

On this topic:

3CX SIP Trunk DNS Record Resolution Mechanism

DNS Record Types 3CX tries to Resolve

NAPTR Record

SRV Records

AAAA / A Record

Registrar and Outbound Proxy scenarios

Scenario #1

Scenario #2

Using SIP over TCP

Using SIP-TLS

Resolution of DNS Entries for REGISTER and INVITE messages

This section is applicable for SIP Trunk Providers that use a FQDN as a Registrar or Outbound Proxy.

3CX alters its behavior depending on how it resolves the Registrar and/or Outbound Proxy of a SIP Trunk. This section describes how 3CX does the resolution and what behavior it will exhibit in each case.

"Registrar" & "Outbound Proxy" fields in SIP Trunk configuration example.

In this section, the Registrar “sip.contoso.com” and Outbound Proxy “outproxy.contoso.com” are used as examples,corresponding to the “Registrar” and “Outbound Proxy” in the SIP Trunk settings.

For a “Registration-based”  SIP Trunk, these fields determine both the SIP Domain and the IP to which 3CX sends the REGISTER SIP message, but also where to send INVITE SIP messages when outbound calls are being made.

For an “IP-based” SIP Trunk,these fields determine where to send the INVITE SIP messages as no registration is required.

DNS Record Types 3CX tries to Resolve

Following is a description of how 3CX resolves each type of DNS Record and in which exact order:

NAPTR Record

When 3CX looks for an NAPTR record, it looks for a SIP-specific service with the following values:

  • SIPS+D2T (SIP over TCP-TLS)
  • SIP+D2T (SIP over TCP)
  • SIP+D2U (SIP over UDP)

3CX then reads the weight/priority of the answers and uses the one with the highest priority. Immediately the SRV record that the chosen answer has as a replacement value for is looked up.

SRV Records

When 3CX checks for SRV Records, it will do so in the following order:

  1. SIPS SRV: Tries to resolve “_sips._tcp.sip.contoso.com”. If not found, proceeds to the next.
  2. TCP SRV: Tries to resolve “_sip._tcp.sip.contoso.com”. If not found, proceeds to the next.
  3. UDP SRV: Tries to resolve “_sip._udp.sip.contoso.com”. If not found, proceeds to AAA Record explained next.

All SRV answers that are returned, are ordered based on their weight/priority. Entries found with the same weight and priority are used in a round robin fashion.

Note: The destination port may also be determined from the replacement SRV record.

AAAA / A Record

3CX tries to resolve the AAAA record (IPv6) and connect to the resolved address. IPv6 transport can be disabled within the 3CX Phone System to avoid connecting to a Provider using a not fully implemented IPv6 transport.

If no AAAA DNS record is found, 3CX tries to lookup the A Record (IPv4) and use that.

Registrar and Outbound Proxy scenarios

As a general rule, when the “Outbound Proxy” field is empty, 3CX resolves the “Registrar” value as the target IP.

If the “Outbound Proxy” field is populated, 3CX resolves the specified value, sends the messages to that IP and uses the “Registrar” value as the SIP Domain.

In both cases, the port to which the messages are sent can also be specified. In order for the port to be read from an SRV record, the port value must be set to 0.

Scenario #1

  • FQDN Registrar without Outbound Proxy with Registrar Port set to 0 or 5060.
    FQDN Registrar without Outbound Proxy with Registrar Port set to 0 or 5060
  • FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port set to 0.
    FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port set to 0

DNS records are resolved in the following order:

Priority

DNS Record

Transport Type

1

NAPTR

Depends on service value.

2

SIPS SRV

TCP / SIP-TLS

3

TCP SRV

TCP / SIP

4

UDP SRV

UDP / SIP

5

AAAA

UDP / SIP

6

A

UDP / SIP

3CX attempts to connect to the first successfully resolved IP and port.

Scenario #2

  • FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port other than 0.
    FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port other than 0
  • FQDN Registrar with IP Outbound Proxy.
    FQDN Registrar with IP Outbound Proxy
  • FQDN Registrar without Outbound Proxy with Registrar Port other than 0 or 5060.
    FQDN Registrar without Outbound Proxy with Registrar Port other than 0 or 5060

DNS records are resolved in the following order:

Priority

DNS Record

Transport Type

1

AAAA

UDP / SIP

2

A

UDP / SIP

Using SIP over TCP

3CX attempts SIP communication using TCP when:

  • It finds a NAPTR record with the “SIP+D2T” service as highest priority,
  • In the absence of the above, a TCP SRV record is found.
  • You prepend “transport-tcp.” in front of the Registrar value (this way you force SIP over TCP).

SIP over TCP has an additional requirement apart from using the TCP transport. The SIP message must also contain the ”transport=TCP” parameter in the SIP headers in all SIP messages. This is not done automatically based on the DNS resolution mechanism.

Prepend <b><b><b>“transport-tcp.”</b></b></b> in front of the Registrar IP or address in the SIP Trunk configuration in 3CX Management Console

For 3CX to add the necessary parameter in the SIP messages you must prepend “transport-tcp.” in front of the Registrar IP or address in the SIP Trunk configuration in 3CX Management Console.

Using SIP-TLS

3CX checks for a SIPS SRV or a NAPTR pointing to one, and if it is found, it attempts to register over SIP-TLS. However, in the current version of 3CX, SIP-TLS is not yet fully implemented. You may disable this functionality by disabling TLS support within the PBX completely (also affects clients and SBC connections).

Resolution of DNS Entries for REGISTER and INVITE messages

3CX handles the resolution of DNS entries the same way both when it is attempting to register and when it is attempting to initiate an outbound call by sending an INVITE message. This means that if there is an A/AAAA Record with multiple addresses or an SRV entry with multiple entries with the same weight/priority, it could happen that 3CX registers to IP A, but when making and outbound call, the INVITE is sent to IP B.

Option <b><b><b>“Force Invites to be send to IP of Registrar”</b></b></b> in the <b><b><b>“Options”</b></b></b> tab in the SIP Trunk settings.

If this is not supported by the SIP Trunk provider under testing, enable option “Force Invites to be send to IP of Registrar” in the “Options” tab in the SIP Trunk settings, to always send INVITE messages to the IP that 3CX resolved to send the REGISTER message.

Free for up to 1 year! Select preferred deployment:

On-Premise

for Linux on a $200 appliance or as a VM

Get the ISO

On-Premise

for Windows as a VM

Download the setup file

On the cloud

In your Google, Amazon, Azure account

Take the PBX Express