Kamailio 开源 SIP 服务器

程序名称:Kamailio

授权协议: GPLv2

操作系统: Linux

开发语言: C/C++

Kamailio 介绍

Kamailio是一个开源的SIP服务器,原名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, 2008, Kamailio and SIP Express Router have started the SIP Router
Project.

Kamailio 诞生于 2005 年 7 月,它是从德国 FhG FOKUS 研究所主导的 SIP Express Router(SER)
项目组分裂出来的。新项目建立的目标是创建一个开放的开发环境,以建立一个强大的可扩展的开源 SIP 服务器。Kamailio 是个纯粹的 SIP
服务器,它可以作为 PROXY、注册服务器、重定向服务器,也可作为简单的 PRESENCE 服务器。

Web links

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

我们使用Kamailio主要用在SIP dispatcher server,即SIP redirect server
安装及配置手册如下

一.安装
1.依赖包:
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.源代码安装
make,make modules,make install
或者make all,make install
参考:
3.启动:kamctl start
4.重启:kamctl restart
5.监控服务状态:kamctl moni
6.MySQL配置:
1)安装:
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 创建数据库:kamdbctl create
6.2管理员登录:user ‘admin’ with password ‘ openserrw ‘
6.3 添加用户:kamctl add
6.4 默认值: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

二.配置
1.配置文件 kamailio.cfg
/usr/local/etc/kamailio/kamailio.cfg
2.配置文件 kamctlrc
/usr/local/etc/kamailio/kamctlrc

三.脚本
参考文档:
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

四.负载均衡Load Balancing
参考:http://www.kamailio.org/dokuwiki/doku.php/asterisk:load-balancing-and-ha
4.1配置文件 kamailio.cfg
loadmodule(“dispatcher.so”)
modparam(“dispatcher”, “list_file”, “/usr/local/etc/kamailio/dispatcher.list”)
modparam(“dispatcher”, “force_dst”, 1)
4.2 —dispatcher.list----文件

group sip addresses of your * units

1 sip:221.5.152.171:5060
1 sip:221.5.152.170:5060
4.3 kamctl命令: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 gateways
dispatcher reload ................... reload dispatcher gateways
dispatcher dump ..................... show in memory dispatcher gateways
dispatcher addgw
.......................... add gateway
dispatcher rmgw................ delete gateway

查看载入的配置:kamctl dispatcher dump
修改后重新载入配置:kamctl dispatcher reload

如需使用,需安装MySQL-client-community-5.1.32-0.rhel5.i386.rpm
否则报错:ERROR: This command requires a database engine - none was loaded

五.与Asterisk对接负载均衡
注意事项:sip.conf
注释如下行
;canreinvite=no ; Asterisk by default tries to redirect

Asterisk#1 10.10.10.56
配置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
配置extension.conf
[default]
exten => 6000,1,Dial(SIP/6000@10.10.10.57,60)
exten => 5000,1,Dial(SIP/5000,60)

Asterisk#2 10.10.10.57
配置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
配置extension.conf
[default]
exten => 6000,1,Dial(SIP/6000,60)
exten => 5000,1,Dial(SIP/5000@10.10.10.136,60)

Kamailio 10.10.10.136
配置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 Many Hops”);
drop();
};
ds_select_dst(“1”, “0”);
forward();
}
配置dispatcher.list

line format

setit(integer) destination(sip uri) flags (integer, optional)

1 sip:10.10.10.56:5060

测试
登录10.10.10.57上的6000,登录10.10.10.56上的5000
从6000呼叫5000,会呼叫10.10.10.136上的5000,10.136重定向到10.56

六.按号码段重定向网关
配置kamailio.cfg
使用正则表达式
route{
if (!mf_process_maxfwd_header(“10”)) {
sl_send_reply(“483”,”Too Many 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;
}
配置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

测试
登录10.10.10.57上的6000,登录10.10.10.56上的5000
从6000呼叫5000,会呼叫10.10.10.136上的5000,10.136重定向到10.56
从6000呼叫8002,会呼叫10.10.10.136上的8002,10.136重定向到10.54

Kamailio 官网

https://www.kamailio.org/w/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


DEFT(数字证据及取证工具箱)是一份定制的Xubuntu自启动运行Linux光盘发行。它是一份易于使用的系统,包含了最佳的硬件检测,以及一些专用于应急响应和计算机取证的最好的开源应用软件。
DFF (Digital Forensics Framework) 是一个简单但强大的数字取证工作辅助工具,它具有一个灵活的模块系统,具有多种功能,包括:恢复错误或崩溃导致的文件丢失,证据的研究和分析等。DFF提供了一个强大的体系结构和
BackTrack是基于Ubuntu的自启动运行光盘,它包含了一套安全及计算机取证工具。它其实是依靠融合Auditor Security
计算机取证时需要为计算机生成一个位镜像拷贝 , 这需要在系统还在运行的时候,或至少要在系统关闭之前进行。“位镜像拷贝”是指对硬件驱动器上每一位进行拷贝,它不考虑操作系统是如何解析这些位的,所以
CAINE(计算机辅助调查环境)是基于Ubuntu的GNU/Linux自启动运行发行,它作为安全研究部际中心(CRIS)的数字取证项目而创建,并
HackShark Linux是一个基于KDE环境的轻量级的发行版。用于渗透测试、网络取证调查和脆弱性评估。
Autopsy® 是数字取证平台,是TheSleuth Kit® 和其他数字取证工具的图形化界面。它可以用来执法,军事和公司的检察官调查过程,用来检测电脑的情况,甚至可以用来恢复你相机存储卡的照片。
OSX Auditor是一个免费的Mac OS X计算机取证工具,这个工具显示分析内核扩展、用户下载的文件等等,然后是提取用户的隔离文件、访问历史等等,最后就可以确认文件的可信度。
有时候你可曾想过,从一个Email,或者Twitter,或是网站,甚至姓名等等,能找到一个人千丝万缕的联系,并把这些联系整合,利用起
Metabase 是一个简单、开源的方式,通过给公司成员提问,从得到的数据中进行分析、学习。
该项目提供了更强大的取证工具集合,运行于命令行(The Sleuth Kit)或通过浏览器界面(Autopsy
OSXCollector 是 OS X 系统样本采集和分析工具。 采集脚本运行在相关的机器上,输出一个 JSON 文件,描述任务机器的相关情况。OSXCollector 会从 plists,SQLite
SFT (Safari Forensic Tools)包含了一系列的命令行实用工具,用于分析Safari WEB浏览器的一些相关文件。SFT使用Objective-C编写可以在Linux和windows及OSX下编译。另外这个项目的主页还包含了几个
Beagle是一个事件响应和数字取证工具,它将数据源和日志转换为图形。支持的数据源包括FireEye HX分类、Windows
GRR 是 Google 开发的远程现场事件取证系统。GRR 由一个代理(客户端)和服务器端组成,客户端可以部署在一个任务系统中,服务器可以管理客户端,跟客户端进行交互。
FileInfo是一款Ubuntu Linux下的文件信息取证分析工具,它是一个脚本但拥有一个图形界面,FileInfo可以从文件中提取有用的信息用于调查取证。
theHarvester是一款信息收集工具,它可以从不同的公开源中(例如:搜索引擎和PGP key服务器)收集e
MASCHE 全称是 Memory Analysis Suite for Checking the Harmony of Endpoints. 这是 Mozilla 开发的内存分析套件。这项技术能够帮你查看你的服务器里面的存储程序,Masche 作为 Mozilla
Matriux是一款功能齐全的安全工具包(套装),它包含了一系列强大、开源和免费的工具可以用于多种目的,但也不限于此。例如:渗透测试、ethical
伟大的Katana Forensics为我们带来了一款开放源代码的IOS设备取证分析工具 - Lantern Lite。Lantern