Virtual PBX Knowledge 27/03/2026

A Guide to Installing and Configuring the Asterisk PBX — What Every IT Professional Needs to Know

Configuring the Asterisk PBX

If you have questions about WebRTC compatibility with a specific version of Asterisk, please direct those questions to the appropriate Asterisk support forums.

Setting Up the Asterisk PBX System

Asterisk and SIP.js have been tested using the following setup:

  • CentOS 7.2 minimal (x86_64)
  • Asterisk 16.9.0
  • OpenSSL 1.0.1e-fips February 11, 2013 or later
  • A public IP address to avoid NAT scenarios on the server side
  • SELinux disabled

Required Packages

Install the following dependencies:

  • wget
  • gcc
  • gcc-c++
  • ncurses-devel
  • libxml2-devel
  • sqlite-devel
  • libsrtp-devel
  • libuuid-devel
  • openssl-devel

Installing Asterisk

cd /usr/local/src/

  1. Download Asterisk with: wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16.9.0.tar.gz
  2. Extract Asterisk: tar zxvf asterisk*
  3. Enter the Asterisk directory: cd /usr/local/src/asterisk*
  4. Run the Asterisk configuration script: ./configure --with-jansson-bundled
  5. Run the Asterisk menuselect tool: make menuselect

In the selection menu, navigate to the resource options and make sure that res_srtp and pjproject are enabled. If there are 3 x’s next to res_srtp, there is a problem with the srtp library and you will need to reinstall it. Save the configuration (press x).

Compile and install Asterisk: make && make install

If you need sample configurations, you can run make samples to install them. If you need to install the Asterisk startup script, you can run make config.

Setting Up DTLS Certificates in Asterisk

A self-signed SSL certificate may be acceptable for development purposes, but it will not work in a production environment. Let’s Encrypt is an excellent way to obtain a free certificate.

Setting Up the Asterisk PBX System

Asterisk and SIP.js have been tested using the following setup:

  • CentOS 7.2 minimal (x86_64)
  • Asterisk 16.9.0
  • OpenSSL 1.0.1e-fips February 11, 2013 or later
  • A public IP address to avoid NAT scenarios on the server side
  • SELinux disabled

Required Packages

Install the following dependencies:

  • wget
  • gcc
  • gcc-c++
  • ncurses-devel
  • libxml2-devel
  • sqlite-devel
  • libsrtp-devel
  • libuuid-devel
  • openssl-devel

Installing Asterisk

cd /usr/local/src/

  1. Download Asterisk with: wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16.9.0.tar.gz
  2. Extract Asterisk: tar zxvf asterisk*
  3. Enter the Asterisk directory: cd /usr/local/src/asterisk*
  4. Run the Asterisk configuration script: ./configure --with-jansson-bundled
  5. Run the Asterisk menuselect tool: make menuselect

In the selection menu, navigate to the resource options and make sure that res_srtp and pjproject are enabled. If there are 3 x’s next to res_srtp, there is a problem with the srtp library and you will need to reinstall it. Save the configuration (press x).

Compile and install Asterisk: make && make install

If you need sample configurations, you can run make samples to install them. If you need to install the Asterisk startup script, you can run make config.


Setting Up DTLS Certificates in Asterisk

A self-signed SSL certificate may be acceptable for development purposes, but it will not work in a production environment. Let’s Encrypt is an excellent way to obtain a free certificate.

Giấy chứng nhận tự ký mkdir /etc/asterisk/keys Nhập thư mục Asterisk scripts : cd /usr/local/src/asterisk*/contrib/scripts. Tạo chứng chỉ DTLS (thay thế pbx.mycompany.com bằng địa chỉ IP hoặc tên dns của bạn, thay thế My Super Company bằng tên công ty của bạn) : ./ast_tls_cert -C pbx.mycompany.com -O “My Super Company” -d /etc/asterisk/keys. Cấu hình Asterisk cho WebRTC Đối với WebRTC, rất nhiều cài đặt cần thiết PHẢI nằm trong cài đặt ngang hàng . Các thiết lập toàn cầu không chảy xuống các cài đặt ngang hàng rất tốt. Theo mặc định, tập tin cấu hình Asterisk được đặt trong /etc/asterisk/. Bắt đầu bằng cách chỉnh sửa http.confvà đảm bảo rằng các dòng sau không bị lỗi: ;http.conf[general]enabled=yesbindaddr=127.0.0.1 ; Replace this with your IP addressbindport=8088 ; Replace this with the port you want to listen ontlsenable=yestlsbindaddr=127.0.0.1:8089 ; Replace this with your IP addresstlscertfile=/etc/asterisk/keys/asterisk.pem Thay đổi địa chỉ IP và cổng thành địa chỉ IP của máy chủ của bạn và cổng mà bạn muốn Asterisk lắng nghe các kết nối ổ cắm web trên đó. Tiếp theo, chỉnh sửa sip.conf. Tại đây, bạn sẽ thiết lập hai máy ngang hàng, một cho máy khách WebRTC và một cho máy khách SIP không phải WebRTC. WebRTC ngang hàng yêu cầu mã hóa, avpf và icesupport để được bật. Trong hầu hết các trường hợp, directmedia nên bị vô hiệu hóa. Cũng trong ứng dụng khách WebRTC, việc vận chuyển cần được liệt kê là ‘ws’ để cho phép kết nối websocket. Tất cả các dòng cấu hình này phải nằm dưới chính nó; thiết lập các dòng cấu hình này trên toàn cầu có thể không hoạt động. ;sip.conf[general]realm=127.0.0.1 ; Replace this with your IP addressudpbindaddr=127.0.0.1 ; Replace this with your IP addresstransport=udp[1060] ; This will be WebRTC clienttype=friendusername=1060 ; The Auth user for SIP.jshost=dynamic ; Allows any host to registersecret=password ; The SIP Password for SIP.jsencryption=yes ; Tell Asterisk to use encryption for this peeravpf=yes ; Tell Asterisk to use AVPF for this peericesupport=yes ; Tell Asterisk to use ICE for this peercontext=default ; Tell Asterisk which context to use when this peer is dialingdirectmedia=no ; Asterisk will relay media for this peertransport=udp,ws,wss ; Asterisk will allow this peer to register on UDP or WebSocketsforce_avp=yes ; Force Asterisk to use avp. Introduced in Asterisk 11.11dtlsenable=yes ; Tell Asterisk to enable DTLS for this peerdtlsverify=fingerprint ; Tell Asterisk to verify DTLS fingerprintdtlscertfile=/etc/asterisk/keys/asterisk.pem ; Tell Asterisk where your DTLS cert file isdtlssetup=actpass ; Tell Asterisk to use actpass SDP parameter when setting up DTLSrtcp_mux=yes ; Tell Asterisk to do RTCP mux[1061] ; This will be the legacy SIP clienttype=friendusername=1061host=dynamicsecret=passwordcontext=default Cuối cùng, thiết lập extensions.confđể cho phép hai đồng nghiệp gọi nhau. ;extensions.conf

[default]

exten => 1060,1,Dial(SIP/1060) ; Dialing 1060 will call the SIP client registered to 1060 exten => 1061,1,Dial(SIP/1061) ; Dialing 1061 will call the SIP client registered to 1061 Khởi động lại Asterisk bằng cách sử dụng service asterisk restartđể đảm bảo rằng các cài đặt mới có hiệu lực. Xử lý sự cố trong Asterisk Bài đăng trên diễn đàn về khắc phục sự cố WebRTC là một hướng dẫn tuyệt vời cho các sự cố khi chụp với Asterisk. Hướng dẫn gọi an toàn Asterisk có thể giúp bạn thiết lập chứng chỉ dtls. Nguồn sipjs.com Hãy liên hệ với chúng tôi để chúng tôi giúp doanh nghiệp bạn KHẲNG ĐỊNH ĐẲNG CẤP KINH DOANH khi lựa chọn tổng đài ảo cho doanh nghiệp mình. Quý khách có nhu cầu tổng đài Ảo xin liên hệ:Show more

3:02 PM

Here is the English translation:

Self-Signed Certificate

mkdir /etc/asterisk/keys

  1. Enter the Asterisk scripts directory: cd /usr/local/src/asterisk*/contrib/scripts
  2. Generate the DTLS certificate (replace pbx.mycompany.com with your IP address or DNS name, and replace My Super Company with your company name): ./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys

Configuring Asterisk for WebRTC

For WebRTC, many required settings MUST be placed in the peer settings. Global settings do not flow down to peer settings very well. By default, Asterisk configuration files are located in /etc/asterisk/. Start by editing http.conf and ensuring the following lines are correct:

;http.conf
[general]
enabled=yes
bindaddr=127.0.0.1        ; Replace this with your IP address
bindport=8088             ; Replace this with the port you want to listen on
tlsenable=yes
tlsbindaddr=127.0.0.1:8089  ; Replace this with your IP address
tlscertfile=/etc/asterisk/keys/asterisk.pem

Change the IP address and port to your server’s IP address and the port on which you want Asterisk to listen for WebSocket connections.

Next, edit sip.conf. Here you will set up two peers — one for the WebRTC client and one for the non-WebRTC SIP client. The WebRTC peer requires encryption, avpf, and icesupport to be enabled. In most cases, directmedia should be disabled. Also, for the WebRTC client, the transport needs to be listed as ws to allow WebSocket connections. All of these configuration lines must be placed under the peer itself; setting these globally may not work.

;sip.conf
[general]
realm=127.0.0.1           ; Replace this with your IP address
udpbindaddr=127.0.0.1     ; Replace this with your IP address
transport=udp

[1060]                    ; This will be the WebRTC client
type=friend
username=1060             ; The Auth user for SIP.js
host=dynamic              ; Allows any host to register
secret=password           ; The SIP Password for SIP.js
encryption=yes            ; Tell Asterisk to use encryption for this peer
avpf=yes                  ; Tell Asterisk to use AVPF for this peer
icesupport=yes            ; Tell Asterisk to use ICE for this peer
context=default           ; Tell Asterisk which context to use when this peer is dialing
directmedia=no            ; Asterisk will relay media for this peer
transport=udp,ws,wss      ; Asterisk will allow this peer to register on UDP or WebSockets
force_avp=yes             ; Force Asterisk to use avp. Introduced in Asterisk 11.11
dtlsenable=yes            ; Tell Asterisk to enable DTLS for this peer
dtlsverify=fingerprint    ; Tell Asterisk to verify DTLS fingerprint
dtlscertfile=/etc/asterisk/keys/asterisk.pem  ; Tell Asterisk where your DTLS cert file is
dtlssetup=actpass         ; Tell Asterisk to use actpass SDP parameter when setting up DTLS
rtcp_mux=yes              ; Tell Asterisk to do RTCP mux

[1061]                    ; This will be the legacy SIP client
type=friend
username=1061
host=dynamic
secret=password
context=default

Finally, set up extensions.conf to allow the two peers to call each other:

;extensions.conf
[default]
exten => 1060,1,Dial(SIP/1060)  ; Dialing 1060 will call the SIP client registered to 1060
exten => 1061,1,Dial(SIP/1061)  ; Dialing 1061 will call the SIP client registered to 1061

Restart Asterisk using service asterisk restart to ensure the new settings take effect.

Troubleshooting Asterisk

The forum post on WebRTC troubleshooting is an excellent guide for issues encountered when working with Asterisk.

The Asterisk Secure Calling Guide can help you set up DTLS certificates.

Source: sipjs.com

Contact us today and let us help your business ASSERT ITS CLASS when choosing the right virtual PBX solution.

For inquiries about our Virtual PBX service, please contact us:

VIHAT TECHNOLOGY Co., Ltd

Headquarters: ViHAT Building – 06 Street No. 16 (Him Lam Residential Area) – Hiep Binh Chanh Ward – Thu Duc District – Ho Chi Minh City

Hanoi Branch: Floor 15, LADECO Building, 266 Doi Can, Ba Dinh, Hanoi

Cambodia Branch: Thida Rath #154 St. 33MC, Sangkat Steung Meanchey, Khan Mean Chey, Phnom Penh

Author admin