Installing and Configuring Asterisk CLI

Asterisk is a software implementation of a telephone private branch exchange (PBX); it was created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the Public Switched Telephone Network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, *.

Here I am going to show you the most basic configuration of Asterisk to give you a clear picture of what and How Asterisk works

Download Asterisk from their Official website

Download Asterisk all versions

# wget
# tar -xzf asterisk-1.8-current.tar.gz
# cd asterisk-

NOTE: Make sure you have gcc compiler pre installed in your system before moving towards next step

# ./configure
.$7$7..          .7$$7:.
.$$:.                 ,$7.7
.$7.     7$$$$           .$$77
..$$.       $$$$$            .$$$7
..7$   .?.   $$$$$   .?.       7$$$.
$.$.   .$$$7. $$$$7 .7$$$.      .$$$.
.777.   .$$$$$$77$$$77$$$$$7.      $$$,
$$$~      .7$$$$$$$$$$$$$7.       .$$$.
.$$7          .7$$$$$$$7:          ?$$$.
$$$          ?7$$$$$$$$$$I        .$$$7
$$$       .7$$$$$$$$$$$$$$$$      :$$$.
$$$       $$$$$$7$$$$$$$$$$$$    .$$$.
$$$        $$$   7$$$7  .$$$    .$$$.
$$$$             $$$$7         .$$$.
7$$$7            7$$$$        7$$$
$$$$$                        $$$
$$$$7.                       $$  (TM)
$$$$$$$.           .7$$$$$$  $$
configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : i686
configure: build-cpu:vendor:os: i686 : pc : linux-gnu :
configure: host-cpu:vendor:os: i686 : pc : linux-gnu :

Once the configure step is completed successfully you will see the above output on the screen

# make
# make install
# make samples

Once all the above steps are completed successfully it is time to start the asterisk services

# asterisk -vvvc
Asterisk Ready.

Now let us configure some local extensions to verify extension-extension calling

*CLI> !

Using ! (exclamation mark) will take you out of the asterisk CLI prompt but the service will be running in the background)

Configuring Asterisk SIP Account

Navigate inside /etc/asterisk

# cd /etc/asterisk

Take a backup of the original sip file and create a new one with the following details

# mv sip.conf sip.conf.orig
# vi sip.conf

Now let me explain you the above used syntax

  • port - This is the port number which Asterisk uses to communicate
  • bindaddr - All the client IP range the server will listen to
  • type - type of connection (peer — outcoming calls only, user — incoming calls, friend — both incoming and outcoming calls)
  • host - Hostname of the phone (Dynamic Host name)
  • secret - Passsword used for authentication user


Configuring Extension Dial Plan

# mv extensions.conf extesnions.conf.orig
# vi extensions.conf
exten => 1000,1,Dial(SIP/1000,10)
exten => 1001,1,Dial(SIP/1001,10)

The above shown dial plan is one of the most basic which means that is a user dials 1000 from his extension using SIP Phone it will go to 1000 Extension and if the phone is not picked up till 10 seconds then the call will hangup. The same will happen for extension 1001
Now we are done with the initial configuration of Asterisk to verify internal calls. Restart the asterisk services
To connect to asterisk CLI

# asterisk -r

This will reload all the configuration files of asterisk

Configure softphones

Let us configure two softphones for verifying the calls
For this demo purpose I will be using X-Lite and QuteCom
You can download the same from the following locations
Download X-Lite
Download QuteCom
Once the software are downloaded and installed follow the below screenshots to configure your softphone

Configuring Extension 1000 on QuteCom

Use your server IP at the place for SIP Domain For example: 192.168.0.xx

Configuring Extension 1001 on X-Lite

Now when both the Softphones are configure try to make calls between each other
Calling from 1001 to 1000

So you can pick the call on the other side and start talking.
Now this was the most basic configuration of Asterisk but it can get very vast and complex moving more and more ahead.