13

Install Kamailio SIP Server on CentOS 8 / CentOS 7

 3 years ago
source link: https://computingforgeeks.com/install-kamailio-sip-server-on-centos-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install Kamailio SIP Server on CentOS 8
Search

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.

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

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

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

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

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.

...
Dependencies resolved.
======================================================================================================================================================================================================
 Package                                               Architecture                      Version                                                           Repository                            Size
======================================================================================================================================================================================================
Installing:
 kamailio                                              x86_64                            5.5.2-0.el8.centos                                                kamailio                             6.2 M
 kamailio-debuginfo                                    x86_64                            5.5.2-0.el8.centos                                                kamailio                             4.3 M
 kamailio-gzcompress                                   x86_64                            5.5.2-0.el8.centos                                                kamailio                              24 k
 kamailio-ldap                                         x86_64                            5.5.2-0.el8.centos                                                kamailio                             109 k
 kamailio-mysql                                        x86_64                            5.5.2-0.el8.centos                                                kamailio                              82 k
 kamailio-outbound                                     x86_64                            5.5.2-0.el8.centos                                                kamailio                              29 k
 kamailio-presence                                     x86_64                            5.5.2-0.el8.centos                                                kamailio                             736 k
 kamailio-tls                                          x86_64                            5.5.2-0.el8.centos                                                kamailio                             195 k
 kamailio-unixodbc                                     x86_64                            5.5.2-0.el8.centos                                                kamailio                              45 k
 kamailio-utils                                        x86_64                            5.5.2-0.el8.centos                                                kamailio                              43 k
 kamailio-xmpp                                         x86_64                            5.5.2-0.el8.centos                                                kamailio                              60 k
Upgrading:
 vim-common                                            x86_64                            2:8.0.1763-16.el8                                                 appstream                            6.3 M
 vim-enhanced                                          x86_64                            2:8.0.1763-16.el8                                                 appstream                            1.4 M
Installing dependencies:
 libtool-ltdl                                          x86_64                            2.4.6-25.el8                                                      baseos                                57 k
 mariadb-connector-c-config                            noarch                            3.1.11-2.el8_3                                                    appstream                             14 k
 mysql-common                                          x86_64                            8.0.26-1.module+el8.4.0+652+6de068a7                              appstream                            133 k
 mysql-libs                                            x86_64                            8.0.26-1.module+el8.4.0+652+6de068a7                              appstream                            1.4 M
 unixODBC                                              x86_64                            2.3.7-1.el8                                                       appstream                            453 k
Installing weak dependencies:
 kamailio-debugsource                                  x86_64                            5.5.2-0.el8.centos                                                kamailio                             3.9 M
Enabling module streams:
 mysql                                                                                   8.0

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

Step 5: Configure Kamailio on CentOS 8 / CentOS 7

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

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

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:


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK