• Choose:

Configure an Asterisk PBX Trunk

Introduction to Asterisk

Asterisk is an open source framework for building communications applications. Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, conference servers and other custom solutions. It is used by small businesses, large businesses, call centers, carriers and government agencies, worldwide.

You'll need to have created a credentials based connection on your Telnyx Mission Control Portal account, assigned this connection to a DID and outbound profile in order to make and receive calls. Our Mission Control Portal was designed with ease of use in mind, but if you need a little help check out our demo for setting up a SIP connection in a couple of minutes.

Asterisk PBX Prerequisites

  1. Download - Asterisk Version 16 is available to download from here.
  2. Installation - You can view the installation guide here.
  3. Configure Your Telnyx Mission Control Portal

Once you've configured your Telnyx account, you can now proceed to setup Asterisk following the guide below.

Asterisk PBX Setup Guide

Telnyx SIP Trunk Setup For Asterisk

Open up /etc/asterisk/pjsip_wizard.conf with your preferred editor, and add the rows as below, where username and password are custom for your installation:

type = wizard

endpoint/allow = !all,ulaw,alaw,G729,G722
endpoint/context = from-pstn
endpoint/force_rport = yes
aor/qualify_frequency = 60
sends_auth = yes
sends_registrations = yes
remote_hosts = sip.telnyx.com:5060
outbound_auth/username = username
outbound_auth/password = password
registration/expiration = 600

Note: For this configuration to work, the module res_pjsip_config_wizard.so must be installed and loaded, available from Asterisk 13.2.0.

Configure to Make and Accept Calls

​​Modify /etc/asterisk/pjsip_wizard.conf in order to add the global configurations for the extensions, and specific ones for the sample. Here we are setting up extension 1001 to make and accept calls. Parameters in the below section that reference 1001 and password can be customized for your requirements.

type = wizard
accepts_registrations = yes
sends_registrations = no
accepts_auth = yes
sends_auth = no
endpoint/context = from-internal
endpoint/allow = !all,ulaw,alaw,G729,G722
endpoint/dtmf_mode = rfc4733
endpoint/rewrite_contact = yes
endpoint/force_rport = yes
aor/max_contacts = 1
aor/remove_existing = yes
aor/minimum_expiration = 30

endpoint/callerid = Test User <1001>
inbound_auth/username = 1001
inbound_auth/password = [email protected]$

Completing the basic PJSIP configuration

Even though pjsip_wizard.conf is a great facilitator in setting up PJSIP endpoints, global configurations, or anything else that might be needed can still be added in /etc/asterisk/pjsip.conf. In the scope of our basic setup, add the lines below to pjsip.conf for installations behind NAT.

  • In case the PBX is not in a NATed network, you can safely remove the parameters external_media_address and external_signaling_address.
  • With the above configurations added to the respective files, your PBX should be now registered to Telnyx, and the extension 1001 in your IP phone/softphone should be registered to your PBX, but there is one last step needed in order to make calls flow.

Setting Up The Dialplan

Asterisk makes use of the dialplans saved in /etc/asterisk/extensions.conf in order to route calls between endpoints, among other tasks. To allow our extension 1001 to call the world through Telnyx, as well as send to it any calls that arrive to the Telnyx DID assigned to the respective trunk, you need to open up extension.conf and add the following lines of code:

exten => _+1NXXXXXXXXX,1,Dial(PJSIP/1001)
exten => _NXXXXXXXXX,1,Dial(PJSIP/1001)

exten = _NXXNXXXXXX,1,Dial(PJSIP/+1${EXTEN}@telnyx)
 same = n,Hangup()

exten = _X.,1,Dial(PJSIP/+${EXTEN}@telnyx)
 same = n,Hangup()
  • [from-pstn] is the context that captures inbound calls to the PBX coming from Telnyx, and sends them to the extension 1001. With the above lines, it will capture every call towards CLDs in US national (10 digit) or +E164 and send it to the extension 1001.
  • [from-internal] serves to route calls towards the world through Telnyx. In the example above, it will capture calls towards US national numbers, convert to +E164 or towards any other number, prepend “+”, and send the call to Telnyx.

That's it, you've now completed the configuration of Asterisk and can now make and receive calls by using Telnyx as your SIP provider!

Additional Resources

Review our getting started guide to make sure your Telnyx Mission Control Portal account is setup correctly!

Checkout Asterisk's help section for extra support!

Can't find what you're looking for? Click the Live Chat icon at your lower right hand corner and start a chat.

Was this page helpful?