This guide will help you to install Latest Kamailio SIP Server on CentOS 7 / CentOS 8 Linux server. 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 SIP Server

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.x
  • CentOS 7 / CentOS 8

Install Kamailio SIP Server on CentOS 7 / CentOS 8

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

1. Set SELinux 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
sudo 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

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 / CentOS 8:

sudo yum -y install mariadb-server
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

3. Add Kamailio RPM Repository

CentOS 8:

Add Kamailio YUM repository on your CentOS 8 by running the following commands:

sudo yum -y install dnf-plugins-core
sudo yum config-manager --add-repo https://rpm.kamailio.org/centos/kamailio.repo

CentOS 7:

On CentOS 7, enable Kamailio RPM repository by running the following commands:

sudo yum -y install yum-utils
sudo yum-config-manager --add-repo https://rpm.kamailio.org/centos/kamailio.repo

4. Install Kamailio SIP Server

Once the repository is added, install Kamailio SIP Server on CentOS 8 / CentOS 7 Linux.

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

Dependency tree should be shown nd you can hit th y key in your keyboard to begin installation.

...
Transaction Summary
======================================================================================================================================================================================================
Install  17 Packages
Upgrade   2 Packages

Total download size: 25 M
Is this ok [y/N]: y

Confirm installed Kamailio version:

$ kamailio -version
version: kamailio 5.5.2 (x86_64/linux) 55e232
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
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: 55e232
compiled on 14:13:04 Aug 25 2021 with gcc 8.4.1

5. Configure Kamailio Server

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

sudo vi /etc/kamailio/kamctlrc

Set Database engine to MYSQL

DBENGINE=MYSQL
DBHOST=localhost
kamailio 5 database engine

Run the command below to create users and tables needed by Kamailio ( Schema).

$ sudo kamdbctl create
MySQL password for root:
INFO: test server charset
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 secfilter? (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.

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 vi /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
kamailio configuration

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 8 / CentOS 7 Linux.

$ systemctl status kamailio
● kamailio.service - Kamailio (OpenSER) - the Open Source SIP Server
   Loaded: loaded (/usr/lib/systemd/system/kamailio.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-05-03 16:35:23 EAT; 12s ago
 Main PID: 9648 (kamailio)
    Tasks: 41 (limit: 24003)
   Memory: 50.0M
   CGroup: /system.slice/kamailio.service
           ├─9648 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9649 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9650 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9651 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9652 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9653 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9654 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9655 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9656 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9658 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
           ├─9659 /usr/sbin/kamailio -DD -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 4
......

Other guides:

8 COMMENTS

  1. You need to install kamailio-presence with yum otherwise it will show errors of presence module while starting kamailio

  2. Hi. Very good tutorial. I’m looking forward the next tutorial, about Kamailio and asterisk integration. You will cover IVR and queues also? When you’ll publish it?

  3. Shows this error:

    WARNING: rtpproxy [rtpproxy.c:1405]: rtpp_test(): support for RTP proxy has been disabled temporarily
    ERROR: rtpproxy [rtpproxy.c:1476]: send_rtpp_command(): can’t send command to a RTP proxy
    ERROR: rtpproxy [rtpproxy.c:1511]: send_rtpp_command(): proxy does not respond, disable it

LEAVE A REPLY

Please enter your comment!
Please enter your name here