Kamailio is an open-source SIP server, formerly known as openser.
Kamailio is an open source, gpl2, SIP Server Routing platform. It is written in C for Linux/Unix plaforms and focuses on performance, flexibility and security.
On Nov 04,200 8, kamailio and SIP Express Router have started the SIP router project.
Web Links
- Home page with new Project name: http://www.kamailio.org
- Home page with old Project name: http://www.openser-project.org
- Sourceforge.net project page: http://sourceforge.net/projects/openser/
Features
- SIP proxy/registrar/redirect server (rfc3261, rfc3263)
- UDP/tcp/tls/sctp support
- Transactional stateful proxy
- Modular architecture
- Programmable configuration file
- Enum support
- Call processing language (CPL)
- Gateway to SMS or XMPP
- Authentication, authorization and accounting via radius or database
- NAT traversal System
- Least Cost Routing
- Load Balancing
- Carrier Routing
- Multiple database backends: MySQL, Postgres, Oracle, bdb or flat files
- Simple Presence Server (IETF simple extensions-rich presence)
- Dialog info presence-SLA/Bla
- Xcap and RLS
- Presence User Agent
- Dialog stateful proxy
- Instant Messaging
- Offline message storage
- Instant Messaging conferencing
- SNMP support
- Perl programming interface
- Java sip servlet Application Server
- Over 80 modules (extensions)
Documentation
- Main documentation page-http://www.kamailio.org/docs/
- Dokuwiki page-http://www.kamailio.org/dokuwiki/
We use kamailio mainly for the SIP dispatcher server, that is, the SIP redirect server.
The installation and configuration manual is as follows:
1. Installation
1. Dependency package:
Libmysqlclient & libz (zlib): MySQL db support (the db_mysql module) shared libraries
MySQL-shared-5.1.32-0.glibc23.i386.rpm
MySQL-devel-community-5.1.32-0.rhel5.i386.rpm
Libxml2: CPL-C (call processing language) or the presence modules (presence and PUA *)
Libperl: perl scripting from you config file (Perl module)
2. Source Code Installation
Make, make modules, make install
Or make all, make install
Refer:
3. Start: kamctl start
4. Restart: kamctl restart
5. Monitoring Service Status: kamctl Moni
6. MySQL Configuration:
1) installation:
Edit makefile. var files to include the MySQL Module
Vim makefile. vars
Uncomment the next line in the file:
Mods_mysql = on
CP/usr/local/lib/MySQL/libmysqlclient. so.16/usr/lib
Edit now/usr/local/etc/kamailio/kamctlrc and add:
Dbengine = MySQL
Sip_domain = pryko.com
6.1 create a database: kamdbctl create
6.2 Administrator Logon: User 'admin' with password 'openserrw'
6.3 Add a user: kamctl add <Name> <password> <email>
6.4 default value: Database URL, users and passwords
-Default_db_url = "MYSQL: // opensips: opensipsrw @ localhost/opensips"
-R/W User: openser; passwd: openserrw
-R/o User: openserro; passwd: openserro
Ii. Configuration
1. configuration file kamailio. cfg
/Usr/local/etc/kamailio. cfg
2. configuration file kamctlrc
/Usr/local/etc/kamailio/kamctlrc
Iii. Script
Reference:
Kamailio Wiki
Http://www.kamailio.com/dokuwiki
Cookbooks and reference
Http://www.kamailio.com/dokuwiki/doku.php/core-cookbook:1.5.x
Kamalio 1.5.x module functions Index
Http://www.kamailio.com/dokuwiki/doku.php/modules:1.5.x:index-functions
4. Load Balancing
Reference: http://www.kamailio.org/dokuwiki/doku.php/asterisk:load-balancing-and-ha
4.1 configuration file kamailio. cfg
Loadmodule ("dispatcher. So ")
Modparam ("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher. List ")
Modparam ("dispatcher", "force_dst", 1)
4.2 --- dispatcher. List ---- File
# Group SIP addresses of your * Units
1 SIP: 221.5.152.171: 5060
1. Sip: 221.5.152.170: 5060
4.3 kamctl command: kamctl dispatcher show
-- Command 'dispatcher '-manage dispatcher
* Examples: Dispatcher addgw 1 SIP: 1.2.3.1: 5050 1 'outbound gateway'
* Dispatcher addgw 2 SIP: 1.2.3.4: 5050 3''
* Dispatcher rmgw 4
Dispatcher show ...... show dispatcher always
Dispatcher reload...
Dispatcher dump ...... show in memory dispatcher always
Dispatcher addgw <setid> <destination> <flags> <description>
.................. Add Gateway
Dispatcher rmgw <ID> ...... Delete Gateway
View the loaded configuration: kamctl dispatcher dump
After modification, reload the configuration: kamctl dispatcher reload
If you need to use, need to install MySQL-client-community-5.1.32-0.rhel5.i386.rpm
Otherwise, an error occurs: Error: This Command requires a database engine-none was loaded.
V. Connect to Server Load balancer with asterisk
Note: sip. conf
Comment out the following lines
; Canreinvite = no; asterisk by default tries to redirect
Asterisk #1 10.10.10.56
Configure sip. conf
[5000]
Type = friend
Username = 5000
Secret = 5000_phone2
Callerid = 5000.
Qualify = yes; qualify peer is no more than 2000 MS away
Nat = no; this phone is natted
Host = dynamic; this device registers with us
; Canreinvite = no; asterisk by default tries to redirect
Configure extension. conf
[Default]
Exten => 6000,1, dial (Sip/6000@10.10.10.57, 60)
Exten =>, 1, dial (Sip/, 60)
Asterisk #2 10.10.10.57
Configure sip. conf
[6000]
Type = friend
Username = 6000
Secret = 6000_phone2
Callerid = 6000.
Qualify = yes; qualify peer is no more than 2000 MS away
Nat = no; this phone is natted
Host = dynamic; this device registers with us
; Canreinvite = no; asterisk by default tries to redirect
Configure extension. conf
[Default]
Exten => 6000,1, dial (Sip/6000,60)
Exten => 5000,1, dial (Sip/5000@10.10.10.136, 60)
Kamailio 10.10.136
Configure kamailio. cfg
...
Loadmodule "dispatcher. So"
Modparam ("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher. List ")
...
Route {
If (! Mf_process_maxfwd_header ("10 "))
{
Sl_send_reply ("483", "to handle hops ");
Drop ();
};
Ds_select_dst ("1", "0 ");
Forward ();
}
Configure dispatcher. List
# Line format
# Setit (integer) destination (sip uri) flags (integer, optional)
1 SIP: 10.10.10.56: 5060
Test:
Log on to 6000 on 10.10.10.57 and 5000 on 10.10.56.
From 6000 to 5000, 5000 is redirected to 10.136 by calling 10.56 on 10.10.136.
6. Redirect the Gateway by number segment
Configure kamailio. cfg
Use Regular Expressions
Route {
If (! Mf_process_maxfwd_header ("10 ")){
Sl_send_reply ("483", "Too route hops ");
Exit;
}
If (uri = ~ "^ SIP: 5 [0-9] + @ 10.10.10.136 $ "){
If (is_method ("invite ")){
Ds_select_dst ("1", "0 ");
Forward ();
Exit;
}
}
If (uri = ~ "^ SIP: 8 [0-9] + @ 10.10.10.136 $ "){
If (is_method ("invite ")){
Ds_select_dst ("2", "0 ");
Forward ();
Exit;
}
}
Sl_send_reply ("404", "not here ");
Exit;
}
Configure dispatcher. List
# Line format
# Setit (integer) destination (sip uri) flags (integer, optional)
1 SIP: 10.10.10.56: 5060 #1
2 SIP: 10.10.10.54: 5060
Test:
Log on to 6000 on 10.10.10.57 and 5000 on 10.10.56.
From 6000 to 5000, 5000 is redirected to 10.136 by calling 10.56 on 10.10.136.
From 6000 to 8002, 8002 is redirected to 10.136 by calling 10.54 on 10.10.136.