Install Kamailio SIP proxy server on CentOS 7 in a few steps








Are you trying to install Kamailio sip proxy server on centos 7?

This article is for you.

Kamailio is an open source implementation of a SIP Signaling Server. SIP is an open standard protocol specified by the IETF.
The IETF is an open international community of network designers, operators, vendors and researchers concerned with the evolution of the Internet architecture and the smooth operation of the Internet. The IETF was established in 1986 to coordinate the operation, management and evolution of the Internet.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to install and configure packages on CentOS 7 Server.
In this context, we shall look into the steps to install phpIPAM on CentOS.

More information about Kamailio?

Kamailio is an Open Source SIP Server for large VoIP and real-time communication platforms. It is a distribution of SER which provides a scalable SIP server suitable for small through to carrier-grade installations.

It can basically handle over 5000 call setups per second. Also, it can serve up to 300,000 active subscribers with just a 4GB Ram System.
Additionally, it functions as a Registrar server, Location server, Proxy server, SIP Application server, and Redirect server.

Steps to install Kamailio sip proxy server on CentOS 7?

Now, we will look into the steps to install Kamailio sip proxy server;

Step 1: Setting SELinux to a Permissive/Disabled mode

To set the SELinux to permissive mode, execute the commands;

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

Alternatively, you can permanently disable it by rebooting the CentOS system. To do this, execute;

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

After rebooting, confirm SELinux status by running the command and you will get a similar output:

$ 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, install the MariaDB database server by running the following commands;

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

Step 3: Add Kamailio RPM Repository

For CentOS 8, execute:

$ 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

Some packages are not on CentOS 8 repository. We have to use Fedora 29 repository on CentOS 8. If the same issue happens to you, change the repository by running the commands below.

$ 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

For CentOS 7, run:

$ 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

Once we add the repository, install the Kamailio SIP Server on CentOS 8/CentOS 7 Linux by executing;

$ 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 will be shown. In that we enter the 'Y' key to begin installation.

Then, confirm Kamailio version by running the following command and you will get a similar output if everything is fine with the installation;

$ 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: Configuring Kamailio on CentOS 8/CentOS 7

Now, modify the file "/etc/kamailio/kamctlrc" and make sure the DBENGINE variable is set to MySQL. Then, remove the pound symbol to uncomment it.

$ sudo vi /etc/kamailio/kamctlrc


After that, we set the database engine to MySQL.
DBENGINE=MYSQL
DBHOST=localhost


We run the below command to create 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 a root password, we enter the MySQL root user password as configured through mysql_secure_installation
Then we answer all the questions that follow. Next we edit /etc/kamailio/kamailio.cfg to configure Kamailio:

$ sudo vi /etc/kamailio/kamailio.cfg

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

After that, we start Kamailio

$ sudo systemctl restart kamailio

Then we enable the service to start on boot.

$ sudo systemctl enable kamailio

Finally, now we have a running Kamailio SIP server on CentOS.

$ 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 Sat 2020-12-05 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
......


[Need additional help with CentOS Software Installation and Configuration? – We are available to help you today.]



Conclusion

This article will guide you on the steps to install and configure Kamailio sip proxy on CentOS.


For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com