Post

AWS Chime SIP Trunking Integration with VoIP Asterisk

Abstract

Session Initiation Protocol (SIP) trunking is a technology used in Voice over Internet Protocol (VoIP) telephony that enables the connection of a private branch exchange (PBX) to the internet. It allows businesses to make and receive phone calls over the internet instead of traditional telephone lines.

This technology allows to use standard IT infrastructure and connect globally remote offices, perform integrations with SIP core with CRM, call recording systems, enhancing Digital Business.

There are a lot of SIP providers around the globe. Most TelCo company provide SIP Trunks as additional service, also there are some service providers like Twillio that specialize in integrations.

AWS also provides Chime service with SIP trunking. In this post we will configure it with Asterisk and check the benefits of VoIP communication:

  • Cost-Effective Communication: AWS Chime SIP trunking allows you to pay only for the minutes you use, making it a cost-effective solution for businesses of all sizes. Asterisk, being an open-source platform, also helps reduce costs compared to proprietary solutions.
  • Scalability: AWS Chime SIP trunking can scale to support a large number of concurrent calls, ensuring that your communication infrastructure can grow with your business needs. Asterisk’s flexibility and scalability make it easy to add new features and expand your communication capabilities.
  • Reliability: AWS offers high availability and reliability for its services, including Chime SIP trunking. By using AWS Chime with Asterisk, you can ensure that your communication system is always up and running, minimizing downtime and disruptions.

Target Architecture

We have already setup Asterisk on EC2 instance in previous post Open Sourced VoIP telephony Asterisk installation on AWS EC2 instance , right now we will perform AWS Chime installation and configure both sides of Trunk.

At the end multiple sites with own pbx-phone extensions can connected to such endpoint, also mobile subscribers that are using softphone or have native support in devices can perform calls.

vpc_asterisk.png

AWS Chime configuration

Configuration starts with creating a new connection:

img.png

img_1.png

img_2.png

In orders you choose different phone numbers and attach them to Trunk:

img.png

img_3.png

img_4.png

Termination

Important configurations here:

  • Outbound host name (note this DNS host name of SIP Trunk): it will be used on Asterisk configuration side
  • Allowed hosts list: we can limit IP-addresses or NW-addresses that are allowed to connect
  • Calls per second: rate allowed for parallel lines calls transfer
  • Calling plan: select countries that are allowed for outgoing calls
  • Credentials: authentication of username/password, register records per VoIP station

img.png

Origination

Has settings that are used for Inbound VoIP traffic configuration. We will skip it for now.

FreePBX Configuration

Trunk Configuration

  • Outbound CallerID should be set same as was created on AWS Chime side

img_5.png

  • Registration set to none
  • SIP Server set to AWS Chime Termination Endpoint value
  • SIP Server Port 5060 for UDP, 5061 for TCP 5062 for TLS
  • Transport choose based on the protocol selected

img.png

  • From Domain set to AWS Chime Termination Endpoint value img.png

  • Send RPID/PAI set to Send P-Asserted-Identity header img.png

  • for Codecs select ulaw img.png

Outbound Configuration

Now we need to add Route to SIP trunk and specify routing rules - what calls should be mapped to created trunk. To achieve this we will create Outbound Configuration. Same way Inbound Configuration is created for incoming calls from SIP Trunk.

img.png

Dialing Patterns

A Dial Pattern is a unique set of digits that will select this route and send the call to the designated trunks. If a dialed pattern matches this route, no subsequent routes will be tried. If Time Groups are enabled, subsequent routes will be checked for matches outside of the designated time(s).

RuleDetails
Xmatches any digit from 0-9
Zmatches any digit from 1-9
Nmatches any digit from 2-9
[1237-9]matches any digit or letter in the brackets (in this example, 1,2,3,7,8,9)
.wildcard, matches one or more characters
prepend:Digits to prepend to a successful match. If the dialed number matches the patterns specified by the subsequent columns, then this will be prepended before sending to the trunks.
prefix:Prefix to remove on a successful match. The dialed number is compared to this and the subsequent columns for a match. Upon a match, this prefix is removed from the dialed number before sending it to the trunks.
match pattern:The dialed number will be compared against the prefix + this match pattern. Upon a match, the match pattern portion of the dialed number will be sent to the trunks
CallerID:If CallerID is supplied, the dialed number will only match the prefix + match pattern if the CallerID being transmitted matches this. When extensions make outbound calls, the CallerID will be their extension number and NOT their Outbound CID. The above special matching sequences can be used for CallerID matching similar to other number matches.

We specify code numbers for international call system with 11 and 7 digits, including +.

Now any local extension that is connected to Asterisk when dialing one of this patterns will be connected to SIP Trunk

img.png

Asterisk configuration from CLI

If you are not using GUI FreePBX same configuration can be done from CLI on raw Asterisk:

pjsip.aor.conf:

1
2
3
4
[aws_chime]
type=aor
qualify_frequency=60
contact=sip:xxxxxxxxbh.voiceconnector.chime.aws:5060

pjsip.endpoint.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[aws_chime]
type=endpoint
transport=0.0.0.0-udp
context=from-pstn
disallow=all
allow=ulaw
aors=aws_chime
rtp_keepalive=0
language=en_GB
from_domain=xxxxxxxx.voiceconnector.chime.aws
user_eq_phone=no
t38_udptl=no
t38_udptl_ec=none
fax_detect=no
trust_id_inbound=no
t38_udptl_nat=no
send_pai=yes
direct_media=no
rtp_symmetric=yes
dtmf_mode=auto

Now configuration is done, after Asterisk reload any extension can perform outgoing calls using AWS Chime.

1
2
# asterisk -rvv
> core reload

In the next post we will deep dive into SIP protocol and will troubleshoot AWS Chime Trunk using multiple tools.

This post is licensed under CC BY 4.0 by the author.