E2EHIRING Logo
Jobs
Jobs
courses
Courses
mentorship
Mentorship
more
Moredropdown
E2EHIRING Logo
more
Jobs
Jobs
courses
Courses
mentorship
Mentorship
HomeSepratorIconBlogsSepratorIconAsterisk Server SetupSepratorIcon

Asterisk Server Setup

Han SoloVigneswaran Sekar
calendar6 Jul 2022
poster

What is 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. 

System Requirements

  1. Server with Linux OS
  2. 80,443,8089 Ports should be accessible.
  3. Sudo access  should be enabled for the user.
  4. Read and Write access for /etc folder.
  5. Internet access for downloading required packages.
  6. Registered Domain Name with installed TLS(“Let’s Encrypt”) certificate.
  7. SIP account to make the outbound calls.

Asterisk Installation

1. Download the source code from asterisk website (Asterisk v17.4)

       sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17.4.0.tar.gz

2. Extract the source code.

         sudo tar zxf asterisk-17.4.0.tar.gz

         Open Asterisk folder -   cd /etc/asterisk

3. Install asterisk by executing the following command.

  • sudo contrib/scripts/install_prereq install
  • ./configure
  • make menuconfig
  • make menuselect
  • make
  • make install
  • sudo make samples
  • make config

File Configurations

1. Add the TLS certificate files path in http.conf

Example:

[general]

enabled=yes

bindaddr=0.0.0.0

bindport=8088

tlsenable=yes

tlsbindaddr=0.0.0.0:8089

tlscertfile=/etc/letsencrypt/live/dialer.bython.co.in/ fullchain.pem

tlsprivatekey=/etc/letsencrypt/live/dialer.bython.co.in/privkey.pem

2. Add the Dialplan in extensions.conf

Example:

[default]

exten => _X.,1,Set(callid=${PJSIP_HEADER(read,call-id)})

same =>n,MixMonitor(/var/www/html/recordings/${STRFTIME(${EPOCH},,%Y%m%d)}/out-${EXTEN}-${callid}.wav,b) //MixMonitor with path for storing recordings (recordings/20200804/out-919080424020-3450ddb5-ffbd-d330-83f2-a14269c0ac39.wav).

same =>n,Dial(PJSIP/${EXTEN}@provider) 

MixMonitor - It's a asterisk module to store the call recordings.

3. Create the Endpoints with Sip provider registrations in pjsip.conf

Example:

//define websocket

[transport-wss]

type=transport

protocol=wss

bind=0.0.0.0

local_net=192.0.2.0/24

local_net=127.0.0.1/32

external_media_address=172.19.2.000

external_signaling_address=172.19.2.000

 

[webrtc_client]

type=aor

max_contacts=5

remove_existing=yes

    

[webrtc_client]

type=auth

auth_type=userpass

username=webrtc_client

password=webrtc_client 

 

[webrtc_client]

type=endpoint

aors=webrtc_client

auth=webrtc_client

dtls_auto_generate_cert=yes

webrtc=yes

rtp_symmetric=yes

rewrite_contact=yes  

rtp_symmetric = yes

ice_support=yes

force_rport=yes

direct_media=no

context=default

rtp_keepalive=1

disallow=all

allow=ulaw

 

[transport-udp-nat]

type=transport

protocol=udp

bind=0.0.0.0

local_net=192.0.2.0/24

local_net=127.0.0.1/32

external_media_address=172.19.2.000 

external_signaling_address=172.19.2.000 

//Register sip provider

[provider]

type=registration

outbound_auth=provider

endpoint=provider

server_uri=sip:172.19.2.000 

client_uri=sip:[email protected]172.19.2.000 

contact_user =91920423443  //Caller ID

auth_rejection_permanent = no

retry_interval = 30

forbidden_retry_interval = 300 

max_retries = 20 

line=yes 

[provider]

type=auth

auth_type=userpass

password=ck5xs3qegslw

username=1234

[provider]

type=aor

contact=sip:[email protected]172.19.2.000

 

//define Endpoint

[provider]

type=endpoint

disallow=all

allow=opus,ulaw,gsm,alaw,h263,h264 

from_user=23422545  //Caller ID

callerid = Office <1000>

outbound_auth=provider 

aors=provider

direct_media=no

outbound_auth=provider 

[provider]

type=identify

endpoint=provider

match=172.19.2.000 

 

4. Enable logs which we can display in asterisk console. logger.conf

Example:

console => notice,warning,error

messages => notice,warning,error

Run Asterisk

  • Login as root user.
  • sudo asterisk –r  (or) asterisk –c
  • By running the above command Asterisk will be started and you can see the Asterisk console.

Asterisk CLI Commands

1. Restart the asterisk

 CLI> core restart now

2.Stop the asterisk

CLI> core stop now

3. Reload Endpoints. If you did any changes in pjsip.conf

CLI> module reload res_pjsip.so

4. Reload dialplan. If you did any changes in extensions.conf

CLI> reload dialplan

5. Restart the asterisk if any changes in http.conf

CLI> core restart now.

6. Make the Extension or Outbound calls

Dial <phone no/Ext no>      // This command will be work based on our Dialplan configurations.


Posts related to Asterisk:

1. How to make the phone calls from your own application using JS and Asterisk  -  https://e2ehiring.com/blogs/how%20to%20make%20the%20phone%20calls%20from%20your%20own%20application%20using%20js-619

2. One way audio issue in Asterisk  - https://e2ehiring.com/blogs/one%20way%20audio%20issue%20in%20asterisk-232



Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML

copycopycopycopy

Han Solo

Recent Posts

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

Rapid Changes in the Coding World: Need for High Skilled Programmers e2eHiring Bridges this Gap with the Mentorship Program April 2023

How to publish your Android app on Google Play Store

How to publish your Android app on Google Play Store

Creating Dynamic User Interfaces with Android Motion Layout

Creating Dynamic User Interfaces with Android Motion Layout

Bean Life Cycle

Bean Life Cycle

Pom.XML

Pom.XML