Skip to main content

Asterisk

This FAQ page collects operational notes for Asterisk.

How can I setup Asterisk to use TLS

Asterisk can use TLS as transport for the signalling, increasing the authentication security and providing extra privacy about the number dialed and other info usually transmitted in clear over the SIP channel. TLS will encrypt only the signalling part, without offering any extra security to the RTP (voice) part. In the [general] section of sip.conf, add the following info, replacing the IP address with the IP address of the server. Provide the certificate and key in pem format.

tlsenable=yes 
tlsbindaddr=213.133.102.85 
tlscertfile=/etc/asterisk/certificates/demo.mirtapbx.com.pem 
tlsdontverifyserver=no 
tlscipher=DES-­CBC3-­SHA 
tlsclientmethod=tlsv1 
transport=udp,tls

Optionally you can add a port number to tlsbindaddr parameter

Don't forget to set asterisk to listen on tcp:

tcpenable=yes

Optionally you can provide a separate certificate and key

tlscertfile=/etc/ssl/demo.mirtapbx.com.crt
tlsprivatekey=/etc/ssl/demo.mirtapbx.com.key

I think my Asterisk is locked... how can I check it?

If you think your asterisk is locked, probably it is. To be 100% sure, just run the following command and check the result:

This is a locked asterisk

# netstat -nap | grep 5060
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      26090/asterisk      
udp   213504      0 0.0.0.0:5060                0.0.0.0:*                               26090/asterisk

This is a normal asterisk

# netstat -nap | grep 5060
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      4127/asterisk       
udp        0      0 0.0.0.0:5060                0.0.0.0:*                               4127/asterisk

When asterisk locks up, it stops processing SIP packets, so the UDP buffer fills up. In this case an asterisk restart is needed.

How can I enable TCP for SIP (port 5060)?

You need to add the following rows to /etc/asterisk/sip.conf and then reload the SIP module (when you have no traffic)

tcpenable=yes
tcpbindaddr=0.0.0.0

How can I configure Asterisk to listen to multiple ports?

You can't, it is not possible to configure Asterisk to listen to multiple ports. However, you can use an iptables REDIRECT to get the same result.

To redirect a single port with iptables:

iptables -t nat -A PREROUTING -i eth0 -p udp --dport 5090 -j REDIRECT --to-ports 5060

This example redirects UPD port 5090 to port 5060, so you can connect to Asterisk on both of them.

Remember to add this command to any init script, like /etc/rc.local

BLF monitoring is not working!

One of the common pitfall about BLF is to monitor just the extension number and not the "username" as required. So if you are in the tenant "DEMO" and you want to monitor extension 100 with username "100-DEMO", you need to monitor 100-DEMO and not just 100.

What is HANGUP_CAUSE XX?

You can check this piece of code:

#define AST_CAUSE_UNALLOCATED 1
#define AST_CAUSE_NO_ROUTE_TRANSIT_NET 2
#define AST_CAUSE_NO_ROUTE_DESTINATION 3
#define AST_CAUSE_MISDIALLED_TRUNK_PREFIX 5
#define AST_CAUSE_CHANNEL_UNACCEPTABLE 6
#define AST_CAUSE_CALL_AWARDED_DELIVERED 7
#define AST_CAUSE_PRE_EMPTED 8
#define AST_CAUSE_NUMBER_PORTED_NOT_HERE 14
#define AST_CAUSE_NORMAL_CLEARING 16
#define AST_CAUSE_USER_BUSY 17
#define AST_CAUSE_NO_USER_RESPONSE 18
#define AST_CAUSE_NO_ANSWER 19
#define AST_CAUSE_SUBSCRIBER_ABSENT 20
#define AST_CAUSE_CALL_REJECTED 21
#define AST_CAUSE_NUMBER_CHANGED 22
#define AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION 23
#define AST_CAUSE_ANSWERED_ELSEWHERE 26
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER 27
#define AST_CAUSE_INVALID_NUMBER_FORMAT 28
#define AST_CAUSE_FACILITY_REJECTED 29
#define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30
#define AST_CAUSE_NORMAL_UNSPECIFIED 31
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION 34
#define AST_CAUSE_NETWORK_OUT_OF_ORDER 38
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE 41
#define AST_CAUSE_SWITCH_CONGESTION 42
#define AST_CAUSE_ACCESS_INFO_DISCARDED 43
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL 44
#define AST_CAUSE_FACILITY_NOT_SUBSCRIBED 50
#define AST_CAUSE_OUTGOING_CALL_BARRED 52
#define AST_CAUSE_INCOMING_CALL_BARRED 54
#define AST_CAUSE_BEARERCAPABILITY_NOTAUTH 57
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL 58
#define AST_CAUSE_BEARERCAPABILITY_NOTIMPL 65
#define AST_CAUSE_CHAN_NOT_IMPLEMENTED 66
#define AST_CAUSE_FACILITY_NOT_IMPLEMENTED 69
#define AST_CAUSE_INVALID_CALL_REFERENCE 81
#define AST_CAUSE_INCOMPATIBLE_DESTINATION 88
#define AST_CAUSE_INVALID_MSG_UNSPECIFIED 95
#define AST_CAUSE_MANDATORY_IE_MISSING 96
#define AST_CAUSE_MESSAGE_TYPE_NONEXIST 97
#define AST_CAUSE_WRONG_MESSAGE 98
#define AST_CAUSE_IE_NONEXIST 99
#define AST_CAUSE_INVALID_IE_CONTENTS 100
#define AST_CAUSE_WRONG_CALL_STATE 101
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102
#define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR 103
#define AST_CAUSE_PROTOCOL_ERROR 111
#define AST_CAUSE_INTERWORKING 127
#define AST_CAUSE_BUSY AST_CAUSE_USER_BUSY
#define AST_CAUSE_FAILURE AST_CAUSE_NETWORK_OUT_OF_ORDER
#define AST_CAUSE_NORMAL AST_CAUSE_NORMAL_CLEARING
#define AST_CAUSE_NOANSWER AST_CAUSE_NO_ANSWER
#define AST_CAUSE_CONGESTION AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
#define AST_CAUSE_UNREGISTERED AST_CAUSE_SUBSCRIBER_ABSENT
#define AST_CAUSE_NOTDEFINED 0
#define AST_CAUSE_NOSUCHDRIVER AST_CAUSE_CHAN_NOT_IMPLEMENTED

When I change the name of an extension or any properties requiring an extension reload, the extension goes offline after few minutes

Asterisk caches the info for the extension, so when updating the extension, it is pruned and reloaded. It is automatically reloaded with an expire time of 120 seconds. If you have an expire time longer, it will go offline. You can avoid this by setting a longer default expiration time using the following parameter in sip.conf

rtautoclear=3600

Calls are dropping after around 30 seconds when using PJSIP

Some softphones sends INFO packets to the pbx and if you have not activated "TrustRPID", the pbx will not answer and the softphone may hangup the call

Asterisk is not using the correct audio file

When using audio translations, even if placed correctly in /var/lib/asterisk/sounds/<your language code> is always possible asterisk will choose to use the english version because in the "best" format. In this case, it can be good to convert all audio files in multiple formats. Let's make the example to have all audio files for da_DK language in "wav" format, while asterisk is picking up the "ulaw" english version. We can easily convert them using:

cd /var/lib/asterisk/sounds/da_DK

for i in `ls *.wav`; do asterisk -x "file convert /var/lib/asterisk/sounds/da_DK/$i /var/lib/asterisk/sounds/da_DK/`basename $i .wav`.ulaw"; done

Asterisk is not reporting the PAUSE event when a phone is auto paused

The name of the event changed from asterisk 13.x to asterisk 16.x and your manager.conf may be still using the old event name. Please check and fix:

eventfilter=Event: QueueMemberPause

My provider uses DNS SRV entry, how should I configure it?

Configure it as a normal entry, but leave the port to zero. That will force a DNS SRV resolution

How to configure TOS and COS for PJSIP?

The configuration of TOS and COS for PJSIP is separated between the realtime extension and the transport. You can check the PJSIP extension security section and insert the following values:

TOS Audio: ef

TOS Video: af41

COS Audio: 5

COS Video: 4

You can also edit pjsip.conf and enter the following values for each type of transport:

tos=ef

cos=5

I am getting an error in WebRTC client about digest

It can be worth trying to enable the dtls in sip.conf, disable the SSL Cert in Admin/Settings and set the Auto DTLS in the ps_endpoint configuration for PJSIP

Asterisk is using lots of CPU, which module/thread is using it?

Start by getting the list of threads run by asterisk with the CPU

ps -L -p $(pidof asterisk) -o pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

Identify the thread with the higher CPU and search it in the thread list

asterisk -rx 'core show threads' | grep <TID>

Asterisk service can't be found

Add the asterisk.service to /etc/systemd/system/asterisk.service

[Unit]

Description=Asterisk PBX and telephony daemon.

After=network.target

#include these if asterisk need to bind to a specific IP (other than 0.0.0.0)

#Wants=network-online.target

#After=network-online.target network.target

[Service]

Type=simple

Environment=HOME=/var/lib/asterisk

#if systemd do not provide hostname and you need to use ${ENV(HOSTNAME)}

#Environment=HOSTNAME=%H

WorkingDirectory=/var/lib/asterisk

ExecStart=/usr/sbin/asterisk -f -vvv

ExecStop=/usr/sbin/asterisk -rx 'core stop now'

ExecReload=/usr/sbin/asterisk -rx 'core reload'

#if /var/run is a tmpfs, this will create /var/run/asterisk on start

#RuntimeDirectory=asterisk

#Nice=0

#UMask=0002

LimitCORE=infinity

#LimitNOFILE=

Restart=on-failure

RestartSec=5

# Prevent duplication of logs with color codes to /var/log/messages

StandardOutput=null

PrivateTmp=true

[Install]

WantedBy=multi-user.target

Then run systemctl daemon-reload

Asterisk crashes at start, maybe a locale problem

dnf install -y glibc-langpack-en

Which asterisk version is support/know to work?

On CentOS 6, it is very hard to compile anything new, but Asterisk 13.38.3 is the latest knowing to work

On CentOS 7, you can't compile PJPROJECT 1.16, so the latest version you can install is Asterisk 20.18.2

On CentOS 9, you can install any Asterisk 20 version