Configuring an Asterisk Credentials Trunk

Comprehensive guide on configuring Asterisk with Telnyx for advanced VoIP communication and seamless call handling.

Written by Customer Success
Updated over a week ago

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.

There are two standard methods to connect an Asterisk box to Telnyx:

  • Asterisk (SIP), to use the same standard Session Initiation Protocol used to connect to SIP phones

  • Asterisk (PJSIP), to use the Open Source Embedded SIP protocol stack

Note: Telnyx does not support IAX2 connections.

For more Asterisk documentation, see:

Instructions for Configuring an Asterisk Trunk

In this guide, you will:


Video Walkthrough

Setting up your Telnyx SIP portal account so you can make and receive calls:

Note: Video walkthrough for Asterisk/Telnyx configuration coming soon. Check back as we update our docs.

1. Configuring the Telnyx Mission Control Portal

For step by step instructions on each of the requirements on the Telnyx Mission Control Portal, please follow this guide.

Once you've configured your Telnyx account, you're ready to set up Asterisk using the following configuration guide:

2. Configuring Asterisk SIP Trunk Setup

Open up /etc/asterisk/pjsip_wizard.conf with your preferred editor, and edit the following rows:

type = wizard

[telnyx] endpoint/transport =
endpoint/allow = !all,ulaw,alaw,G729,G722
endpoint/rewrite_contact = yes
endpoint/dtmf_mode = rfc4733 ; Most PBXs will also support 2833.
endpoint/context = from-pstn
endpoint/force_rport = yes
aor/qualify_frequency = 60
sends_auth = yes
sends_registrations = yes
remote_hosts =
outbound_auth/username = username
outbound_auth/password = password
registration/expiration = 600

Note: For this configuration to work, the module must be installed and loaded. This is available through Asterisk 13.2.0.

3. Configure Asterisk to Make and Accept Calls

​​You will need to modify extension 1001 in the /etc/asterisk/pjsip_wizard.conf in order to add the global configurations for the extensions, and specific ones for the sample. This will allow Asterisk to make and accept calls.

Parameters that reference 1001 and password can be customized for your requirements and map to the following fields:

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/force_rport = yes
endpoint/dtmf_mode = rfc4733
endpoint/rewrite_contact = yes
aor/max_contacts = 1
aor/remove_existing = yes
aor/minimum_expiration = 30

After creating the template, setting up a new phone is often as simple as setting up a username/password, as the Phone object inherits from the Wizard template. You won't even need to specify a type.

hint_exten = 1001
endpoint/callerid = Bart <1001>
inbound_auth/username = Bart
inbound_auth/password = strong@pass123$

hint_exten = 1001
endpoint/callerid = Lisa <1001>
endpoint/allow = !all,ulaw
inbound_auth/username = Lisa
inbound_auth/password = strong@pass246$
has_phoneprov = yes ; defaults to no
phoneprov/MAC = hereweGOaga1n ;must specify if has_phoneprov=yes
phoneprov/PROFILE = profile1 ;must specify if has_phoneprov=yes

4. Completing the Basic PJSP 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.

Edit the following lines in pjsip.conf for installations behind NAT.


type = global
type = transport
protocol = udp
bind =
local_net = X.X.X.X/24
external_media_address = X.X.X.X
external_signaling_address = X.X.X.X
allow_reload = no

  • In case the PBX is not in a NATed network, you can safely remove the following 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.

5. 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 to send 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. The [from-ptsn] code block 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. The [from-internal] code block 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 completed your Asterisk configuration 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 set up correctly.

Additionally you can check out:

Did this answer your question?