(Last Updated On: November 26, 2018)

This guide will help you to install Latest Kamailio SIP Server on CentOS 7. This is part of Series tutorials on Building an Enterprise VOIP System. Kamailio is a distribution of SER and provides a scalable SIP server suitable for small through to carrier grade installations.

Features of Kamailio

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

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

We have tested this guide on:

  • Kamailio 5.1.6
  • CentOS 7.6

Install Latest Kamailio SIP Server on CentOS 7

Before we dive deep into the installation process, let’s get some heads up on basics about Kamailio SIP Server.

Step 1: Set SELinux to a Permissive/Disabled mode

If you’re not SELinux lover, I recommend you put it in Permissive mode:

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

If you decide to permanently disable it, you’ll need to reboot your  CentOS system:

sudo setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
sudo reboot

After rebooting, confirm SELinux status:

$ sestatus 
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31

Step 2: Install MariaDB Database server

Kamailio requires a database server to function. For this, we’ll use the MariaDB database server which can be installed on CentOS 7 using the guide below:

Install MariaDB 10.3 on Ubuntu 18.04 and CentOS 7

Step 3: Add Kamailio RPM Repository

Add CentOS 7’s Kamailio repos

cat >/etc/yum.repos.d/kamailio.repo<<EOF
[home_kamailio_v5.1.x-rpms]
name=RPM Packages for Kamailio v5.1.x (CentOS_7)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/kamailio:/v5.1.x-rpms/CentOS_7/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/home:/kamailio:/v5.1.x-rpms/CentOS_7/repodata/repomd.xml.key
enabled=1
EOF
Update package list index:
sudo yum makecache fast

Then install Kamailio packages

sudo yum install -y vim kamailio kamailio-presence kamailio-ldap kamailio-mysql kamailio-postgres kamailio-debuginfo kamailio-xmpp kamailio-unixodbc kamailio-utils kamailio-tls kamailio-outbound kamailio-gzcompress

Confirm installed Kamailio version:

$ kamailio -version
version: kamailio 5.1.6 (x86_64/linux) 7d1964
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 7d1964 
compiled on 11:10:15 Nov  4 2018 with gcc 4.8.5

Step 4: Configuring Kamailio

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

sudo vim /etc/kamailio/kamctlrc

Set Database engine to MYSQL

DBENGINE=MYSQL

The command below will create users and tables needed by Kamailio ( Schema)

kamdbctl create

When asked for root password, enter the MySQL root user password as configured through mysql_secure_installation

Answer Yes to all the questions that follow. The kamdbctl create command will add two Mysql users:

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.

Next is to edit /etc/kamailio/kamailio.cfg to configure Kamailio:

sudo vim /etc/kamailio/kamailio.cfg

Add the following lines just below #!KAMAILIO.

#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_NAT
#!define WITH_PRESENCE
#!define WITH_ACCDB

Start Kamailio

sudo systemctl restart kamailio

Enable the service to start on boot:

sudo systemctl enable kamailio

That’s the end. You should now have a running Kamailio SIP server on your CentOS 7.

In our next tutorial, we’ll talk about integrating Kamailio with Asterisk Server and Installing its GUI configuration manager called SIREMIS. Meanwhile, you can read on

How to install Asterisk PBX 13.x on CentOS 7 step by step guide