In this guide, I’ll take you through complete steps to install and configure Kamailio SIP Server on Ubuntu 18.04 / Ubuntu 16.04 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
- 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
How to Install Kamailio on Ubuntu 18.04 / Ubuntu 16.04
Below are some of the pre-requisites for installation of Kamailio on Ubuntu 18.04 system.
- Installed MariaDB Server
- Kamailio repositories
Start by installing MariaDB Server on Ubuntu 18.04 using the guide below:
Add Kamailio apt repository
If you’re running Ubuntu 16.04, you can add the following Kamailio repository to be used for installing Kamailio SIP proxy server.
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.1:
$ sudo vim /etc/apt/sources.list.d/kamailio.list
deb http://deb.kamailio.org/kamailio51 xenial main deb-src http://deb.kamailio.org/kamailio51 xenial main
The list of APT repositories and associated operating systems is available at http://deb.kamailio.org
For Ubuntu 18.04, there is no need to add repository since the latest packages are available on upstream repositories.
Installing Kamailio on Ubuntu 18.04 / Ubuntu 16.04
Once the repository has been configured, update your system and install Kamailio. You’ll also install Kamailio MySQL modules:
$ sudo apt install kamailio kamailio-mysql-modules
For example, to be able to load websocket module, you have to install the package kamailio-websocket-modules:
$ sudo apt install kamailio-websocket-modules
Once the above commands are finished, you can check if
kamailio application is available and confirm installed version using
$ which kamailio /usr/sbin/kamailio $ kamailio -V version: kamailio 5.1.2 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, 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 ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, 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 7.3.0
Edit the file
/etc/kamailio/kamctlrc and make sure the
DBENGINE variable is set to MySQL. Remove the
# symbol to uncomment it.
$ sudo vim /etc/kamailio/kamctlrc
Set Database engine to MYSQL
Next is to create database for Mysql. Command below will create users and tables need by Kamailio( Schema)
$ kamdbctl create 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.
/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=sxi.io
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.