3CX SIP Trunk DNS Record Resolution Mechanism

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.

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.

Controlling DNS Lookup

"Auto Discovery" option

In the “General” tab next to the Registrar and Outbound Proxy fields there is the option “Auto Discovery”. When this option is disabled, the port must be manually specified. In this configuration 3CX will not attempt to look for NAPTR or SRV entries, it will only check for A or AAAA records.

When “Auto Discovery” is enabled, the port is determined automatically from the SRV entry. When no SRV entry is found, the port is assumed to be 5060.

"Transport Protocol" and "IP Mode" options

In the “Options” tab, there are the following settings that can help control what DNS lookup 3CX will use to resolve and Registrar or Outbound Proxy FQDN:

The options that are available are the following:

  • Transport Protocol
  • Any
  • UDP
  • TCP
  • TLS

When “Any” is selected, all DNS records will be looked up as explained in section “DNS Record Types 3CX tries to Resolve”.

When “UDP”, “TCP” or “TLS” is selected, NAPTR DNS records will be ignored and the PBX will only attempt to lookup a corresponding SRV of the mode selected. If no SRV is found it will attempt an A/AAAA record lookup. The transport will always match the mode selected. Additionally, when “TLS” is selected, there is an option to upload a Root Certificate that may be required to establish the TLS connection.

  • IP Mode
  • Any:
  • IPV4:
  • IPV6:

When “Any” is selected, 3CX will attempt to connect to whatever IP Mode is returned from the DNS Lookup. When selecting “IPV4” or “IPV6”, 3CX will only attempt the selected mode.

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 a 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 there is no NAPTR record, 3CX checks for SRV Records in the following order:

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

All SRV answers that are returned, are ordered based on their weight/priority. Entries found with the same weight and priority are read in a round robin fashion until a successful SIP conversation is made.

Also, in order for 3CX to attempt SIPS, a certificate must be specified in the “Options” tab. If no certificate has been specified and no matching certificate is available in the system, 3CX will not attempt to connect over SIPS.

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, option “Auto Discovery” must be enabled.

Scenario #1

Registrar Proxy


FQDN Registrar without Outbound Proxy with Registrar set to “Auto Discovery” and “Transport Protocol” set to “Any”.

Outbound Proxy

FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port set to “Auto Discovery” and “Transport Protocol” set to “Any”.

DNS records are resolved in the following order:

Priority

DNS Record

Transport Type

1

NAPTR

Depends on service value.

2

UDP SRV

UDP / SIP

3

TCP SRV

TCP / SIP

4

SIPS SRV

TCP / SIP-TLS

5

AAAA

UDP / SIP

6

A

UDP / SIP

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

Scenario #2

Registrar and Outbound Proxy - 5060

FQDN Registrar with FQDN Outbound Proxy with Outbound Proxy Port set manually and “Transport Protocol” set to “Any”.

Registrar and Outbound Proxy Example

FQDN Registrar with IP Outbound Proxy and “Transport Protocol” set to “Any”.

Registrar and Outbound Proxy - Any Transport Protocol

FQDN Registrar without Outbound Proxy with Registrar Port set manually and “Transport Protocol” set to “Any”.

DNS records are resolved in the following order:

Priority

DNS Record

Transport Type

1

AAAA

UDP / SIP

2

A

UDP / SIP

Alternative Proxy

The "Alternative Proxy" option found in the "Options" --> "Advanced" section of the SIP Trunk settings works as a second proxy address with the only difference being that if a "Registrar" and a "Secondary Proxy" are present, the PBX will first use the "Registrar" resolved targets to register or send calls to and if that fails it will then switch over to the "Secondary Proxy" resolved targets.

When present the PBX will resolve the FQDN when the trunk is added, according to what was discussed above with the only difference being that if the FQDN includes a port, only the A and AAAA records will be resolved for that FQDN e.g. “altproxy.contoso.com:5060”

If no port is included then the PBX will perform the full DNS query according to the rules discussed above.

The alternative proxy will only be used if the "Registrar" and "Outbound Proxy" targets fail. When the "Alternative Proxy" is used the SIP Domain by the PBX for Registration or Invite messages is still the "Registrar" value.

Last Updated

This document was last updated on 25 July 2024

https://www.3cx.com/docs/sip-trunk-dns-record-resolution/