We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install Kamailio SIP Server on Ubuntu 20.04|18.04|16.04

Learn how to – Install Kamailio SIP Server on Ubuntu 20.04|18.04|16.04.

In this guide, I’ll take you through complete steps to install and configure Kamailio SIP Server on Ubuntu 20.04/18.04/16.04 Linux system. This guide is a part of building an enterprise open source VOIP System on Linux. Our previous guide was on How to Install Latest Kamailio SIP Server on CentOS 7. So if you are a CentOS user, use the link for installation steps.

Introduction – What is Kamailio SIP Server?

Kamailio is a distribution of SER and provides a scalable SIP server
suitable for small through to carrier grade installations. Kamailio is
developed in C and runs on Linux/Unix systems. 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

Install Kamailio on Ubuntu 20.04/18.04/16.04

Below are some of the pre-requisites for installation of Kamailio on Ubuntu 18.04 system.

  • Installed MariaDB Server
  • Kamailio repositories

Step 1: Install MariaDB Database Server

Start by installing MariaDB Server on Ubuntu using the commands:

sudo apt update
sudo apt install mariadb-server

Step 2: Add Kamailio apt repository

Add the following Kamailio repository to be used for installing Kamailio SIP proxy server.

But first, download and add our GPG key to your apt key list:

wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -

Then add the repository lines to your /etc/apt/sources.list file depending on the Kamailio version of your choice. I’ll add a repository for latest release as of this writing – 5.5:

For Ubuntu 20.04

sudo tee /etc/apt/sources.list.d/kamailio.list<<EOF
deb     http://deb.kamailio.org/kamailio55 focal main
deb-src http://deb.kamailio.org/kamailio55 focal main
EOF

For Ubuntu 18.04

sudo tee /etc/apt/sources.list.d/kamailio.list<<EOF
deb     http://deb.kamailio.org/kamailio55 bionic main
deb-src http://deb.kamailio.org/kamailio55 bionic main
EOF

For Ubuntu 16.04

sudo tee /etc/apt/sources.list.d/kamailio.list<<EOF
deb     http://deb.kamailio.org/kamailio55 xenial main
deb-src http://deb.kamailio.org/kamailio55 xenial main
EOF

The list of APT repositories and associated operating systems is available at http://deb.kamailio.org

Step 3: Install Kamailio on Ubuntu 20.04|18.04|16.04

Once the repository has been configured, update your system and install Kamailio. You’ll also install Kamailio MySQL modules:

sudo apt update
sudo apt install kamailio kamailio-mysql-modules

Proceed with the installation as prompted

...
The following additional packages will be installed:
  default-mysql-client libmysqlclient21 mysql-client-8.0 mysql-client-core-8.0 mysql-common
Suggested packages:
  kamailio-berkeley-modules kamailio-cpl-modules kamailio-dbg kamailio-ldap-modules kamailio-lua-modules kamailio-perl-modules kamailio-postgres-modules kamailio-presence-modules
  kamailio-python-modules kamailio-radius-modules kamailio-snmpstats-modules kamailio-tls-modules kamailio-unixodbc-modules kamailio-xml-modules kamailio-xmpp-modules
The following NEW packages will be installed:
  default-mysql-client kamailio kamailio-mysql-modules libmysqlclient21 mysql-client-8.0 mysql-client-core-8.0 mysql-common
0 upgraded, 7 newly installed, 0 to remove and 42 not upgraded.
Need to get 12.6 MB of archives.
After this operation, 108 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

To be able to load websocket module, you have to install the package kamailio-websocket-modules:

sudo apt install kamailio-websocket-modules kamailio-tls-modules

Once the above commands are finished, you can check if kamailio application is available and confirm installed version using kamailio -V

$ which kamailio
/usr/sbin/kamailio

$ kamailio -V
version: kamailio 5.5.3 (x86_64/linux)
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: unknown
compiled with gcc 9.3.0

Step 4: Configure Kamailio on Ubuntu 20.04|18.04|16.04

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

Set Database engine to MYSQL

$ sudo vim /etc/kamailio/kamctlrc
DBENGINE=MYSQL
DBHOST=localhost

Next is to create database for Mysql. Command below will create users and tables need by Kamailio( Schema)

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

You will be prompted to provide a mysql root password. Mysql users and password added by above command are.

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

The /etc/kamailio/kamailio.cfg is the configuration file for kamailio. Edit it to enable some of the features shipped with it.

You can also set your SIP domain:

$ sudo vim /etc/kamailio/kamctlrc
## your SIP domain
SIP_DOMAIN=ownyourlife.com.ng

If you don’ have a working DNS server on your local network, you can as well use IP Address in place of a domain name.

Add the following lines just below #!KAMAILIO.

$ sudo vim /etc/kamailio/kamailio.cfg
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
#!define WITH_ACCDB

These directives will turn on necessary modules.  E.g when you specify,WITH_MYSQL it enables the loading of mysql.so:

#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif

Then restart Kamailio service:

sudo systemctl restart kamailio

Your Kamailio service should be running and you can confirm the same using:

$ systemctl status kamailio
kamailio.service - Kamailio (OpenSER) - the Open Source SIP Server
   Loaded: loaded (/lib/systemd/system/kamailio.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-07-27 18:15:20 UTC; 2min 59s ago
  Process: 14062 ExecStart=/usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP (code=exi
 Main PID: 14075 (kamailio)
    Tasks: 40 (limit: 4704)
   CGroup: /system.slice/kamailio.service
           ├─14075 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14083 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14084 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14085 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14086 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio
           ├─14087 /usr/sbin/kamailio -P /var/run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg -m 64 -M 8 -u kamailio -g kamailio

If you encounter any issues with Kamailio service, the logs are available on: /var/log/kamailio.log

Next article to read is:

Cart

Your Cart is Empty

Back To Shop