This article will provide step-by-step instructions on how to install Kamailio 5.2.x on Debian using apt packages. This article assumes you have a fresh install of Debian 9.x.
Add Kamailio GPG Key
wget -O- https://deb.kamailio.org/kamailiodebkey.gpg | sudo apt-key add -
Add Kamailio 5.2 repo
Add the following lines to the file
deb http://deb.kamailio.org/kamailio52 stretch main
deb-src http://deb.kamailio.org/kamailio52 stretch main
Update the apt package manager so that it’s aware of the new repository.
You can look at the kamailio packages in the apt repository by typing:
apt search kam
apt install kamailio kamailio-mysql-module
Set Kamailio to Start at Boot
systemctl enable kamailio
We will use MariaDB for the Kamailio database engine. Note, Kamailio has support for a number of database backends. But, we are going to use MariaDB
apt install mysql-server
Set MySQL to Start at Boot
systemctl enable mariadb
systemctl start mariadb
Configure Kamailio to use MariaDB
By default, Kamailio does not use MySQL. To change this we need to edit one of Kamailio’s configuration files.
Uncomment the DBENGINE parameter by removing the pound symbol and make sure the value equals MYSQL. The parameter should look like this afterwards:
Uncomment and setup the Database Read/Write and Database Read/Only fields. You can just use the default values for right now and you can change them at a later time.
## database read/write user
## password for database read/write user
## database read only user
## password for database read only user
Create the Kamailio Database Schema
The command will create all the users and tables needed by Kamailio. You will be prompted to put in the MySQL root password that you created in the install MySQL section of this document. You will be asked if you want to install different tables – just say “yes” to all the questions.
Below are all the prompts you will be presented:
MySQL password for root: ''
Install presence related tables? (y/n): y
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist htable purple uac pipelimit mtree sca mohqueue rtpproxy?
Install tables for uid_auth_db uid_avp_db uid_domain uid_gflags uid_uri_db? (y/n): y
The following MySQL users and passwords are created (please change these in a production environment).
kamailio - (With default password 'kamailiorw') - user which has full access rights to 'kamailio' database.
kamailioro - (with default password 'kamailioro') - user which has read-only access rights to 'kamailio' database.
Enable MariaDB module and auth modules in the Kamailio Configuration
Add the following after #!KAMAILIO
Update the DBURL line to match the username and password you set in /etc/kamailio/kamctlrc earlier
The line looks like this by default:
#!define DBURL "mysql://kamailio:kamailioro@localhost/kamailio
If you changed the username and password then the new user name and password would look like this
#!define DBURL "mysql://new_username:new_password@localhost/kamailio
The new_username and new_password fields would be replaced with the values you entered in the /etc/kamailio/kamctlrc file.
Start the Kamailio Server
service start kamailio
Note, the startup options for Kamailio is located at /etc/default/kamailio
In order to test that Kamailio is working correctly, I’m going to create a SIP user account and register that account using a softphone such as X-Lite, Linphone, or Zoiper
Create SIP User Accounts
The following command will create a new SIP User. Note, that the domain portion has to be specified unless you export the SIP_DOMAIN environment variable:
kamctl add extension@domain extension password
Here is what I created:
kamctl add firstname.lastname@example.org opensourceisneat
Registering a SIP Softphone
Configure whichever softphone you choose with the following options:
User ID: 1001
Once you are registered, you can view all the registered extensions in kamailio with the following command:
kamctl ul show
You will get something like this:
Domain:: location table=1024 records=1 max_slot=1
AOR:: 1001 Contact:: sip:email@example.com:40587;
rinstance=636c6f6dedce9a2b;transport=UDP Q= Expires:: 3559
User-agent:: Z 3.3.21937 r21903
State:: CS_NEW Flags:: 0 Cflag:: 0
Socket:: udp:220.127.116.11:5060 Methods:: 5087
Ruid:: uloc-5a2f0176-36a3-1 Reg-Id:: 0
Make a Test Call
You can call yourself by entering 1001 into your softphone. If it rings then you have a basic Kamailio server installed and ready to be configured to provide load balancing, failover, accounting, etc. As an exercise, you should create another SIP user account and register that user using another softphone and try calling between the two SIP users.