
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
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.
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:1234@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:1234@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
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:
2. One way audio issue in Asterisk - https://e2ehiring.com/blogs/one%20way%20audio%20issue%20in%20asterisk-232