Asterisk configuration from database

Configuration from database

Asterisk configurations can be stored in a database. This is useful since it allows easy creation of web-based UIs. There are different approaches to storing users in a database.

1. Asterisk RealTime (Asterisk v1.2)

Asterisk RealTime
The Asterisk external configuration engine is the result of work by Anthony Minessale II, Mark Spencer, and Constantine Filin. It is designed to provide a flexible, seamless integration between Asterisk's internal configuration structure and external SQL databases (maybe even LDAP one day).

External configuration is configured in /etc/asterisk/extconfig.conf allowing you to map any configuration file (static mappings) to be pulled from the database, or to map special runtime entries which permit the dynamic creation of objects, entities, peers, etc. without the necessity of a reload.

Generally speaking, the columns in your tables should line up with the fields you would specify in the given entity declaration. If an entry would appear more than once, in the column it should be separated by a semicolon.

A Tutorial on how to install and configure Asterisk Realtime can be found here:

2. Dynamic 'friends' (Asterisk v1.0.*)

The user details are read directly from the database. This is used for SIP & IAX friends:
and also for MeetMe:

However the number of options supported by this 'MySQL_Friends' system is currently very limited: You can't specify nat= or host=dynamic nor accountcode= and the like. It appears that these restrictions made ast_data appear (see above and bug 1086).
Question: Does this entirely replace the peer entries in sip.conf, or does this add to manual entries in sip.conf?

3. Load configuration from database on startup (Asterisk v1.0.*)

Obviously, the disadvantage of such systems is that Asterisk needs to be reloaded to see these changes. This can be done from a shell script using

asterisk -r -x reload

or by using the Manager interface.
An example of this approach is: Asterisk GUI phpMyEdit

3a: res_config

All the details are stored in the database. When changes are made, asterisk has to be reloaded to load the new configuration in memory. This is the approach taken by:

3b: contrib scripts

This can be used to write a file to be #included in sip.conf or extensions.conf, which means you can nicely mix database-based setup with .conf file setup:

4. Templates & MySQL_AUTH

This is available in Olle's chan_sip2:

Templates can be used to store the different user options and peers can be 'autocreated' when they register. Only the passwords are stored in the MySQL database.

Option 4 can also benefit from the use of Templates.

See also

Created by: flavour, Last modification: Wed 03 of May, 2006 (05:10 UTC) by chrissnell
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+