99久久亚洲综合精品成人_永久黄网站色视频免费_9I制作厂免费_久久久WWW成人免费毛片_亚洲国产精品一区二区久久_少妇又紧又深又湿又爽视频_成人乱码一区二区三区av_亚洲香蕉视频天天爽_欧美z0z0人禽交_免费人妻无码不卡中文字幕系

內(nèi)容字號:默認大號超大號

段落設置:段首縮進取消段首縮進

字體設置:切換到微軟雅黑切換到宋體






Kamailio(OpenSER)開源SIP服務器-呼叫重定向

時間:2015-03-24 來源:www.www.jjxinkai.com 作者:徐寶國 點擊:

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. 
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/

我們使用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.監(jiān)控服務狀態(tài):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 創(chuàng)建數(shù)據(jù)庫:kamdbctl create
6.2管理員登錄:user 'admin' with password ' openserrw '
6.3 添加用戶:kamctl add <name> <password> <email>
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 <setid> <destination> <flags> <description>
.......................... add gateway
dispatcher rmgw <id> ................ 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
六.按號碼段重定向網(wǎng)關
配置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

 

(中國集群通信網(wǎng) | 責任編輯:陳曉亮)

中國集群通信網(wǎng),國內(nèi)首家集群通信專業(yè)網(wǎng)站。

Copyright © www.jjxinkai.com, All Rights Reserved.   

聯(lián)系我們 聯(lián)系我們 中國集群通信網(wǎng) 對講機學堂 對講機世界