Get in Touch

Kamailio Overview

Kamailio (successor of OpenSER and SER) is an Open Source SIP Server released under GPL, able to handle thousands of call setups per second. Kamailio used to build huge platforms for VoIP and realtime communications – presence, WebRTC, Instant messaging and other applications. In addition, it can be easily used for scaling up SIP-to-PSTN gateways, media servers or PBX systems like Asterisk, FreeSWITCH or SEMS.

Among powerful features:

asynchronous TCP, UDP and SCTP, secure communication via TLS for VoIP (voice, video, text); SIMPLE instant informing and presence with embedded XCAP server and MSRP relay; WebSocket support for WebRTC; IPv4 and IPv6; asynchronous operations; IMS extensions for VoLTE; ENUM; DID and least cost routing; load balancing; routing fail-over, accounting, authentication and authorization. support for various backend systems such as MySQL, Cassandra, MongoDB, Postgres, Oracle, Radius, LDAP, Redis, Memcached; Json and XML RPC control interface, SNMP monitoring.


The following packages are required before proceeding to the next steps.

git client: apt-get install git-core – it is recommended to have a recent version, if your Linux distro has an old version. gcc compiler: apt-get install gcc flex – apt-get install flex bison – apt-get install bison libmysqlclient-dev – apt-get install libmysqlclient-dev make – apt-get install make if you want to enable more modules, some of them require extra libraries: 1. libssl – apt-get install libssl-dev 2. libcurl – apt-get install libcurl4-openssl-dev 3. libxml2 – apt-get install libxml2-dev 4. libpcre3 – apt-get install libpcre3-dev

Note: starting with version 4.3.0, Kamailio uses the directory /var/run/kamailio/ for creating FIFO and UnixSocket control files. You have to complete the section related to installation of init.d script for creating /var/run/kamailio even if you plan to start Kamailio manually from command line. The alternative is to set different paths via parameters of mi_fifo and ctl modules.

1. Getting sources from GIT

First of all, you have to create a directory on the file system where the sources will be stored.
    1. mkdir -p /usr/local/src/kamailio-devel
    2. cd /usr/local/src/kamailio-devel

2. Tuning Make files

The first step is to generate build config files.
    1. make cfg
Next step is to enable the MySQL module. Edit modules.lst file:
    1. nano -w modules.lst
Add db_mysql to the variable include_modules.
    1. include_modules= db_mysql
Save the modules.lst and exit. NOTE: this is one mechanism to enable modules which are not compiled by default, such as lcr, dialplan, presence – add the modules to include_modules variable inside the modules.lst file. Alternative is to set ‘include_modules’ variable to specify what extra modules to be included for compilation when building Makefile cfg:
    1. make include_modules=”db_mysql dialplan” cfg
NOTE: If you want to install everything in one directory (so you can delete all installed files at once), say /usr/local/kamailio-devel, then set PREFIX variable to the install path in ‘make cfg …’ command:
    1. make PREFIX=”/usr/local/kamailio-devel” include_modules=”db_mysql dialplan” cfg
NOTE: Previous release series 3.x.x used FLAVOUR mechanism to set the name of the application to kamailio. Starting with 4.0.0, the default is kamailio. From that version, if you want to build ser flavour, use FLAVOUR=ser in the make command to generate the build configs.

3. Compile Kamailio

Once you added the mysql module to the list of enabled modules, you can compile Kamailio:
    1. make all
You can get full compile flags output using:
    1. make Q=0 all

4. Install Kamailio

When the compilation is ready, install Kamailio with the following command:
    1. make install

5. Kamailio installation Path

The binaries and executable scripts were installed in:
    1. /usr/local/sbin
These are kamailio, kamdbctl, kamctl, kamcmd commond to manage SIP Server. To be able to use the binaries from command line, make sure that ‘/usr/local/sbin’ is set in PATH environment variable.
    1. PATH=$PATH:/usr/local/sbin
    2. export PATH
Kamailio (OpenSER) modules are installed in:
    1. /usr/local/lib/kamailio/modules/
Note: On 64 bit systems, /usr/local/lib64 may be used. The documentation and readme files are installed in:
    1. /usr/local/share/doc/kamailio/
The man pages are installed in:
    1. /usr/local/share/man/man5/
    2. /usr/local/share/man/man8/
The configuration file was installed in:
    1. /usr/local/etc/kamailio/kamailio.cfg

6. Create MySQL database

To create the MySQL database, first edit kamctlrc file to set the database server type:
    1. nano -w /usr/local/etc/kamailio/kamctlrc
Locate DBENGINE variable and set it to MYSQL:
You can change other values in kamctlrc file, at least it is recommended to change the default passwords for the users to be created to connect to database. Once you are done updating kamctlrc file, run the script to create the database used by Kamailio:
    1. /usr/local/sbin/kamdbctl create

7. Edit configuration file

To fit your requirements for the VoIP platform, you have to edit the configuration file.
    1. /usr/local/etc/kamailio/kamailio.cfg
Follow the instruction in the comments to enable usage of MySQL. Basically you have to add several lines at the top of config file, like:
    1. #!define WITH_MYSQL
    2. #!define WITH_AUTH
    3. #!define WITH_USRLOCDB

8. The init.d script

The init.d script can be used to start/stop the Kamailio server in a nicer way. A sample of init.d script for Kamailio is provided at:
    1. /usr/local/src/kamailio-devel/kamailio/pkg/kamailio/deb/debian/kamailio.init
Just copy the init file into the /etc/init.d/kamailio. Then change the permisions:
    1. chmod 755 /etc/init.d/kamailio

Related Post


The Future Prospect of Telephony Freeswitch is an open- standards VoIP telecom platform. It can be…

Read More


Opensips is one of the best solution that are present in opensource, it provide you ITSP…

Read More


Kamailio (successor of OpenSER and SER) is an Open Source SIP Server released under GPL, able…

Read More


Asterisk is one of the best telephony solutions which is free to use. There are others…

Read More

IVR Setting

Interactive Voice Response (IVR) allows your organizations to interact with customers through voice and DTMF tones…

Read More

Open Source

Elastix Elastix is appliance server software that integrates the most effective tools available for Asterisk-based PBXs…

Read More


Currently we are doing replication between two servers i.e. VPN3 and VPN4. Our project needed persistent…

Read More


Apache HTTP Server is an open-source HTTP server to develop and maintain modern operating systems including…

Read More


Subversion is a open-source version control tool. It is open-source and distributed as free software over…

Read More

Copyright © 2016 GVenture Technology Pvt. Ltd., All Rights Reserved.