16
Kamailio on Docker Stanley Wu (吳建澄) [email protected] Sep. 12, 2015

Kamailio on Docker

Embed Size (px)

Citation preview

Page 1: Kamailio on Docker

Kamailio on Docker

Stanley Wu (吳建澄)

[email protected]

Sep. 12, 2015

Page 2: Kamailio on Docker

Outline

• Introduction to Kamailio

• Make Kamailio as Session Border Controller (SBC) with B2BUA

• How to Configure Kamailio on Docker?

2

Page 3: Kamailio on Docker

Introduction to Kamailio (1/3) • Kamailio History

3 Source: http://www.kamailio.org/w/history/

Page 4: Kamailio on Docker

Introduction to Kamailio (2/3)

• Kamailio is an Open-Source SIP Proxy (not B2BUA)

• Kamailio can be configured as a Session Border Controller (SBC)

– User authentication

– Blacklisting

– Brute-force attack protection

– Strip TLS

4

Page 5: Kamailio on Docker

Introduction to Kamailio (3/3) • Put Kamailio in front of a B2BUA farm(such as

FreeSWITCH), to perform load balancing, failure routing and high availability.

• Containers (such as Docker) make Kamailio easy to prototype and test, but many see them as a way to scale on demand

5 Ref: http://sip-router.org/history/

Page 6: Kamailio on Docker

Make Kamailio as SBC with B2BUA (1/2)

• In this setup, the dialplan is detailed only for inbound to outbound traffic, but it could be easily extended for outbound to inbound traffic (or DID).

• The design is the following:

– FreeSWITCH is configured with an internal and an external profile, each profile listening on a different network interface.

– Kamailio is listening on the loopback interface, and is not used by any other process than FreeSWITCH.

6

Page 7: Kamailio on Docker

Make Kamailio as SBC with B2BUA (2/2)

• Separate the telephony core network from the Internet to keep safety

7

Private Network

Internet Kamailio

IVR (FreeSWITCH)

RTP Gateway (FreeSWITCH)

Database PSTN Gateway (FreeSWITCH)

IM/SMS (Asterisk)

SIP User A SIP User B SIP User C SIP User D

Page 8: Kamailio on Docker

How to Configure Kamailio on Docker?

• Docker Host System Environment – CetOS 6.6 64bit

– 8GB RAM

– 10/100 NIC

– 512GB HardDisk

• Client – Android/iOS Phone with Linphone APP

(Recommend)

– Other SIP phone software

8

Page 9: Kamailio on Docker

How to Configure Kamailio on Docker?

• Install Docker (skip)

• Download the centos basic docker image – $ docker pull delu2000/centos6.6:latest

• Run the centos in a new docker container with port forwarding – $ docker run -it -p 8888:22 -p 5060:5060/udp -p

5060:5060/tcp -p 16384-16394:16384-16394/udp -p 16384-16394:16384-16394/tcp -p 5080:5080/tcp -p 3478-3479:3478-3479/udp -p 7077:7077/udp -p 7077:7077/tcp delu2000/centos6.6:latest /bin/bash

9

Page 10: Kamailio on Docker

How to Configure Kamailio on Docker?

• Prepare to Install Kamailio

– disable selinux

• # setenforce 0

– Install dependency

• # yum -y install gcc gcc-c++ gdb bison openssl-devel libtermcap-devel ncurses-devel doxygen curl-devel make newt-devel mlocate lynx tar wget nmap bzip2 unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel mysql-server flex libxml2 libxml2-devel pcre pcre-devel git which

10

Page 11: Kamailio on Docker

How to Configure Kamailio on Docker? • Install Kamailio by Source code

– Download source code • # mkdir -p /usr/local/src/kamailio-4.0

• # cd /usr/local/src/kamailio-4.0

• # git clone --depth 1 git://git.sip-router.org/sip-router kamailio

• # cd kamailio

• # git checkout -b 4.0 origin/4.0

– Configure make • # make cfg

– Modify modules.lst • # vi modules.lst

• add db_mysql in the section that says include_modules

• include_modules= db_mysql

– Compile source code and install • # make all

• # make install 11

Page 12: Kamailio on Docker

How to Configure Kamailio on Docker?

• Start MySQL – #service mysqld start

– #mysqladmin -u root password <your password>

• 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 /usr/local/etc/kamailio/kamctlrc

– 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

12

Page 13: Kamailio on Docker

How to Configure Kamailio on Docker?

• Create the Kamailio Database Schema

– # /usr/sbin/kamdbctl create (say yes by default)

13

Page 14: Kamailio on Docker

How to Configure Kamailio on Docker?

• Modify the Kamailio config file

– # vi /usr/local/etc/kamailio/kamailio.cfg

– Insert the following after the #!Kamailio line:

• #!define WITH_MYSQL

– mdoify IP #listen=udp:10.0.0.10:5060

• listen=udp:PRIVATE_IP:5060 advertise PUBLIC_IP:5060

• Start the Kamailio Server

– service kamailio start

14

Page 15: Kamailio on Docker

How to Configure Kamailio on Docker?

• Test Kamailio

– Get Kamailio Error Log

• # kamailio -E -e –dd

– Creating SIP User Accounts

• # kamctl add <extension@domain> <password>

• e.g.=> kamctl add [email protected] 1234

– Registering a SIP Softphone

15

User ID: 1006 Domain: <Public_IP address of your Kamailio Server> Password: 1234

Page 16: Kamailio on Docker

Reference

• http://www.kamailio.org

• http://wiki.freeswitch.org/wiki/SBC_Setup

• https://github.com/alezzandro/docker-kamailio

16