In this post you will find information that will tell you how to load, reload or remove specific modules. You will also find out what categories they are divided into. After the standard installation, the control panel does not contain all the modules and codecs available on the market, so we will show you how to install the additional ones that you may need.
Table of Contents
1) Initial informations
At the beginning it is worth mentioning where we can find the configuration files and directories related to the module configuration. If you have installed Asterisk to the default directories, you should find the following files:
/etc/asterisk/modules.conf
– module configuration file/usr/lib/asterisk/modulues
– modules directory
If you installed the control panel using our installer, the folder for 64-bit systems with modules will be: /usr/lib64/asterisk/modulues
The modules themselves are divided into the following categories:
- Applications
- Bridging
- Call Detail Records
- Channel Drivers
- Codecs
- Formats
- Functions
- Core/PBX
- Resources
If you cannot find the file modules.conf
, try executing:
find / -name 'modules.conf'
In the middle of the modules directory, you should find a ton of files with a .so
extension. Since they were generated by our installer, it should be possible to load each of them.
2) Using ‘autoload=yes’
The easiest way to load all available modules is to use autoload. This can be done in modules.conf
.
nano /etc/asterisk/modules.conf
Instead of manually editing /etc/asterisk/modules.conf
, you can also do this:
sed -i "s/^autoload.*$/autoload=yes/" /etc/asterisk/modules.conf
However, automatically loading all modules with autoload = yes
has some consequences. If any of the modules has not been properly loaded, the CLI will start throwing a lot of errors.
For example, if you created only basic files using make basic-pbx
, and then turn on autoload = yes
, you will see a lot of errors, e.g.
ERROR[1373]: res_config_ldap.c:1825 parse_config: Cannot load configuration file: res_ldap.conf ERROR[1373]: config_options.c:710 aco_process_config: Unable to load config file 'features.conf' NOTICE[1190]: chan_sip.c:32569 reload_config: Unable to load config sip.conf WARNING[1373]: func_odbc.c:1916 reload: Unable to load config for func_odbc: func_odbc.conf
and the like.
However:
- if you want to use
autoload=yes
, - you have configured the required configuration files,
- but you still get errors with modules you are not using
you may use noload
, to skip loading chosen modules.
The example configuration prompts, for example, to disable the res_hep
modules.
If you want to limit the number of errors thrown by Asterisk created with make basic-pbx
, just create (even empty) files that are missing or you can copy sample files.
# option 1 – copying sample files (recommended)
/bin/cp -b /etc/asterisk/samples/{cel.conf,features.conf,acl.conf,pjproject.conf,pjsip.conf,udptl.conf} /etc/asterisk/
# option 2 – creating empty files (NOT recommended; below SOME of required files)
touch /etc/asterisk/cel.conf /etc/asterisk/features.conf /etc/asterisk/acl.conf /etc/asterisk/udptl.conf
3) Manually loading modules with ‘autoload=no’
I think a great starting point is to use the modules.conf
file generated by make basic-pbx
.
Inside of the file, you’ll notice that oposite rules apply. By default, no modules are loaded and must be added manually. In the mentioned file you will notice that the modules are divided into 9 categories. Each of them corresponds to what was available when installing the control panel in make menuselect
.
Loading a misconfigures module will throw an error, but Asterisk will turn on normally. If you prefer to keep Asterisk inactive when a specific module fails, you can use require
as shown below.
require = res_pjsip.so
4) Examples of additional modules
Although basic PBX includes everything you need to run an Asterisk with basic functionality, you may want to load additional modules. Below we will discuss how to add some of them.
4.1) chan_sip.so module
Starting with Asterisk 13, PJSIP is the default driver for channel support. Therefore, the sip.conf
file is no longer generated by default by make basic-pbx
, but is generated by make samples
.
If you have the sample files, it might seem as if it would be enough to copy the sip.conf
file to /etc/asterisk/
and load the module in modules.conf
. However, if in CLI (asterisk -r
command) we execute “module load chan_sip.so
” we will get the error:
WARNING[1901]: chan_sip.c:33496 reload_config: Failed to bind to 0.0.0.0:5060: Address already in use
The above error is due to the fact that UDP port 5060 is already occupied by chan_pjsip.so
. It is enough to change the port to e.g. 5070 and the error will disappear and the PBX will listen on another port:
SIP Listening on 0.0.0.0:5070
Later we just need to add the chan_sip.so
module loading to modules.conf
so that the driver is loaded during Asterisk autostart.
We will achieve it by creating sip.conf
with minimal configuration, by executing the following commands:
cat <<'EOF'>/etc/asterisk/sip.conf
[general]
bindaddr=0.0.0.0
bindport=5070
transport=udp
EOF
# option if you don’t use autoload = yes in modules.conf
echo "load = chan_sip.so" >> /etc/asterisk/modules.conf
If you want to use a sample file from our installer, do:
/bin/cp -b /etc/asterisk/samples/sip.conf /etc/asterisk/
sed -i "s/^udpbindaddr=0.0.0.0.*$/udpbindaddr=0.0.0.0:5070/" /etc/asterisk/sip.conf
echo "load = chan_sip.so" >> /etc/asterisk/modules.conf
4.2) Additional G.723 and G.729 codecs
Since the license to use G.729 has been released, you can add the G.729 codec without purchasing additional transcoding cards or a license from Digium.
At http://asterisk.hosting.lv/ you will find links to download ready, compiled G.723 and G.729 codecs. We will not go into details on how to download files for each version of the system. We will focus on our case, which is the 64-bit version of Asterisk 16.
wget http://asterisk.hosting.lv/bin/codec_g723-ast160-gcc4-glibc-x86_64-barcelona.so
wget http://asterisk.hosting.lv/bin/codec_g729-ast160-gcc4-glibc-x86_64-barcelona.so
mv codec_g723-ast160-gcc4-glibc-x86_64-barcelona.so /usr/lib64/asterisk/modules/codec_g723.so
mv codec_g729-ast160-gcc4-glibc-x86_64-barcelona.so /usr/lib64/asterisk/modules/codec_g729.so
chmod +x /usr/lib64/asterisk/modules/codec_g723.so
chmod +x /usr/lib64/asterisk/modules/codec_g729.so
# optional if you do not use autoloading modules
echo "load = codec_g723.so" >> /etc/asterisk/modules.conf
echo "load = codec_g729.so" >> /etc/asterisk/modules.conf
asterisk -rx "module load codec_g723.so"
asterisk -rx "module load codec_g729.so"
The end result should contain additional codecs. Executing following command in Asterisk console will display our new codecs.
core show codecs audio
5) Show loaded modules
Although there’s no direct way to show all loaded modules with one commands, you may use …command ‘module show like
‘. Since modules have .so
extensions, you can show most of the modules with:
asterisk -rx 'module show like so'
This will display almost all loaded modules in Asterisk. We’re saying ‘almost’ because this command is skipping some core modules like acl, manager, http, logger, etc…