Blogs on System Administration, Scripting, System Monitoring, Cloud Computing & Virtualizaton, VoIP Systems, SMS Systems and Web Applications Development.

How to install Asterisk 13 with WebRTC support in CentOS?


Introduction

This article is a guide to install Asterisk 13.10.0 with WebRTC Support in CentOS.

Description

I have gone through many articles to enable WebRTC support in Asterisk 11 and Asterisk 12 but I faced a alot of issues for WebRTC calling including No Audio, abrupt closing of web sockets etc. But I find Asterisk 13 more stable for WebRTC.

Methodology

Following is the step by step guide for installing Asterisk 13 with WebRTC Support.

Step # 1

First of install some of the dependencies of the Asterisk and WebRTC:
Installing dependencies with yum.
$ sudo yum update
$ sudo yum groupinstall "Development tools" -y
$ sudo yum install wget gcc gcc-c++ ncurses-devel libxml2-devel sqlite-devel libuuid-devel openssl-devel
$ sudo yum install gcc-c++ make gnutls-devel kernel-devel subversion doxygen texinfo curl-devel net-snmp-devel neon-devel
$ sudo yum install uuid-devel libuuid-devel sqlite-devel sqlite git speex-devel gsm-devel 
Install Secure RTP library from source:
$ cd /usr/src/
$ sudo wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
$ sudo tar zxvf srtp-1.4.2.tgz
$ cd srtp*
$ sudo autoconf
$ sudo make && make install
$ cp /usr/local/lib/libsrtp.a /lib
Install jansson library from source:
$ cd /usr/src
$ sudo wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz\
$ sudo tar zxvf jansson-2.5.tar.gz
$ cd jansson-2.5
$ sudo ./configure --prefix=/
$ sudo make && make install
Install latest PjSIP libraries from source:
$ cd /usr/src
$ sudo git clone https://github.com/asterisk/pjproject
$ cd pjproject
$ sudo ./configure CFLAGS="-DNDEBUG -DPJ_HAS_IPV6=1" --prefix=/usr --libdir=/usr/lib64 --enable-shared --disable-video --disable-sound --disable-opencore-amr
$ sudo make dep
$ sudo make
$ sudo  make install
$ sudo ldconfig
Verifying PjSIP libraries:
$ sudo ldconfig -p | grep pj

Step # 2

Now we are going to install Asterisk 13 from source:
$ sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
$ sudo tar -zxvf asterisk-13-current.tar.gz
$ cd asterisk-13*
$ sudo make clean
$ sudo ./configure --with-crypto --with-ssl --with-srtp=/usr/local/lib --with-jansson=/
$ sudo contrib/scripts/get_mp3_source.sh
# Make sure that all required modules and resources i.e. res_pjsip are enabled.
$ sudo make menuselect
$ sudo make && make install
$ sudo make samples
$ sudo make config
$ sudo chkconfig asterisk on

Step # 3

Now we are going to generate TLS certificates for secure socket connections in asterisk.
$ sudo mkdir /etc/asterisk/keys
$ cd /usr/src/asterisk-13*
$ cd contrib/scripts
# Add IP Address of Server at X.X.X.X
$ sudo ./ast_tls_cert -C X.X.X.X -O "My Test Company" -d /etc/asterisk/keys

Step # 4

Now we have to configure Asterisk to run with WebRTC support:

Edit rtp.conf file with following code:
;rtp.conf
[general]
rtpstart=10000
rtpend=20000
icesupport=yes
stunaddr=stun.l.google.com:19302

Edit res_stun_monitor.conf file with following code:
;res_stun_monitor.conf
[general]
stunaddr=stun.l.google.com:19302
stunrefresh = 30

Edit http.conf file with following code:
;http.conf
[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
tlsenable=yes
tlsbindaddr=0.0.0.0:7443
tlscertfile=/etc/asterisk/keys/asterisk.pem
tlsprivatekey=/etc/asterisk/keys/asterisk.pem
Edit sip.conf file with following code:
;sip.conf
[general]
udpbindaddr = 0.0.0.0:5060
realm = X.X.X.X ; replace with your Server's Public IP Address
transport = udp,ws,wss
externaddr = X.X.X.X ; replace with your Server's Public IP Address
websocket_enabled = true
[1000]
host=dynamic
secret=12345
context=from-internal
type=friend
encryption=yes
avpf=yes
;force_avp=yes
icesupport=yes
directmedia=no
disallow=all
dial = SIP/1000
disallow=all
allow=ulaw
allow=alaw
allow=speex
allow=gsm
dtlsenable=yes
dtlsverify=fingerprint
dtlscertfile=/etc/asterisk/keys/asterisk.pem
dtlscafile=/etc/asterisk/keys/ca.crt
dtlssetup=actpass
nat=force_rport,comedia
[2000]
host=dynamic
secret=12345
context=from-internal
type=friend
encryption=yes
avpf=yes
;force_avp=yes
icesupport=yes
directmedia=no
disallow=all
dial = SIP/2000
disallow=all
allow=ulaw
allow=alaw
allow=speex
allow=gsm
dtlsenable=yes
dtlsverify=fingerprint
dtlscertfile=/etc/asterisk/keys/asterisk.pem
dtlscafile=/etc/asterisk/keys/ca.crt
dtlssetup=actpass
nat=force_rport,comedia
Edit extensions.conf file with following code:
;extensions.conf
[from-internal]
; For Testing Audio
exten => 1111,1,Answer()
same => n,Playback(demo-thanks)
same => n,Hangup()
; For testing SIP to SIP calling
exten => _X.,1,Dial(SIP/${EXTEN})
exten => _X.,n,Hangup()

Step # 5

So far, we have added all important configurations in Asterisk.
Now we are going to start Asterisk:

$ sudo service asterisk start
Starting asterisk:
$ sudo netstat -pln | grep asterisk                                                                                                                             
tcp        0      0 0.0.0.0:2000                0.0.0.0:*                   LISTEN      21012/asterisk                                                                                    
tcp        0      0 0.0.0.0:7443                0.0.0.0:*                   LISTEN      21012/asterisk                                                                                    
tcp        0      0 0.0.0.0:8088                0.0.0.0:*                   LISTEN      21012/asterisk                                                                                    
udp        0      0 0.0.0.0:4569                0.0.0.0:*                               21012/asterisk                                                                                    
udp        0      0 0.0.0.0:5000                0.0.0.0:*                               21012/asterisk                                                                                    
udp        0      0 0.0.0.0:2727                0.0.0.0:*                               21012/asterisk                                                                                    
udp        0      0 0.0.0.0:4520                0.0.0.0:*                               21012/asterisk                                                                                    
udp        0      0 0.0.0.0:57769               0.0.0.0:*                               21012/asterisk                                                                                    
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               21012/asterisk                                                                                    
unix  2      [ ACC ]     STREAM     LISTENING     94199  21012/asterisk      /var/run/asterisk/asterisk.ctl
$ sudo asterisk -vvvvr                                                                                                                                              
Asterisk 13.10.0, Copyright (C) 1999 - 2014, Digium, Inc. and others.                                                                                                                     
Created by Mark Spencer <markster@digium.com>                                                                                                                                             
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.                                                                                                        
This is free software, with components licensed under the GNU General Public                                                                                                              
License version 2 and other licenses; you are welcome to redistribute it under                                                                                                            
certain conditions. Type 'core show license' for details.                                                                                                                                 
=========================================================================                                                                                                                 
Connected to Asterisk 13.10.0 currently running on Asterisk-13 (pid = 21012)    
Asterisk-13*CLI> http show status                                                                                                                                                  
HTTP Server Status:                                                                                                                                                                       
Prefix:                                                                                                                                                                                   
Server: Asterisk/13.10.0                                                                                                                                                                  
Server Enabled and Bound to 0.0.0.0:8088                                                                                                                                                  
                                                                                                                                                                                            
HTTPS Server Enabled and Bound to 0.0.0.0:7443                                                                                                                                            
                                                                                                                                                                                            
Enabled URI's:                                                                                                                                                                            
/httpstatus => Asterisk HTTP General Status                                                                                                                                               
/phoneprov/... => Asterisk HTTP Phone Provisioning Tool                                                                                                                                   
/static/... => Asterisk HTTP Static Delivery                                                                                                                                              
/ari/... => Asterisk RESTful API                                                                                                                                                          
/ws => Asterisk HTTP WebSocket                                                                                                                                                            
                                                                                                                                                                                            
Enabled Redirects:                                                                                                                                                                        
  None.                  
                                                                                                    
Asterisk-13*CLI> sip show peers
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                                                          
1000                      (Unspecified)                            D  Yes        Yes            0        Unmonitored                                                                      
2000                      (Unspecified)                            D  Yes        Yes            0        Unmonitored                                                                      
2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 2 offline]    

It shows that Asterisk is running smoothly.

Step # 6

Now we are going to configure Web SIP Phone for calling:
First of all open below link in your browser and add exception for your Server’s IP (replace X.X.X.X with your Server’s IP) in your browser:

https://X.X.X.X:7443/httpstatus
After successfully adding exception for your Server’s IP Address, you’ll see below page:


We are using sipml5 for testing and below are its configurations:
Open following URL to add your WebRTC and Server’s Information and then press the save button:
SIPML5 Expert Mode
Now open below link to add your Extension Information and press login button to register your extension:

SIPML5 Phone Configurations


Step # 7

You can dial 1111 Extension which will Playback demo-thanks sound.
If you have registered 1000 and 2000 Extensions on two machines then you can dial each other to test SIP to SIP calling.
If your are concerned about the security of your SIP Server then you can following this Blog to secure your Asterisk Server.

2 comments:

  1. We live in a technological age where even teenagers have mobile phones at school; they seem to have them permanently fixed to their hands. If you take the phones away from them they struggle to survive the day without being able to text in their weird language or abbreviations and smileys. You can also communicate with your clients through text to landline free service from online websites.

    ReplyDelete

Please Enter your Comments Here.