Kamailio Quick Install Guide for v4.4

Kamailio 4.4 on CentOS 6.

Are you looking for the CentOS 7.x version?  It can be found here

Setup YUM Repository

  1. Install wget so we can pull down the rpm.
yum install wget
  1. Let’s download the yum repo file for our Cent OS version.
cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/home:/kamailio:/v4.4.x-rpms/CentOS_6/home:kamailio:v4.4.x-rpms.repo
  1. Update system so yum is aware of the new repository.
yum update
  1. You can look at the kamailio packages in the YUM repository by typing:
yum search kam

Install Kamailio and Required Database Modules

  1. Install the following packages from the new repo.
yum install -y kamailio kamailio-mysql kamailio-debuginfo kamailio-unixodbc kamailio-utils gdb
  1. Set kamailio to start at boot.
chkconfig kamailio on
  1. The Kamailio configuration files will be owned by the root user, rather than the kamailio user created by the Kamailio package. We will need to change the ownership of these files.
chown kamailio:kamailio /etc/default/kamailio
chown -R kamailio:kamailio /etc/kamailio/
chown -R kamailio:kamailio /var/run/kamailio

Install MySQL

  1. Since we plan on using MySQL, we will need to instal the MySQL server as well as the client.
yum install -y mysql-server mysql
  1. Next we need to start up MySQL:
service mysqld start
  1. And enable mysqld at boot.
chkconfig mysqld on
  1. Now we can set a root password for mysql:

You can hit yes to all the options. There is no root password as of yet, so the first question will be blank. Be sure to use a secure unique password for your root user.

[root@localhost yum.repos.d]# sudo /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Configure Kamailio to use MySQL

  • By default, Kamailio does not use MySQL. To change this we need to edit one of Kamailio’s configuration files.
vi /etc/kamailio/kamctlrc
  1. Uncomment the DBENGINE parameter by removing the pound symbol and make sure the value equals MYSQL. The parameter should look like this afterwards:
DBENGINE=MYSQL
  1. To have the kamdbctl command create the mysql database with the correct permissions, we will want to set the databaseusers and passwords in kamctlrc
## database read/write user
DBRWUSER="kamailio"

## password for database read/write user
DBRWPW="kamailiorw"

## database read only user
DBROUSER="kamailioro"

## password for database read only user
DBROPW="kamailioro"

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.
/usr/sbin/kamdbctl create
  • Below are all the prompts you will be presented:
MySQL password for root: ''
Install presence related tables? (y/n):
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist htable purple uac pipelimit mtree sca mohqueue rtpproxy?
(y/n):
Install tables for uid_auth_db uid_avp_db uid_domain uid_gflags uid_uri_db? (y/n):
  • 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 the mysql and auth modules.

Add the following to the beginning of the kamailio.cfg after #!KAMAILIO

#!define WITH_MYSQL
#!define WITH_AUTH

Update the DBURL line to match the username and password you set in kamctlrc before running kamdbctl

#!define DBURL "mysql://kamailio:kamailioro@localhost/kamailio"

Start the Kamailio Server

service kamailio start

We also need to edit /etc/default/kamailio to notify Kamailio that is is configured and ready to go.

Uncomment the following:

RUN_KAMAILIO=yes

Test 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 hte domain portion has to be specified unltess you export hte SIP_DOMAIN environment variable.
kamctl add <extension@domain>
  • Here is what I created
kamctl add 1001@dopensource.com opensourceisneat

Registering a SIP Softphone

  • configure whichever softphone you choose with the following options:
User ID: 1001
Domain:
Password: opensourceisneat
  • Once you are registered, you can view all the registered extensions in kamailio with the following command.
kamctl ul show

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.

References

  • Install And Maintain Kamailio v4.1.x From GIT – http://www.kamailio.org/wiki/install/4.1.x/git

16 thoughts on “Kamailio Quick Install Guide for v4.4

  1. I am getting a problem :
    ERROR: Error opening Kamailio’s FIFO /var/run/kamailio/kamailio_fifo
    ERROR: Make sure you have the line ‘modparam(“mi_fifo”, “fifo_name”, “/var/run/kamailio/kamailio_fifo”)’ in your config
    ERROR: and also have loaded the mi_fifo module.the

    The kamailio_fifo does not exist
    I can’t find mi_fifo module

    Thanks

    1. Hey Eduardo,

      Thanks for pointing out this issue. I think this is caused by the incorrect permissions on the kamailio configuration files. After installing kamailio from the opensuse repo, /etc/kamailio/* and /etc/default/kamailio is owned by root, but the init.d script is starting kamailio as the kamailio user. I fixed the issue with the following commands.

      chown kamailio:kamailio /etc/default/kamailio
      chown -R kamailio:kamailio /etc/kamailio

      Let me know if this works on your system as well!

  2. I configured kamaiio as per your documentation bt at last there is error when i run command kamctl ul show

    ERROR: Error opening Kamailio’s FIFO /tmp/kamailio_fifo
    ERROR: Make sure you have the line ‘modparam(“mi_fifo”, “fifo_name”,
    “/tmp/kamailio_fifo”)’ in your config
    ERROR: and also have loaded the mi_fifo module.
    kindly help me

  3. I have already done this during installation but There is again this issue after doing this kindly help other solution

  4. [root@kamailio ~]# chown kamailio:kamailio /etc/default/kamailio
    [root@kamailio ~]# chown -R kamailio:kamailio /etc/kamailio
    [root@kamailio ~]# kamctl ul show
    ERROR: Error opening Kamailio’s FIFO /var/run/kamailio/kamailio_fifo
    ERROR: Make sure you have the line ‘modparam(“mi_fifo”, “fifo_name”, “/var/run/kamailio/kamailio_fifo”)’ in your config
    ERROR: and also have loaded the mi_fifo module.

  5. After you’ve changed the database password for users ‘kamailio’ and ‘kamailioro’ you need to edit the /etc/kamailio/kamctlrc file and update ‘DBRWPW’ and ‘DBROPW’ with the passwords.

  6. ERROR: Error opening Kamailio’s FIFO /var/run/kamailio/kamailio_fifo
    ERROR: Make sure you have the line ‘modparam(“mi_fifo”, “fifo_name”, “/var/run/kamailio/kamailio_fifo”)’ in your config
    ERROR: and also have loaded the mi_fifo module.the

    For this error follow the below steps

    Enable the below line in “/etc/kamailio/kamctlrc”

    FIFOPATH=”/var/run/kamailio/kamailio_fifo”

    And also enable below line in “/etc/kamailio/kamailio.cfg”

    modparam(“mi_fifo”, “fifo_name”, “/var/run/kamailio/kamailio_fifo”)

    Then restart the kamailio service

  7. I have the same problem, configured everything as recommended. It works only with sudo …

    ubuntu@ip-172-31-32-10:/etc/kamailio$ kamctl ul show
    ERROR: Error opening Kamailio’s FIFO /var/run/kamailio/kamailio_fifo
    ERROR: Make sure you have the line ‘modparam(“mi_fifo”, “fifo_name”, “/var/run/kamailio/kamailio_fifo”)’ in your config
    ERROR: and also have loaded the mi_fifo module.
    ubuntu@ip-172-31-32-10:/etc/kamailio$ sudo kamctl ul show
    Domain:: location table=1024 records=0 max_slot=0

    This works without sudo:
    ubuntu@ip-172-31-32-10:/etc/kamailio$ kamctl db show subscriber

    Any hints?
    Thanks Norpois

  8. I notived that after using your guide for install on a CentOS 7 box I had to modify the user of the /var/run/kamailio directory to get things to be happy

    chown -R kamailio:kamailio /var/run/kamailio

  9. Well I installed Kamailio this way and created two users. But users not getting registered in soft phone, please help me on this.
    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *