author image


This is a step by step tutorial about how to install and maintain Kamailio SIP server development version using the sources downloaded from GIT repository - the choice for those willing to write code for Kamailio or to try the new features to be released in the future with the next major stable version.

This document focuses on Kamailio v5.5.x series, installed with MySQL/MariaDB support, using a Debian unstable system.

Prerequisites To be able to follow the guidelines from this document you need root access.

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

git client: apt-get install git - it is recommended to have a recent version, if your Linux distro has an old version, you can download newer one from

gcc and g++ compilers: apt-get install gcc g++

flex - apt-get install flex

bison - apt-get install bison

libmysqlclient-dev - apt-get install libmysqlclient-dev (or: apt install default-libmysqlclient-dev)

make, autoconf and pkg-config - apt-get install make autoconf pkg-config

nml  apt install libmnl-dev -y

if you want to enable more modules, some of them require extra libraries:

libssl - apt-get install libssl-dev

libcurl - apt-get install libcurl4-openssl-dev

libxml2 - apt-get install libxml2-dev

libpcre3 - apt-get install libpcre3-dev

MySQL Or MariaDB Server To complete all the steps in this tutorial, it is required to have a MySQL or MariaDB server installed. Consult the documentation of MySQL or MariaDB server for Debian for a proper installation.

For testing purposes, it can just be done with apt-get install mysql-server or apt-get install default-mysql-server. During or after installation you may have to complete some configuration steps, such as setting the password for mysql root user or initialize the database system.

Getting Sources From GIT First of all, you have to create a directory on the file system where the sources will be stored.

mkdir -p /usr/local/src/kamailio-5.5
cd /usr/local/src/kamailio-5.5

Download the sources from GIT using the following commands.

git clone --depth 1 --no-single-branch kamailio
cd kamailio
git checkout -b 5.5 origin/5.5

Note: if your git client version does not support –no-single-branch command line parameter, then just remove it.

Tuning Makefiles The first step is to generate build config files.

If make it with PREFIX, it in /usr/local/kamailio/sbin,etc…,so ,use it please with real path.

make PREFIX="/usr/local/kamailio" include_modules=“app_lua_sr app_lua crypto db_postgres dialplan db_unixodbc http_client ims_auth ims_charging ims_dialog ims_diameter_server ims_icscf ims_ipsec_pcscf ims_isc ims_ocs ims_qos ims_registrar_pcscf ims_registrar_scscf ims_usrloc_pcscf ims_usrloc_scscf lcr presence presence_profile presence_mwi presence_dialoginfo presence_reginfo presence_xml regex uuid” cfg

Compile Kamailio Once you added the mysql module to the list of enabled modules, you can compile Kamailio:

make all

You can get full compile flags output using:

make Q=0 all

Install Kamailio

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

make install

What And Where Was Installed

The binaries and executable scripts were installed in:


These are:

kamailio - Kamailio SIP server

kamdbctl - script to create and manage the Databases

kamctl - script to manage and control Kamailio SIP server

kamcmd - CLI - command line tool to interface with Kamailio SIP server

To be able to use the binaries from command line, make sure that /usr/local/sbin is set in PATH environment variable. You can check that with echo $PATH. If not and you are using bash, open /root/.bash_profile and at the end add:

export PATH

Kamailio modules are installed in:


Note: On 64 bit systems, /usr/local/lib64 may be used.

The documentation and readme files are installed in:


The man pages are installed in:



The configuration file was installed in:


NOTE:: In case you set the PREFIX variable in make cfg … command, then replace /usr/local in all paths above with the value of PREFIX in order to locate the files installed.

Create MySQL Database

To create the MySQL database, you have to use the database setup script. First edit kamctlrc file to set the database server type:

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.

Note that the existing line with DBENGINE or other attributes may be commented, uncomment by removing the # character at the beginning of the line.

Once you are done updating kamctlrc file, run the script to create the database used by Kamailio:

/usr/local/sbin/kamdbctl create
#You can call this script without any parameter to get some help for the usage. You will be asked for the domain name Kamailio is going to serve (e.g., and the password of the root MySQL user. The script will create a database named kamailio containing the tables required by Kamailio. You can change the default settings in the kamctlrc file mentioned above.

The script will add two users in MySQL:

kamailio - (with default password kamailiorw) - user which has full access rights to kamailio database

kamailioro - (with default password kamailioro) - user which has read-only access rights to kamailio database

IMPORTANT: do change the passwords for these two users to something different that the default values that come with sources.

Edit Configuration File To fit your requirements for the VoIP platform, you have to edit the configuration file.

#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:

#!define WITH_MYSQL
#!define WITH_AUTH
#If you changed the password for the kamailio user of MySQL, you have to update the value for db_url parameters.

#You can browse kamailio.cfg online on GIT repository.

Running Kamailio There are couple of variants for starting/stopping/restarting Kamailio, the recommended ones being via init.d script or systemd unit, a matter of what the Debian OS is configured to use.

Init.d Script To install the init.d script, run in Kamailio source code directory:

make install-initd-debian Follow any instructions that may be printed by the above commad.

Then you can start/stop Kamailio using the following commands:

/etc/init.d/kamailio start
/etc/init.d/kamailio stop

Systemd Unit To install the systemd unit, run in Kamailio source code directory:

make install-systemd-debian Follow any instructions that may be printed by the above commad.

Then you can start/stop Kamailio using the following commands:

systemctl start kamailio
systemctl stop kamailio

You may need to edit edit /usr/local/etc/kamailio/kamctlrc and set the PID_FILE and STARTOPTIONS attributes.

The you can use:

kamctl start kamctl stop Command Line Kamailio can be started from command line by executing the binary with specific parameters. For example:

start Kamailio

/usr/local/sbin/kamailio -P /var/run/kamailio/ -m 128 -M 12 stop Kamailio

killall kamailio


kill -TERM $(cat /var/run/kamailio/

Ready To Rock

Now everything is in place. You can start the VoIP service, creating new accounts and setting the phones.

A new account can be added using kamctl tool via:

kamctl add username password

If SIP_DOMAIN was not set in kamctlrc file do one of the following option.

run in terminal:

kamctl add username password
or edit /usr/local/etc/kamailio/kamctlrc and add:
and then run again kamctl add ... as above.

or give the username with domain in kamctl add ... parameter:

kamctl add password
Instead of it has to be given the real domain for the SIP service or the IP address of Kamailio.

The maintenance process is very simple right now. You have to be user root and execute following commands:

cd /usr/local/src/kamailio-devel/kamailio
git pull origin
make all
make install
/etc/init.d/kamailio restart
Now you have the latest Kamailio devel running on your system.

When To Update
Notification about GIT commits are sent to the mailing list: Each commit notification contains the reference to the branch where the commit has been done. If the commit message contains the lines:

Module: kamailio
Branch: 5.5
then an update has been made to Kamailio devel version and it will be available to the public GIT in no time.

A modern command line control tool for Kamailio is available at:

It offers an alternative to all kamctl/kamdbctl/kamcmd, offering internal interactive shell with syntax highlighting, tab completion and suggestions from history. It implements more sub-commands than kamctl and has the ability to format the output using different styles.

IMS Configuration

VoLTE test

+———+ +——-+ +——-+ | | <–> | IMS | <–> | | | UE1 | | + | | UE2 | | | | EPC | | | | | | | | | +—+—–+ +——-+ +——-+

#ims directory

root@lihao:/opt/kamailio# ls /opt/kamailio/misc/examples/ims
icscf ims_dnszone pcscf scscf
#icscf kamailio.cfg file

root@lihao:/opt/kamailio# ls /opt/kamailio/misc/examples/ims/icscf
icscf.cfg.sample icscf.sql icscf.xml.sample kamailio.cfg
icscf kamailio.cfg

loadmodule ""

# ----- icscf params -----
# Comment the following line to enable realm routing
modparam("ims_icscf", "cxdx_forced_peer", CXDX_FORCED_PEER)
modparam("ims_icscf","cxdx_dest_realm", NETWORKNAME)

# DB-URL, where information about S-CSCF-Server can be found:
#!ifdef DB_URL2
modparam("ims_icscf", "db_url", "cluster://lihao")
modparam("ims_icscf", "db_url", DB_URL)

#!ifdef PEERING
# Route which is executed, in case HSS returned "User-Unknown" on LIR request
modparam("ims_icscf","route_lir_user_unknown", "lir_term_user_unknown")
# Route which is executed, in case HSS returned "User-Unknown" on UAR request
modparam("ims_icscf","route_uar_user_unknown", "uar_term_user_unknown")
#icscf process script

root@lihao:/opt/kamailio# ls /opt/kamailio/misc/examples/ims/pcscf
dispatcher.list.sample kamailio.cfg pcscf.cfg.sample pcscf.xml.sample route sems tls.cfg.sample
pcscf kamailio.cfg

loadmodule "ims_dialog"
loadmodule "ims_usrloc_pcscf"
#!ifdef WITH_IPSEC
loadmodule "ims_ipsec_pcscf"
loadmodule "ims_registrar_pcscf"
loadmodule "ims_qos"
#!ifdef DB_URL
#!ifdef DB_URL2
modparam("ims_usrloc_pcscf", "db_url", "cluster://lihao")
modparam("ims_usrloc_pcscf", "db_url", DB_URL)
modparam("ims_usrloc_pcscf", "db_mode", 1)
modparam("ims_usrloc_pcscf", "enable_debug_file", 0)
modparam("ims_usrloc_pcscf", "match_contact_host_port", 1)
modparam("ims_registrar_pcscf", "is_registered_fallback2ip", 1)
modparam("ims_registrar_pcscf", "ignore_reg_state", 1)
modparam("ims_registrar_pcscf", "ignore_contact_rxport_check", 1)

modparam("ims_registrar_pcscf", "subscribe_to_reginfo", 1)
modparam("ims_registrar_pcscf", "publish_reginfo", 1)
modparam("ims_registrar_pcscf", "pcscf_uri", PCSCF_URL)
modparam("ims_registrar_pcscf", "subscribe_to_reginfo", 0)
modparam("ims_registrar_pcscf", "publish_reginfo", 0)

#!ifdef WITH_IPSEC
modparam("ims_ipsec_pcscf", "ipsec_listen_addr", IPSEC_LISTEN_ADDR)
modparam("ims_ipsec_pcscf", "ipsec_client_port", IPSEC_CLIENT_PORT)
modparam("ims_ipsec_pcscf", "ipsec_server_port", IPSEC_SERVER_PORT)

#!ifdef WITH_RX
# -- CDP params --
# -- diameter_rx params --
modparam("ims_qos", "rx_dest_realm", "NETWORKNAME")
# -- ims_dialog params --
modparam("ims_dialog", "dlg_flag", FLT_DIALOG)
modparam("ims_dialog", "timeout_avp", "$avp(DLG_TIMEOUT_AVP)")
modparam("ims_dialog", "detect_spirals", 0)
modparam("ims_dialog", "profiles_no_value", "orig ; term")
#!ifdef DB_URL
#!ifdef DB_URL2
modparam("ims_dialog", "db_url", "cluster://cluster1")
modparam("ims_dialog", "db_url", DB_URL)
modparam("ims_usrloc_pcscf", "db_mode", 1)

#pcscf process script

root@lihao:/opt/kamailio# ls /opt/kamailio/misc/examples/ims/scscf/
CxDataType_Rel6.xsd CxDataType_Rel7.xsd CxDataType_Rel8.xsd dispatcher.list.sample kamailio.cfg scscf.cfg.sample scscf.xml.sample
icscf kamailio.cfg

loadmodule ""
loadmodule ""
loadmodule ""
loadmodule ""
loadmodule ""
#!ifdef WITH_RO
loadmodule ""
##!ifdef WITH_DEBUG
loadmodule ""
modparam("debugger", "mod_hash_size", 5)
modparam("debugger", "mod_level_mode", 1)
#modparam("debugger", "mod_level", "ims_usrloc_scscf=3")
#modparam("debugger", "mod_level", "ims_registrar_scscf=3")
modparam("debugger", "mod_level", "ims_auth=3")
#modparam("debugger", "mod_level", "ims_isc=3")
modparam("debugger", "mod_level", "ims_dialog=3")
#modparam("debugger", "mod_level", "ims_charging=3")
# -- usrloc params --
modparam("ims_usrloc_scscf", "enable_debug_file", 0)
modparam("ims_usrloc_scscf", "matching_mode", 0)
modparam("ims_registrar_scscf", "max_contacts", 3);
modparam("ims_usrloc_scscf", "maxcontact_behaviour", 2) #overwrite
#!ifdef DB_URL
#!ifdef DB_URL2
modparam("ims_usrloc_scscf", "db_url", "cluster://cluster1")
modparam("ims_usrloc_scscf", "db_url", DB_URL)
modparam("ims_usrloc_scscf", "db_mode", 1)
modparam("ims_registrar_scscf", "subscription_default_expires", 654800)
modparam("ims_registrar_scscf", "subscription_min_expires", 3700)
modparam("ims_registrar_scscf", "subscription_max_expires", 605800)

# -- CDP params --

# -- ims_dialog params --
modparam("ims_dialog", "dlg_flag", FLT_DIALOG)
modparam("ims_dialog", "timeout_avp", "$avp(DLG_TIMEOUT_AVP)")
modparam("ims_dialog", "detect_spirals", 1)
modparam("ims_dialog", "profiles_no_value", "orig ; term")
modparam("ims_dialog", "db_mode", 0)

# -- ims_auth params --
modparam("ims_auth", "name", URI)
modparam("ims_auth", "registration_default_algorithm", REG_AUTH_DEFAULT_ALG)
modparam("ims_auth", "cxdx_forced_peer", CXDX_FORCED_PEER)
modparam("ims_auth", "cxdx_dest_realm", NETWORKNAME)
modparam("ims_auth", "av_check_only_impu", 1)

#modparam("ims_auth", "auth_data_timeout", 5)
modparam("ims_auth","auth_used_vector_timeout", 300)

# -- ims_registrar_scscf params --
#!ifdef WITH_DEBUG
modparam("ims_registrar_scscf", "default_expires", 60)
modparam("ims_registrar_scscf", "min_expires", 60)
modparam("ims_registrar_scscf", "max_expires", 60)
modparam("ims_registrar_scscf", "default_expires", 604800)
modparam("ims_registrar_scscf", "min_expires", 60)
modparam("ims_registrar_scscf", "max_expires", 604800)
modparam("ims_registrar_scscf", "use_path", 1)
modparam("ims_registrar_scscf", "support_wildcardPSI",1)
modparam("ims_registrar_scscf", "user_data_xsd","/etc/kamailio_scscf/CxDataType_Rel7.xsd")
modparam("ims_registrar_scscf", "scscf_name", URI)
modparam("ims_registrar_scscf", "scscf_name", URI)
modparam("ims_registrar_scscf", "cxdx_dest_realm", NETWORKNAME)
# ----- ims_isc params -----
modparam("ims_isc", "my_uri", HOSTNAME)
modparam("ims_isc", "add_p_served_user", 1)

#!ifdef WITH_RO
# ----- ims_diameter_ro params -----
#!ifdef DB_URL
#!ifdef DB_URL2
#modparam("ims_charging", "db_url", "cluster://cluster1")
#modparam("ims_charging", "db_url", DB_URL)
#modparam("ims_charging", "db_mode", 1)
modparam("ims_charging", "origin_host", HOSTNAME);
modparam("ims_charging", "origin_realm", NETWORKNAME);
modparam("ims_charging", "ro_forced_peer", RO_FORCED_PEER);
modparam("ims_charging", "destination_host", RO_DESTINATION);
modparam("ims_charging", "destination_realm", NETWORKNAME);

modparam("ims_charging","service_context_id_root", RO_ROOT);
modparam("ims_charging","service_context_id_ext", RO_EXT);
modparam("ims_charging","service_context_id_mnc", RO_MNC);
modparam("ims_charging","service_context_id_mcc", RO_MCC);
modparam("ims_charging","service_context_id_release", RO_RELEASE);

###########ims scscf process script

Recent Articles



 注意,本次应用的能力为半实时,即不是每个语音包流都要送往识别,而是VAD后才送,识别后通过ESL发送消息后进行处理,用于座席辅助或半实时质检均可。部署方式为:云主机、物理机、测试型的内部虚拟机均可。识别特性:座席助手,或当检测到有异常,实 …