Twilio Trunk

Top  Previous  Next
Solution Integration > PBXs > BT Call Server > Example Configurations > Trunks Configuration

 

Twilio Trunk

 

Here is the Ad-Hoc procedure to define a Trunk between Twilio and Asterisk.

 

1. Connect to Twilio and open the Elastic SIP Trunking page and select "Create new SIP Trunk"

 

Example-Trunk-Twilio_01

 

2. Set a Name for the Trunk

 

3. Go to "Termination" tab

 

4. Define a "Termination SIP URI" that Asterisk will use to reach out to Twilio and add in the "IP ACL" field the list of IP addresses that INVITE from Asterisk will come from (technically the Public IPs of your infrastructure)

 

Example-Trunk-Twilio_02

 

5. Go to "Origination" tab

 

6. Enter the IP Address or Domain Name that Twilio should use to reach your infrastructure (e.g. "sip:1.1.1.1:5060;transport=tcp"). This entry must eventually lead to the Asterisk server.

 

For dual Asterisk node, put the two public IP addresses linked to the Asterisk servers. Put a priority of 10 for the primary Asterisk and 20 for the secondary.

 

Example-Trunk-Twilio_03

 

TableCornerTopLeftA

IPT_Empty

IPT_Empty

TableCornerTopRightA

IPT_Empty

ImportantNote_Icon

•The infrastructure's firewall needs to be open from/to the Twilio IP addresses and Asterisk servers for SIP and RTP ports : https://www.twilio.com/docs/sip-trunking#whitelist

 

•For dual Asterisk servers, each server will need a different public IP for the NAT to be able to use the failover mechanism.

 

•A SIP aware firewall/router is necessary to NAT the IP addresses inside the SIP packets.

This feature of a firewall / router is commonly referred to as a SIP ALG (Application Layer Gateway).

These devices are able to rewrite SIP packets with the correct IP address information as the traffic flows through them.

IPT_Empty

TableCornerBottomLeftA

IPT_Empty

IPT_Empty

TableCornerBottomRightA

 

7. Go to "Numbers"

 

8. Add at least 1 number which will be used to place calls

 

Example-Trunk-Twilio_04

 

9. Setup the Trunk and Extension configuration in Asterisk (Extension configuration tab). As seen in the below example.

 

; Extension definition needs to use the same number as defined in Twilio

 

[+443xxxxxxxxx](extension-defaults)

inbound_auth/username = +443xxxxxxxxx

inbound_auth/password = 123456

endpoint/callerid = Twilio <+443xxxxxxxxx>

 

; Trunk template definition

 

[twilio-trunk-defaults](!)

type = wizard

endpoint/context = incoming

endpoint/transport=transport-udp

endpoint/allow = !all,ulaw,alaw

endpoint/direct_media=no

endpoint/rewrite_contact=yes

endpoint/rtp_symmetric=yes

endpoint/dtmf_mode=rfc4733

endpoint/allow_subscribe = no

aor/qualify_frequency = 60

 

; Trunk definition

; For "remote_hosts" Add in the Twilio Termination URI as well as any additional Localized Termination URI's required. (comma separated)

; If you have set any credentials in the Twilio Trunk you can uncomment the "auth" settings below and fill their information

 

[TWILIO](twilio-trunk-defaults)

remote_hosts = asterisk-test.pstn.twilio.com,asterisk-test.pstn.dublin.twilio.com

;sends_auth = yes

;outbound_auth/username = username

;outbound_auth/password = password