SIP Trunking Configuration Guides

The following Configuration Guides are intended to help you connect your SIP Infrastructure (IP-PBX, SBC, etc) to a Twilio Elastic SIP Trunk.

Be aware, due to the large number of versions, variations, add-ons, and options for many of these systems, the settings you see may differ from those shown in our Configuration Guides. As such, these documents are intended as general guidelines, rather than configuration templates. There is an assumption of familiarity with your network and SIP infrastructure, and how they work.

Twilio cannot provide direct support for third-party products; you should contact the manufacturer for your PBX/SBC for assistance in configuring such products.

If you wish to share your PBX or SBC configuration guide to help us improve this section for other users, kindly submit them or any corrections to the existing guides to sip.interconnectionguides@twilio.com.

Vendor Type Qualified for Secure Trunking
Asterisk IP-PBX Yes
FreeSwitch IP-PBX Yes
3CX IP-PBX No
Elastix IP-PBX No
Free PBX IP-PBX No
Grandstream IP-PBX No
Acme Packet E-SBC No
Cisco ISR E-SBC No
Sonus using Microsoft Lync E-SBC Yes
Audiocodes E-SBC No
AudioCodes using Microsoft Lync E-SBC No
EdgeMarc E-SBC No
inGate E-SBC Yes
Sansay E-SBC No
xCally Call Center Yes
Mitel MiVoice Business 7.2 Communication Platform Yes

IP-PBX

Asterisk IP-PBX

Assuming you have Asterisk already set up as your IP-PBX, with one or more telephones configured and running calls between them, the following guide provides detailed step-by-step instructions of how to configure your Trunk and your Asterisk IP-PBX. Optionally, Twilio Elastic SIP trunking also provides Secure Trunking (SIP TLS and SRTP), see guide for configuration details.

Click here to download the Asterisk Interconnection Guide

FreeSwitch IP-PBX

Assuming you have FreeSwitch already set up as your IP-PBX, with one or more telephones configured and running calls between them, the following Interconnection Guide provides you with step-by-step instructions to use FreeSwitch PBX with your Twilio Elastic SIP Trunk.

Click here to download the FreeSwitch PBX Interconnection Guide

FreeSwitch using Secure Trunking

This is supported. At this time there is no guide published but reach out to support if you have any questions.

Twilio Elastic SIP trunking also provides Secure Trunking (SIP TLS and SRTP).

This guide provides the configuration steps required to implement FreeSwitch PBX using a Twilio Elastic SIP trunk using Secure Trunks.

Click here to download the FreeSwitch PBX with Secure Trunking Interconnection Guide

3CX

Assuming you have your 3CX already set up with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

  • Add a new VoIP Provider account in the 3CX phone system: "Twilio"
    • Set the SIP server hostname to: example.pstn.twilio.com
    • Set your Authentication ID/username and password (as you configured in your user credentials on your Twilio Trunk)
  • DID’s and Inbound Call Identification: Enter your Twilio numbers under the "DID" tab.
  • "Advanced" under "Codec priorities" only include G711 U-law
  • Create Outbound Call Rules: setting calls to numbers with a length of 10, and also prepend a "+1". This will ensure E164 formatting.

Click here to download the 3CX Interconnection Guide

Elastix

If you want to use Elastix IP-PBX with your Twilio Trunk, the following guide provides detailed step-by-step instructions of how to configure your Trunk and your IP-PBX.

Click here to download the Elastix Interconnection Guide

Free PBX

Assuming you have Free PBX already set up as your IP-PBX, with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

Click here to download the Free PBX Interconnection Guide

GrandStream UCM

The following Interconnection Guide provides you with step-by-step instructions to use GrandStream UCM with your Twilio Elastic SIP Trunk.

Click here to download the Grandstream Interconnection Guide

Mitel MiVoice Business 7.2

The following guide is not maintained by Twilio. Please see Mitel Knowledge base for latest guide.

Click here to download the Mitel MiVoice configuration Guide

Enterprise Session Border Controller (E-SBC)

Acme Packet SBC

Assuming you have your SBC already set up with your IP-PBX, with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio trunk.

Make sure you have your Network & Physical Interfaces appropriately configured.

Configure your Trunk SIP Interface towards Twilio:

sip-interface
state               enabled
realm-id            OUTSIDE
description
sip-port
address             X.X.X.X   (add this to your Twilio IP ACL)
port                5060
transport-protocol  UDP
tls-profile
allow-anonymous     agents-only
ims-aka-profile
carriers
trans-expire        0
...

Configure your Session Agent towards Twilio:

session-agent
hostname          example.pstn.twilio.com
ip-address
port              5060
state             enabled
app-protocol      SIP
app-type
transport-method  UDP
realm-id          OUTSIDE
egress-realm-id
description       Twilio
carriers
allow-next-hop-lp enabled
constraints       disabled
...

The second example presented here illustrates adding +1 to called numbers (To and Request-URI headers) for all SIP trunk endpoints in a particular realm.

Firstly, define the session-translation with a called rule:

session-translation
id             addCalledPlusOne
rules-calling
rules-called   addPlusOne

Then define the rule to append +1:

translation-rules
id            addPlusOne
type          add
add-string    +1
add-index     0
delete-string
delete-index  0

Lastly, apply the translation as outgoing to the SIP trunk realm:

realm-config
identifier          OUTSIDE
...
in-translationid
out-translationid   addCalledPlusOne
...

Set the preferred codec to G711 mu-law. In the example below, the Net-Net SD manipulates the codec list for all PBXs in the PBXs realm such that PCMU appear first in the media descriptor offered to the SIP trunk:

realm-config
identifier  PBXs
...
options     preferred-codec=PCMU
...

Cisco ISR (Cisco 28xx, 29xx, 38xx, 39xx, 43xx etc.)

Assuming you have your ISR already set up with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

If you use credentials for outbound calls, you must use the B2BUA built into Cisco IOS:

sip-ua
authentication username anniebp password 7 15431A0D1E0A1C171060302610 realm sip.twilio.com
registrar dns:example.pstn.twilio.com expires 3600
sip-server dns:example.pstn.twilio.com
!

Update your Trust List:

voice service voip
ip address trusted list
ipv4 54.172.60.0/23
ipv4 54.171.127.192/26
ipv4 54.65.63.192/26
ipv4 54.169.127.128/26
ipv4 54.252.254.64/26
ipv4 177.71.206.192/26
allow-connections sip to sip
!

Ensure all numbers use full E.164 format, so transform all outbound calls to E.164 before sending to Twilio. The rules below are doing 2 things: changing this outbound call from 919803331212 to +19803331212 and changing the ANI from 4002 to 9802180999.

voice translation-rule 1
 rule 1 /^91/ /+1/
!
voice translation-rule 2
 rule 1 /4004/ /9802180971/
 rule 2 /4002/ /9802180999/
 rule 3 /4005/ /9802180980/
!
!
voice translation-profile twilio
 translate calling 2
 translate called 1
!

Lastly, you may have a dial-peer with 91[2-9]..[2-9]...... in order to catch the calls. You can see the translation profile that is applied to translated the number to E.164. Also ensure G.711 codec is used. The ‘session target sip-server’ is what target the sip B2BUA configured above with the ‘sip-ua’ command.

dial-peer voice 200 voip
translation-profile outgoing twilio
destination-pattern 91[2-9]..[2-9]......
session protocol sipv2
session target sip-server
dtmf-relay rtp-nte sip-kpml sip-notify
codec g711ulaw
no vad
!

Sonus E-SBC 5000 using Microsoft Lync

Assuming you have your E-SBC already set up, the following highlights specific configuration for your Sonus E-SBC for interworking with Microsoft's Lync Server 2013 environment using your Twilio Trunk.

Click here to download the Sonus Microsoft Lync Interconnection Guide

Audiocodes SBC

Assuming you have your SBC already set up with your IP-PBX, with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

Make sure you have an IP Group defined with:

IPGroup_Description: Twilio
IPGroup_SIPGroupName: domain.pstn.twilio.com
...

Define your Proxy IP:

[ ProxyIp ]
FORMAT ProxyIp_Index = ProxyIp_IpAddress, ProxyIp_TransportType, ProxyIp_ProxySetId;
ProxyIp 1 = "54.172.60.0/23:5060", 0, 2;
ProxyIp 2 = "54.171.127.192/26:5060", 0, 2;
ProxyIp 3 = "54.65.63.192/26:5060", 0, 2;
ProxyIp 4 = "54.169.127.128/26:5060", 0, 2;
ProxyIp 5 = "54.252.254.64/26:5060", 0, 2;
ProxyIp 6 = "177.71.206.192/26:5060", 0, 2;
[ \ProxyIp ]

Have a Coders Group with:

CodersGroup0_Name: g711ulaw64k
CodersGroup0_pTime: 20
CodersGroup0_PayloadType: 0

You will also need to define your IP Profiles & Routing rules.

AudioCodes using Microsoft Lync

Assuming you have your E-SBC already set up, the following highlights specific configuration for your AudioCodes E-SBC for interworking with Microsoft's Lync Server 2013 environment using your Twilio Trunk.

Click here to download the Audio Codes using Microsoft Lync Interconnection Guide

EdgeMarc

Assuming you have your SBC already set up with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

Navigate to "VoIP">"SIP" to configure the SIP server info for Twilio. Enter in the SIP Server FQDN assigned for these services under the SIP Server Address field. Fill in the SIP Server Domain field with the proper Twilio domain.

Note: Make sure to check the "Limit Inbound to listed Proxies" and "Limit Outbound to listed Proxies" boxes to help prevent fraudulent activity sourced from a LAN side PBX or a WAN side DoS attack.

EdgeMarc SIP Settings

Navigate to "VoIP ALG" and then "B2BUA" to configure the SIP Trunk registration with the soft-switch (between the EdgeMarc and the WAN side soft-switch), the PBX for SIP registration mode (between the PBX and LAN side of the EdgeMarc), inbound rule (for sending SIP messages from the WAN side of the EdgeMarc to the PBX) and outbound rule (for sending the SIP messages from the EdgeMarc to the WAN soft-switch). RFC-4904 support will be handled by applying header manipulation action rules to the matched outbound rules.

Configuring the PBX for SIP registration mode (between PBX and the EdgeMarc). From the "Trunking Devices" section:

  • Click the "New Row" button to get to a new entry for a Trunking Device.
  • Enter a PBX name in the "Name" field.
  • Select the correlating PBX from the drop-down list of the "Model" field.

EdgeMarc Trunking Device Settings

  • Select IP Registration mode by selecting the radio button for using the IP field and Port field.
  • Enter the PBX IP in the "IP" field.
  • Enter 5060 in the "Port" field. Click "Update" to create a Trunking Device for PBX. Click "Submit" at the bottom of the page to send the config to the EdgeMarc.

Configure the EdgeMarc default inbound rule (for sending the SIP messages from the EdgeMarc to the PBX). This is required in order for non-pilot DIDs to reach the PBX.

From the Actions section:

  • Click the "New Row" button to get a new entry for creating an inbound action.
  • Enter the action name in the "Name" field.
  • Select the radio button of "Trunking Device".
  • Select the PBX from the drop-down list next to "Trunking Device".

EdgeMarc Default Rule Settings

  • Click the "Update" button.

From the Match section:

  • Click the "New Row" button to get a new entry for an inbound rule.
  • Select "Inbound" in the "Direction" field.
  • Select the radio button of "Default".
  • Select "InboundAction" from the drop-down list of the "Action" field.
  • Click the "Update" button.

EdgeMarc Default Rule Settings

From the Match section:

  • Click the "New Row" button to start a new entry for an outbound rule.
  • Select "Outbound" in the "Direction" field.
  • Select the radio button of "Pattern match", select "Calling" from the drop-down list and enter a "." or match the partial DID map (for example, if there is 6785551111-1115, then use 678555111X) in the "Pattern match" field to match any calling numbers.
  • Select "Any" from the "Source" field.
  • Select OutboundAction1 from the drop-down list of the "Action" field.
  • Click the "Update" button.

EdgeMarc Default Rule Settings

  • Click "Submit" at the bottom of the page to send the config to EdgeMarc.

inGate SIParator

The following Interconnection Guide provides you with step-by-step instructions to use inGate SIParator E-SBC with Twilio Elastic SIP Trunk. Optional steps to configure SIP over TLS and SRTP (Secure Trunking) are also included in this guide.

Click here to download the inGate Interconnection Guide

Sansay

Assuming you have your SBC already set up with one or more telephones configured and running calls between them, the following highlights specific configuration for use with your Twilio Trunk.

Sansay Configuration Sansay Configuration Sansay Configuration Sansay Configuration

Other Network Elements

xCally Call Center

The following Interconnection Guide provides you with step-by-step instructions to use XCally Call Center your with Twilio Elastic SIP Trunk.

Click here to download the xCally Interconnection Guide

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.