Kamailio is an open-source SIP server, previously known as OpenSER. It is able to handle thousands of call setups per second and as such can be used to build high-grade applications for VoIP and real-time communications. Kamailio can be used as a SIP registrar, proxy/redirect server, SIP security firewall and support presence, RADIUS accounting and authorization. It supports various storage backends like SQL/NoSQL and many more.
Kamailio was released all the way back in 2002 under the name of OpenSER. Today, Kamailio is used by large scale internet service providers to provide public telephony services.
We will be installing Kamailio 5.4, from the sources, which is the latest release at the time of writing. For this tutorial Debian 10 will be used as the host operating system. The following is the brief overview of the steps we will be performing to install Kamailio
- Pre-requisite steps
- Downloading the source
- Configuring and compiling
- Database Configuration
Step 1: Pre-Requisite
First, Let us make sure that our packages and OS is up-to-date.
apt update && apt upgrade
Next we will install the dependencies which are required to be fulfilled for the proper functioning of Kamailio and it’s modules
apt install git gcc g++ flex bison libmariadb-dev libmariadb-dev-compat make autoconf pkg-config libssl-dev libcurl4-openssl-dev libxml2-dev libpcre3-dev
Next up, we will install and configure MariaDB server to use it as a database back-end for our Kamailio server.
apt install mariadb-server systemctl enable mariadb systemctl start mariadb mysql_secure_installation
Step 2: Downloading the Source
Let’s begin with downloading the latest Kamailio release i.e 5.4 on our Host from their official GitHub repository. It is possible that a newer version is released when you are installing. You can look at their official website for the latest version and change the branch accordingly.
cd /usr/src && git clone https://github.com/kamailio/kamailio.git -b 5.4
Switch to the kamailio directory and we will be good to go.
Step 3: Configuring and Compiling
Now since all the dependencies of Kamailio server and it’s modules has been installed, we can now configure it . First step is to generate build configs. Since we also require to compile the module for MySQL database, we will add the following argument as well. If you want to enable the support of other modules like radius, cgrates etc, you have to install the dependencies first for those modules and then add those in make command.
make include_modules="db_mysql tls" cfg
Now we will compile and install Kamailio 5 on Debian 10 alongside the modules selected.
make all make install
After the successful compilation and installation of kamailio on debian 10. All the binaries and executable scripts can be found in /usr/local/sbin directory.
Step 4: Database Configuration
In step 1, we installed MariaDB with other dependencies. Now we will use the provided database setup script to create kamailio database along with it’s tables. First edit the kamctlrc file and set the DBENGINE to MySQL. Also, don’t forget to change the default password for users in the same file.
Once we are done with updating the kamctlrc file, we can execute the script to create the required database. For the purpose of this tutorial we used utf32 as the character set for our database.
The script will also create two users –
- kamailio – A user to manage the kamailio database. The default password is kamailiorw
- kamailioro – A user with permissions to only read the kamailio database. The default password is kamailioro.
Step 5: Miscellaneous
To run Kamailio, we are provided with two methods. Init.d script and systemd. For this tutorial we will use the systemd method. To enable it we will run the following make command, make sure you are inside /usr/src/kamailio directory before executing this command.
First we will run the daemon reload command to reload all the units.
Now we can simply use the following commands to run/stop/enable the Kamailio service.
systemctl start kamailio systemctl stop kamailio systemctl enable kamailio
Now we can check the using the netstat utility if our Kamailio is listening on port 5060.
As you can see in the above image, Kamailio is listening on port 5060. With this we have Kamailio 5 up and running on Debian 10
Thanks for reading, if you face any issue during the installation you can use the comments section below and consider subscribing to our newsletter.