How to Install Latest Kamailio SIP Server on Ubuntu 18.04 / Ubuntu 16.04

(: August 25, 2018)

In this guide, I’ll take you through complete steps to install and configure Kamailio SIP Server on Ubuntu 18.04 / Ubuntu 16.04 system. This guide is a part of building an enterprise open source VOIP System on Linux. Our previous guide was on How to Install Latest Kamailio SIP Server on CentOS 7. So if you are a CentOS user, use the link for installation steps.

Introduction – What is Kamailio SIP Server?

Kamailio is a distribution of SER and provides a scalable SIP server suitable for small through to carrier grade installations. Kamailio is developed in C and runs on Linux/Unix systems. Kamailio’s main advantages for use alongside Media server like Asterisk are:

  • Kamailio can handle over 5000 call setups per second.
  • Can serve up to 300,000 active subscribers with just a 4GB Ram System.
  • Clustering can easily be realized by adding more Kamailio servers

Kamailio can function as:
● Registrar server
● Location server
● Proxy server
● SIP Application server
● Redirect server{text-align:left} img{margin:0 auto 0 0}

Other Features of Kamailio are:

  • NAT traversal support for SIP and RTP traffic
  • Load balancing with many distribution algorithms and
    failover support
  • Provides flexible least cost routing
  • Easy to realize routing failover
  • Support both IPv4 and IPv6
  • SCTP multi-homing and multi-streaming
  • Communication can be over UDP, TCP, TLS, and SCTP
  • Digest SIP User authentication
  • Provides event-based accounting
  • Data storage can be to database, Radius or Diameter
  • Extensible Java, Python, Lua and Perl Programming interface
  • TLS support for SIP signaling and transparent handling of SRTP for secure audio

How to Install Kamailio on Ubuntu 18.04 / Ubuntu 16.04

Below are some of the pre-requisites for installation of Kamailio on Ubuntu 18.04 system.

  • Installed MariaDB Server
  • Kamailio repositories

Start by installing MariaDB Server on Ubuntu 18.04 using the guide below:

Install MariaDB 10.3 on Ubuntu 18.04 and CentOS 7

Add Kamailio apt repository

If you’re running Ubuntu 16.04, you can add the following Kamailio repository to be used for installing Kamailio SIP proxy server.

First, download and add our GPG key to your apt key list:

wget -O- | sudo apt-key add -

Then add the repository lines to your /etc/apt/sources.list file depending on the Kamailio version of your choice. I’ll add a repository for latest release as of this writing – 5.1:

$ sudo vim /etc/apt/sources.list.d/kamailio.list

Add content:

deb xenial main
deb-src xenial main

The list of APT repositories and associated operating systems is available at

For Ubuntu 18.04, there is no need to add repository since the latest packages are available on upstream repositories.

Installing Kamailio on Ubuntu 18.04 / Ubuntu 16.04

Once the repository has been configured, update your system and install Kamailio. You’ll also install Kamailio MySQL modules:

$ sudo apt install kamailio kamailio-mysql-modules

For example, to be able to load websocket module, you have to install the package kamailio-websocket-modules:

$ sudo apt install kamailio-websocket-modules

Once the above commands are finished, you can check if kamailio application is available and confirm installed version using kamailio -V

$ which kamailio

$ kamailio -V
version: kamailio 5.1.2 (x86_64/linux) 
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled with gcc 7.3.0

Edit the file /etc/kamailio/kamctlrc and make sure the DBENGINE variable is set to MySQL. Remove the # symbol to uncomment it.

$ sudo vim /etc/kamailio/kamctlrc

Set Database engine to MYSQL


Next is to create database for Mysql. Command below will create users and tables need by Kamailio( Schema)

$ kamdbctl create
INFO: creating database kamailio ...
INFO: granting privileges to database kamailio ...
INFO: creating standard tables into kamailio ...
INFO: Core Kamailio tables succesfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into kamailio ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute
drouting userblacklist htable purple uac pipelimit mtree sca mohqueue
rtpproxy rtpengine? (y/n): y
INFO: creating extra tables into kamailio ...
INFO: Extra tables succesfully created.
Install tables for uid_auth_db uid_avp_db uid_domain uid_gflags
uid_uri_db? (y/n): y
INFO: creating uid tables into kamailio ...
INFO: UID tables succesfully created.

You will be prompted to provide a mysql root password. Mysql users and password added by above command are.

kamailio with the password kamailiorw. It has read/write access permissions to the Kamailio database.
kamailioro: The password for this user is kamailioro. It has read only access permissions to the Kamailio database.

The /etc/kamailio/kamailio.cfg is the configuration file for kamailio. Edit it to enable some of the features shipped with it.

You can also set your SIP domain:

$ sudo vim /etc/kamailio/kamctlrc
## your SIP domain

If you don’ have a working DNS server on your local network, you can as well use IP Address in place of a domain name.

Add the following lines just below #!KAMAILIO.

#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_ACCDB

These directives will turn on necessary modules.  E.g when you specify,WITH_MYSQL it enables the loading of

#!ifdef WITH_MYSQL
loadmodule ""

Then start Kamailio service:

$ sudo systemctl restart kamailio

Your Kamailio service should be running and you can confirm the same using:

# systemctl status kamailio
● kamailio.service - Kamailio (OpenSER) - the Open Source SIP Server
   Loaded: loaded (/lib/systemd/system/kamailio.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-07-27 18:15:20 UTC; 2min 59s ago
  Process: 14062 ExecStart=/usr/sbin/kamailio -P /var/run/kamailio/ -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP (code=exi
 Main PID: 14075 (kamailio)
    Tasks: 40 (limit: 4704)
   CGroup: /system.slice/kamailio.service
           ├─14075 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14083 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14084 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14085 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14086 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14087 /usr/sbin/kamailio -P /var/run/kamailio/ -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio

If you encounter any issues with Kamailio service, the logs are available on: /var/log/kamailio.log

Next article to read is How to Install Siremis Web management interface for Kamailio SIP Server on Ubuntu 18.04{text-align:left} img{margin:0 auto 0 0}