Install the latest Kamailio SIP server on CentOS 8 / CentOS 7

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

This guide will help you install the latest Kamailio SIP server on CentOS 7 / CentOS 8 Linux server. This is part of a series of tutorials on building an enterprise VOIP system. Kamailio is a SER distribution that provides a scalable SIP server, suitable for installations from small to carrier grade.

Kamailio features

The main advantages of using Kamailio with media servers such as Asterisk are:

  • Kamailio can handle more than 5000 call settings per second.
  • Only 4GB of Ram system can serve 300,000 active users.
  • Clustering can be easily achieved by adding more Kamailio servers

Kamailio can be used as: ● Registration server ● Location server ● Proxy server ● SIP application server ● Redirect server

Other Kamailio features include:

  • Supports NAT traversal of SIP and RTP traffic
  • Load balancing with many distribution algorithms and failover support
  • Provide flexible and lowest cost routing
  • Easy to implement routing failover
  • Support both IPv4 and IPv6
  • SCTP multi-homing and multi-stream
  • Can communicate via UDP, TCP, TLS and SCTP
  • Summary SIP user authentication
  • Provide event-based accounting
  • Data can be stored to database, radius or diameter
  • Extensible Java, Python, Lua and Perl programming interfaces
  • TLS supports transparent processing of SIP signaling and SRTP to achieve secure audio

We have tested this guide in the following areas:

  • Kamailio 5.x
  • CentOS 7 / CentOS 8

Install Kamailio SIP server on CentOS 7 / CentOS 8

Before introducing the installation process in depth, let us first understand the basics of Kamailio SIP Server.

Step 1: Set SELinux to allow / disable mode

If you are not a SELinux enthusiast, it is recommended that you put it in “allow” mode:

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

If you decide to disable it permanently, you need to restart the CentOS system:

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

After rebooting, confirm the 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 run. For this, we will use the MariaDB database server that can be installed on CentOS 7 / CentOS 8:

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

Step 3: Add Kamailio RPM repository

CentOS 8:

sudo wget -O /etc/yum.repos.d/kamailio.repo http://download.opensuse.org/repositories/home:/kamailio:/v5.3.x-rpms/CentOS_8/home:kamailio:v5.3.x-rpms.repo

At the time of this update, some packages are not in the CentOS 8 repository. I have to use Fedora 29 repository on CentOS 8. If you encounter the same problem, please change the repository by running the following command.

sudo wget -O /etc/yum.repos.d/kamailio.repo http://download.opensuse.org/repositories/home:/kamailio:/v5.3.x-rpms/Fedora_29/home:kamailio:v5.3.x-rpms.repo

CentOS 7:

sudo wget -O /etc/yum.repos.d/kamailio.repo http://download.opensuse.org/repositories/home:/kamailio:/v5.3.x-rpms/CentOS_7/home:kamailio:v5.3.x-rpms.repo

Step 4: Install Kamailio SIP server on CentOS 8 / CentOS 7

After adding the repository, install the 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

The dependency tree should be displayed, you can click ÿ Enter the letters on the keyboard to start the installation.

Dependencies resolved.
========================================================================================================================================================
 Package                           Arch                Version                                             Repository                              Size
========================================================================================================================================================
Installing:
 kamailio                          x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms              5.6 M
 kamailio-debuginfo                x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms              3.8 M
 kamailio-gzcompress               x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               19 k
 kamailio-ldap                     x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               99 k
 kamailio-mysql                    x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               74 k
 kamailio-outbound                 x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               24 k
 kamailio-presence                 x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms              673 k
 kamailio-tls                      x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms              187 k
 kamailio-unixodbc                 x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               39 k
 kamailio-utils                    x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               37 k
 kamailio-xmpp                     x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms               53 k
Upgrading:
 vim-common                        x86_64              2:8.0.1763-13.el8                                   AppStream                              6.3 M
 vim-enhanced                      x86_64              2:8.0.1763-13.el8                                   AppStream                              1.4 M
Installing dependencies:
 mysql-common                      x86_64              8.0.17-3.module_el8.0.0+181+899d6349                AppStream                              143 k
 mysql-libs                        x86_64              8.0.17-3.module_el8.0.0+181+899d6349                AppStream                              1.2 M
 unixODBC                          x86_64              2.3.7-1.el8                                         AppStream                              458 k
Installing weak dependencies:
 kamailio-debugsource              x86_64              5.3.3-4.1                                           home_kamailio_v5.3.x-rpms              3.7 M
Enabling module streams:
 mysql                                                 8.0                                                                                             

Transaction Summary
========================================================================================================================================================
Install  15 Packages
Upgrade   2 Packages

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

Confirm the installed Kamailio version:

$ kamailio -version
version: kamailio 5.3.3 (x86_64/linux) c918a3
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_BLACKLIST, 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: c918a3 
compiled on 14:32:52 Mar 16 2020 with gcc 8.2.1

Step 5: Configure Kamailio on CentOS 8 / CentOS 7

Edit file /etc/kamailio/kamctlrc And make sure to set the DBENGINE variable to MySQL. Delete the pound sign to uncomment.

sudo vi /etc/kamailio/kamctlrc

Set the database engine to MYSQL

DBENGINE=MYSQL
DBHOST=localhost

Run the following command to create the users and tables required 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 the root password, enter the MySQL root user password that was configured mysql_secure_installation

Answer “yes” to all subsequent questions. of kamdbctl create This command will add two Mysql users:

Camellio: With password.kamailiorw It has read / write access to Kamailio database.

Camellio: The user’s password is kamailioro. It has read-only access to the Kamailio database.

Next is editing /etc/kamailio/kamailio.cfg Configure Kamailio:

sudo vi /etc/kamailio/kamailio.cfg

Add the following line below #! KAMAILIO.

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

Install the latest Kamailio SIP server on CentOS 8 / CentOS 7

Start Kamailio

sudo systemctl restart kamailio

Enable the service to start at startup:

sudo systemctl enable kamailio

So far. Now, you should have a running Kamailio SIP server on 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 guidelines:

Install Asterisk PBX on CentOS 8

Install Asterisk PBX on CentOS 7

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Sidebar