Trunks

Trunks

Overview

A Trunk is a SIP connection between your phone system and a VOIP provider for inbound and outbound calls.

The SIP trunk configuration depends on your VoIP provider. There are:

  • registration-based SIP Trunks

    • i.e. via username and password

  • IP-based trunks

    • i.e. PBX public IP is linked to the provider.

Please check with your provider the necessary configuration parameters.

For Sample trunk configurations go to: Examples of Trunks

Trunks section

This page describes the Trunks configuration on the New Client Experience, available from version 3.45.0. We recommend using the New Experience web interface to take full advantage of the latest features.

You can find the Trunks section under the Tools menu. When you click on it, you can see all the already existing Trunks.

image (8)-20250108-150224.jpg

You can edit, clone or delete a trunk clicking the three dots button (⋮) next to the trunk of interest. You can access the realtime panel to monitor trunk activity.

Furthermore, under Tools → Trunks, you can:

  • search for a specific trunk

  • clear all filters

  • manage columns, by selecting or not them

  • activate the advanced search for each field

  • create a new trunk

Create a Trunk

To create a new Trunk:

  1. Click the Add button, under Tools → Trunks

image-20250108-150707.png
  1. Enter the Trunk’s details:

  • Name

  • Domain/Host name (please refer to your provider)

  • Authentication Password

  • Default User Name

  • Trunk Registry string (which is usually defaultuser:password@host)

  1. Click the Active flag to enable it

  2. Click Add

Don't forget to configure the Inbound and Outbound routes to properly route the incoming and outgoing calls.

Edit a Trunk

In the Trunks section, clicking the three dots button (⋮) next to the trunk, you can:

Settings

In the Settings Section, you can change general settings inserted at trunk generation (like name, default user, password, context and so on) plus a set of other parameters (in this section and the Advanced and Other Fields).

  • Active: enable or disable the trunk

  • Host: domain or host name

  • Secret: Authentication password

  • Default User: Authentication user

  • Context: the applicable context

  • Caller ID: The Caller ID in the format "name"

  • Type:

    • "user" is matched on username (in the From: header)

    • "peer" is matched on IP address

    • "friend" allows both, but can introduce matching ambiguity

  • DTMF Mode: how DTMF (Dual-Tone Multi-Frequency) tones are transmitted:

    • RFC2833 (default): DTMF tones are sent via RTP, outside the audio stream

    • INBAND: DTMF is sent within the audio stream and is audible. This method requires high CPU usage

    • INFO: DTMF is sent using SIP INFO messages. Reliable but not widely supported by all PBX systems and SIP trunks

  • NAT: adjusts Asterisk behavior for clients behind firewalls.
    If any of the comma-separated options is set to no, Asterisk will override other settings and set nat=no.

  • Qualify: determines when the SIP is achievable

  • Allowed Codecs: specifies the list of supported codecs, ordered by priority

  • Insecure: defines how Asterisk handles connections from peers with insecure settings. Useful for compatibility with certain SIP trunks.

  • Calls Limit: maximum number of concurrent inbound and outbound calls allowed

  • Optional Description

Advanced

  • Registry: required for receiving inbound calls when authentication is needed

  • Direct Media: Asterisk by default tries to redirect the RTP media stream to go directly from the caller to the callee. Some devices do not support this (especially if one of them is behind a NAT).

    • The default setting is YES.

    • If you have all clients behind a NAT, or for some other reason want Asterisk to stay in the audio path, you may want to turn this off.

  • Call Counter: enables call counters on devices

  • From Domain: sets the default From:domain in SIP messages when Asterisk acts as a SIP user agent. Some providers require this to be a valid domain instead of just an IP address

  • From User: defines the username to be sent in the From header when placing calls to the peer (another SIP proxy). Used for authentication. Valid only for type=peer.

  • Outbound Proxy: IP address, hostname, or SRV record of the outbound SIP proxy. SIP signaling is routed to this proxy instead of directly to the device. Valid only for type=peer.

  • Add Phone to URL: If enabled (yes), appends ;user=phone to SIP URIs. Required by some providers for proper number recognition.

  • Trust Remote Party ID: defines whether Asterisk should trust the Remote-Party-ID header sent by the peer.

  • Send Remote Party ID Header: specifies whether Asterisk should send the Remote-Party-ID header.

    • yes: header is sent

    • no: header is not sent

  • Encryption: determines if SRTP encryption is required for media.

    • yes: only encrypted media is allowed. If the peer doesn't support SRTP, the call fails (HANGUPCAUSE=58).

    • no: unencrypted media is allowed.

  • Port: the SIP port used to communicate with the peer (typically 5060 or 5061).

  • Transport: preferred transport protocols for SIP signaling. Examples: udp, tcp, tls.

  • T38pt Udptl: settings related to T.38 UDPTL.

    • Example: yes,redundancy,maxdatagram=400

  • Video Support: Enables or disables support for video calls. If yes: Asterisk negotiates video streams if supported by the peer.

As indicated in the sip.conf file, the format of Asterisk's register directive is as follows:

register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry]

To send the REGISTER using the TCP protocol, it is necessary to explicitly specify the transport in the dedicated field.

E.g.:

register => tcp://username:password@host

Other Fields

In the Other Fields section you can specify other fields to add in the trunks conf files. Follow default asterisk format (key=value), each field on a single row.

Monitor Trunk Status

To monitor the trunk registration status:

  1. Go to Realtime section under Voice menu

  2. Click Trunks tab

  1. Check the information in realtime:

  • Trunk Status, which shows status of a SIP trunk registration to motion server

  • Registry, which shows SIP registration status when Motion registers as a client to the provider.

Examples of Trunks

Scenario 1: Motion and VoIP provider

image-20250609-083650.png

Trunk General settings for Motion and VoIP provider scenario
Host: provider host domain
Secret: password
Default user: authentication username, i.e. phone number
Context: from-voip-provider
Caller ID: "" <>
Type: friend
DTMF mode: rfc2833
NAT: force_rport,comedia
Qualify: yes
Allowed codecs: ulaw, alaw, gsm
Insecure: port,invite
Calls limit: 1000

Trunk Advanced settings for Motion and VoIP provider scenario
Registry: registry string
Direct media: no
Call counter: yes
From domain: provider domain
Add phone to URL: no
Trust remote party ID: no
Send remote party ID header: no
Encryption: no
Transport: udp

Registry string

The format of the registry string is usually:

defaultuser:secret@host or defaultuser:secret@host/callerid (in the most of cases the callerid and the defaultuser are the same).

Scenario 2: SIP Gateway Digium

image-20250609-083827.png

Trunk General settings - SIP Gateway Digium
Host: dynamic
Secret: password
Default user: authentication username
Context: from-voip-provider
Caller ID: "" <>
Type: friend
DTMF mode: rfc2833
NAT: force_rport,comedia
Qualify: yes
Allowed codecs: ulaw, alaw, gsm
Insecure: port,invite
Calls limit: 1000

Trunk Advanced settings - SIP Gateway Digium
Direct media: no
Call counter: yes
Add phone to URL: no
Trust remote party ID: no
Send remote party ID header: no
Encryption: no
Transport: udp
T38pt Udptl: no

Scenario 3: TWILIO SIP trunk

The following Interconnection Guide provides you with a step-by-step configuration to use XCALLY with Twilio Trunks:

image-20250609-083941.png
  1. Access your Twilio account and order the Inbound DID number you want to associate with the SIP Trunk

  1. Locate the Twilio section Elastic SIP Trunk and select the tab Configure, then click on Create SIP Trunk

 

Give a name to the new SIP Trunk and Save

  1. Edit the created SIP Trunk and fill in the:

3.1 Termination: create your own Twilio Termination SIP URI (in our example training1.pstn.twilio.com)

image-20250609-084200.png

3.2 Click on to + Create IP Access Control List section to enable only the IP address of your XCALLY server for security reason (in our example 197.22.150.2)

3.3 Click on to the + Create Credential List link and insert the user and password you want to use for this SIP Trunk autentication 

3.4 SAVE the Termination section configuration
3.5 Select the Origination tab and create your Origination URI (We suggest you to fill it with: sip:DIDNumber@XCALLY-IP-ADDRESS)

3.6 Select the Numbers Tab and ADD the number you have bought in order to associate the number to the created Trunk and SAVE

For inbound call being properly routed to your XCALLY server, you need to Whitelist the Twilio IP address, so to accept VoIP traffic from the Twilio servers:
https://www.twilio.com/user/account/sip-trunking/your-network
Check your Firewall and XCALLY server iptables to accept those IP address requests!

Trunk General settings - Twilio SIP
Host: provider host domain
Secret: password
Default user: authentication username
Context: from-voip-provider
Caller ID: "" <>
Type: friend
DTMF mode: rfc2833
NAT: force_rport,comedia
Qualify: yes
Allowed codecs: ulaw, alaw, gsm
Insecure: port,invite
Calls limit: 1000

Trunk Advanced settings - Twilio SIP
Direct media: no
Call counter: yes
From user: phone number
Add phone to URL: no
Trust remote party ID: no
Send remote party ID header: no
Encryption: no
Transport: udp
T38pt Udptl: no

Scenario 4: Motion and FreePBX

  1. Create a SIP extension on your FreePBX (your inbound calls will be routed on xCALLY)

  1. Choose an extension number in according to your dial plan, in the example below we used 9000

Pay attention to set Outbound Concurrency Limit to “No Limit” and Call Waiting to “Enable”.

  1. Change, if you want, the password of the extension. In the example, the password is xcally1234

Trunk General settings for Motion and FreePBX
Host: provider host domain
Secret: password
Default user: authentication user
Context: from-voip-provider
Caller ID: "" <>
Type: friend
DTMF mode: rfc2833
NAT: force_rport,comedia
Qualify: yes
Allowed codecs: ulaw, alaw, gsm
Insecure: port,invite
Calls limit: 1000

Trunk Advanced settings for Motion and FreePBX
Registry: registry string
Direct media: no
Call counter: yes
Add phone to URL: no
Trust remote party ID: no
Send remote party ID header: no
Encryption: no
Transport: udp
T38pt Udptl: no

Registry string

The format of the registry string is usually:

defaultuser:secret@host or defaultuser:secret@host/callerid (in the most of cases the callerid and the defaultuser are the same).