Configuring Asterisk to connect with Zentrunk

Zentrunk is a SIP Trunking service from Plivo that allows you to connect with fixed and mobile phones in over 200 countries. Connect your cloud or on-premise communication infrastructure to Plivo’s Zentrunk SIP Trunking service to connect to your customers easily.

This documentation provides a basic configuration to get Asterisk up and running with Plivo as the external SIP gateway.

To get started with Zentrunk using Asterisk you would need to do the following:

  1. Install Asterisk on your environment.
  2. Create a Trunk on Zentrunk using Plivo Console.
  3. Configure Outbound Gateway on Asterisk to connect to the Trunk created in the previous step.

Installation of Asterisk

For installing Asterisk, follow the instructions below:

  • For Debian systems execute the following commands in the terminal.

    1.

    apt-get update
    

    2.

    apt-get upgrade
    

    3.

    apt-get install asterisk
    
  • Follow the instructions given here to install Asterisk on CentOS.
  • To install Asterisk on Windows, follow the instructions given here

Create a Trunk on Zentrunk

You can create a trunk using Plivo Console. For more information on creating a Trunk on Plivo Console, see Getting Started with Zentrunk.

Configuring your Asterisk

To configure the asterisk to connect to your Plivo Zentrunk, locate the root configuration of Asterisk on your machine. These locations vary from platform to platform.

In this case (Debian Jessie GNU/Linux System), the root configuration is present at /etc/asterisk/.

With the root configuration directory located, there are two major configurations that need to do -

  1. Create a new SIP Channel
  2. Create a Dial Plan.
  3. Reload the configuration

Step 1: Sip Channel

Create a new channel named “plivo-phone” at /etc/asterisk/sip.conf. This channel will be used in X-Lite to connect to asterisk. Also, create another channel called “plivo-trunk” which will connect to your Plivo Trunk.

[plivo-phone]
type=friend
context=Zentrunk
host=dynamic
secret=password1234

[zentrunk]
type=peer
context=Plivo
host=Termination SIP Domain of your Plivo Trunk
secret=Password for TestAuthGroup
username=Username for TestAuthGroup

A “plivo-phone” channel is created with the following attributes.

  • Type=friend - Creates a user and peer connection
  • Context=Zentrunk - Context is the identifier for a dialplan that will be loaded from extensions.conf. The sip.conf identifies and allows connections to the asterisk server. The context in the identifier allows the execution of call flow when a call is received from XLite.
  • Host=dynamic - XLite can be connected from anywhere
  • Secret=password1234 - Password to be used in X-Lite

The “zentrunk” channel is created with the following attributes.

  • Type=peer - Creates a peer connection
  • Context=Plivo - Context is the identifier for a dialplan that will be loaded from extensions.conf. The sip.conf identifies and allows connections to the asterisk server. The context in the identifier allows the execution of call flow when a call is received from XLite.
  • Host=Termination SIP Domain of your Plivo Trunk
  • Secret=Password for TestAuthGroup
  • Username=Username for TestAuthGroup

Step 2: Dialplan

Next, you should set up a Dial Plan. A Dial Plan tells Asterisk what to do when a call has to be placed. The “Content” attribute in the SIP channel connects a channel with a dialplan. Add a dialplan named “Zentrunk” in extensions.conf under /etc/asterisk/directory.

[Zentrunk]
exten => _1XXXX.,1,Set(CALLERID(all)="Your Plivo Number" <Your Plivo Number>)
exten => _1XXXX.,n,Dial(SIP/zentrunk/${EXTEN})
exten => _1XXXX.,n,Hangup()

The above dial plan has defined an extension for a number starting with the digit 1. When a call is made from X-Lite to a number that starts with 1, it hits the asterisk server first. The dialplan that satisfies this pattern matching get loaded, in this case, the above plan. The caller ID is set to your Plivo Number and the SIP INVITE is sent to “Zentrunk” channel which forwards the invite to Plivo Trunk from where the outbound call is placed.

Step 3: Reload Configurations:

  1. Load the asterisk client.
  2. Execute the following command in your terminal:
     asterisk -rvvvv
    
  3. Reload the sip channel, and then execute the following command:
     sip reload
    
  4. Reload the dialplan, and then execute the following command:
     dialplan reload.
    

To configure X-Lite

  1. Download and install X-Lite.
  2. On X-Lite, navigate to Preferences.
  3. On the Accounts tab, click Add Account, and then click New SIP Account.
  4. Enter the User ID and Authorization name. Note: Use the channel name for the User ID and Authorization name from step 1.
  5. In the Domain field, enter the domain of your Asterisk machine.
  6. In the Password field, enter the secret of the channel (password1234 in our setup from step 1).
  7. Uncheck the option “Register with domain and receive calls”.
  8. Once you have configured X-Lite, click OK. Your endpoint entry will be displayed in the Accounts tab. If all configuration details are accurate, the status will show the account as enabled.

image alt text