How to configure Asterisk AMI

Asterisk Managment Interface (AMI) – a powerful API interface for Asterisk, allows you to manage, execute commands, receive notifications about events in real time, etc.

To enable Asterisk AMI, open the /etc/asterisk/manager.conf file in a text editor and specify the parameters:

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
timestampevents = yes
displayconnects = yes
allowmultiplelogin = yes
webenabled = no

#include "manager.d/*.conf"

Now create the configuration file for the first user:

sudo nano /etc/asterisk/manager.d/admin.conf
sudo chown asterisk:asterisk /etc/asterisk/manager.d/admin.conf

And add to it:

[admin]
secret = IXNFO
deny = 0.0.0.0/0.0.0.0
permit = 127.0.0.1/255.255.255.0
permit = 192.168.2.2/255.255.255.255
permit = 192.168.5.5/255.255.255.255
read = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr,dialplan,originate

Where I indicated:
admin (user login)
secret (user password)
deny (denied all access)
permit (allow access only from specified IP addresses and networks)
read and write (we define the rights to the user, I have specified all)

Apply the changes:

asterisk -rvvv
module reload manager
manager reload
quit

Make sure the Asterisk AMI is running:

netstat -tulpn | grep :5038

Example of viewing available commands, settings, users, connected users, events:

manager show commands
manager show command NAME
manager show settings
manager show users
manager show connected
manager show events

You can enable and disable the debugging mode as follows:

manager set debug on
manager set debug off

See also my article:
IPTables rules for Asterisk AMI

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply