开源的SIP服务器,Kamailio 3.3.0 发布

openkk 10年前
   <div id="p_fullcontent" class="detail">     <p><a href="/misc/goto?guid=4958194607497661967" target="_blank">Kamailio</a>是一个开源的SIP服务器,原名OpenSER<span style="color:#436976;"> </span></p>     <p><span style="color:#436976;">Kamailio</span> 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.</p>     <p>On Nov 04, 2008, <span style="color:#436976;">Kamailio</span> and <span style="color:#436976;">SIP Express Router</span> have started the <span style="color:#436976;">SIP Router Project</span>. <br /> <br /> Web links</p>     <ul>      <li>Home page with new project name: <span style="color:#436976;">http://www.kamailio.org</span> </li>      <li>Home page with old project name: <span style="color:#436976;">http://www.openser-project.org</span> </li>      <li>SourceForge.net Project page: <span style="color:#436976;">http://sourceforge.net/projects/openser/</span></li>     </ul>     <p>Features</p>     <ul>      <li>SIP proxy/registrar/redirect server (<span style="color:#436976;">RFC3261</span>, <span style="color:#436976;">RFC3263</span>) </li>      <li>UDP/TCP/TLS/SCTP support </li>      <li>Transactional stateful proxy </li>      <li>Modular architecture </li>      <li>Programmable configuration file </li>      <li>ENUM support </li>      <li>Call Processing Language (CPL) </li>      <li>Gateway to sms or xmpp </li>      <li>Authentication, authorization and accounting via Radius or database </li>      <li>NAT traversal system </li>      <li>Least cost routing </li>      <li>Load balancing </li>      <li>Carrier routing </li>      <li>Multiple database backends: MySQL, Postgres, Oracle, BDB or flat files </li>      <li>SIMPLE Presence Server (IETF SIMPLE extensions - rich presence) </li>      <li>Dialog Info Presence - SLA/BLA </li>      <li>XCAP and RLS </li>      <li>Presence User Agent </li>      <li>Dialog Stateful Proxy </li>      <li>Instant Messaging       <ul>        <li>Offline message storage </li>        <li>Instant messaging conferencing </li>       </ul> </li>      <li>SNMP support </li>      <li>Perl Programming Interface </li>      <li>Java SIP Servlet Application server </li>      <li>Over 80 modules (extensions) </li>     </ul>     <p>Documentation</p>     <ul>      <li>Main Documentation Page - <span style="color:#436976;">http://www.kamailio.org/docs/</span> </li>      <li>Dokuwiki Page - <span style="color:#436976;">http://www.kamailio.org/dokuwiki/</span></li>     </ul>     <p>我们使用Kamailio主要用在SIP dispatcher server,即SIP redirect server<br /> 安装及配置手册如下<br /> <br /> <strong>一.安装</strong><br /> 1.依赖包:<br /> libmysqlclient & libz (zlib) :mysql DB support (the db_mysql module) Shared libraries</p>     <p>                        MySQL-shared-5.1.32-0.glibc23.i386.rpm</p>     <p>                        MySQL-devel-community-5.1.32-0.rhel5.i386.rpm</p>     <p><br /> libxml2:cpl-c (Call Processing Language) or the presence modules (presence and pua*)<br /> libperl:perl scripting from you config file (perl module)<br /> 2.源代码安装<br /> make,make modules,make install<br /> 或者make all,make install<br /> 参考:<br /> 3.启动:kamctl start<br /> 4.重启:kamctl restart<br /> 5.监控服务状态:kamctl moni<br /> 6.MySQL配置:<br /> 1)安装:<br /> edit Makefile.var files to include the MySQL module<br /> vim Makefile.vars<br /> Uncomment the next line in the file: <br /> MODS_MYSQL=on<br /> cp /usr/local/lib/mysql/libmysqlclient.so.16 /usr/lib<br /> <br /> Edit now /usr/local/etc/kamailio/kamctlrc and add: <br /> DBENGINE=MYSQL<br /> SIP_DOMAIN=pryko.com<br /> 6.1 创建数据库:kamdbctl create<br /> 6.2管理员登录:user 'admin' with password ' openserrw '<br /> 6.3 添加用户:kamctl add <name> <password> <email><br /> 6.4 默认值:database url, users and passwords<br />   - DEFAULT_DB_URL="mysql://opensips:opensipsrw@localhost/opensips"<br />   - r/w user: openser; passwd: openserrw<br />   - r/o user: openserro; passwd: openserro<br /> <br /> <strong>二.配置<br /> </strong>1.配置文件 kamailio.cfg<br /> /usr/local/etc/kamailio/kamailio.cfg<br /> 2.配置文件 kamctlrc<br /> /usr/local/etc/kamailio/kamctlrc<br /> <br /> <strong>三.脚本</strong><br /> 参考文档:<br /> Kamailio Wiki<br /> <span style="color:#336699;">http://www.kamailio.com/dokuwiki</span><br /> Cookbooks and Reference<br /> <span style="color:#336699;">http://www.kamailio.com/dokuwiki/doku.php/core-cookbook:1.5.x</span><br /> Kamalio 1.5.x Module Functions Index<br /> <span style="color:#336699;">http://www.kamailio.com/dokuwiki/doku.php/modules:1.5.x:index-functions</span><br /> <br /> <br /> <strong>四.负载均衡Load Balancing<br /> </strong>参考:<span style="color:#336699;">http://www.kamailio.org/dokuwiki/doku.php/asterisk:load-balancing-and-ha</span><br /> 4.1配置文件 kamailio.cfg<br /> loadmodule("dispatcher.so")<br /> modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")<br /> modparam("dispatcher", "force_dst", 1)<br /> 4.2 ---dispatcher.list----文件<br /> # group sip addresses of your * units<br /> 1 sip:221.5.152.171:5060<br /> 1 sip:221.5.152.170:5060<br /> 4.3 kamctl命令:kamctl dispatcher show<br /> -- command 'dispatcher' - manage dispatcher<br />   * Examples:  dispatcher addgw 1 sip:1.2.3.1:5050 1 'outbound gateway'<br />   *            dispatcher addgw 2 sip:1.2.3.4:5050 3 ''<br />   *            dispatcher rmgw 4<br /> dispatcher show ..................... show dispatcher gateways<br /> dispatcher reload ................... reload dispatcher gateways<br /> dispatcher dump ..................... show in memory dispatcher gateways<br /> dispatcher addgw <setid> <destination> <flags> <description><br />             .......................... add gateway<br /> dispatcher rmgw <id> ................ delete gateway<br /> <br /> 查看载入的配置:kamctl dispatcher dump<br /> 修改后重新载入配置:kamctl dispatcher reload</p>     <p> </p>     <p>如需使用,需安装MySQL-client-community-5.1.32-0.rhel5.i386.rpm<br /> 否则报错:ERROR: This command requires a database engine - none was loaded</p>     <p><br /> <br /> <strong>五.与Asterisk对接负载均衡<br /> </strong>注意事项:sip.conf<br /> 注释如下行<br /> ;canreinvite=no ; Asterisk by default tries to redirect<br /> <br /> Asterisk#1  10.10.10.56<br /> 配置sip.conf<br /> [5000]<br /> type=friend<br /> ;username=5000<br /> secret=5000_phone2<br /> callerid=5000<br /> qualify=yes ; Qualify peer is no more than 2000 ms away<br /> nat=no ; This phone is natted<br /> host=dynamic ; This device registers with us<br /> <strong>;canreinvite=no ; Asterisk by default tries to redirect</strong><br /> 配置extension.conf<br /> [default]<br /> exten => 6000,1,Dial(<span style="color:#336699;">SIP/6000@10.10.10.57,60</span>)<br /> exten => 5000,1,Dial(SIP/5000,60)<br /> <br /> Asterisk#2  10.10.10.57<br /> 配置sip.conf<br /> [6000]<br /> type=friend<br /> ;username=6000<br /> secret=6000_phone2<br /> callerid=6000<br /> qualify=yes ; Qualify peer is no more than 2000 ms away<br /> nat=no ; This phone is natted<br /> host=dynamic ; This device registers with us<br /> <strong>;canreinvite=no ; Asterisk by default tries to redirect</strong><br /> 配置extension.conf<br /> [default]<br /> exten => 6000,1,Dial(SIP/6000,60)<br /> exten => 5000,1,Dial(<span style="color:#336699;">SIP/5000@10.10.10.136,60</span>)<br /> <br /> Kamailio 10.10.10.136<br /> 配置kamailio.cfg<br /> …<br /> loadmodule "dispatcher.so"<br /> modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")<br /> …<br /> route{<br /> if ( !mf_process_maxfwd_header("10") )<br /> {<br />   sl_send_reply("483","To Many Hops");<br />   drop();<br /> };<br /> ds_select_dst("1", "0"); <br /> forward();<br /> }<br /> 配置dispatcher.list<br /> # line format<br /> # setit(integer) destination(sip uri) flags (integer, optional) <br /> 1 sip:10.10.10.56:5060<br /> <br /> <strong>测试</strong>:<br /> 登录10.10.10.57上的6000,登录10.10.10.56上的5000<br /> 从6000呼叫5000,会呼叫10.10.10.136上的5000,10.136重定向到10.56<br /> <br /> <strong>六.按号码段重定向网关</strong><br /> 配置kamailio.cfg<br /> 使用正则表达式<br /> route{<br />         if (!mf_process_maxfwd_header("10")) {<br />                 sl_send_reply("483","Too Many Hops");<br />                 exit;<br />         }<br /> if (uri=~"^sip:5[0-9]+@10.10.10.136$") {<br />   if (is_method("INVITE")) {<br />   ds_select_dst("1", "0");<br />   forward();<br />   exit;<br />   }<br /> }<br /> if (uri=~"^sip:8[0-9]+@10.10.10.136$") {<br />   if (is_method("INVITE")) {<br />   ds_select_dst("2", "0");<br />   forward();<br />   exit;<br />   }<br /> }<br /> sl_send_reply("404","Not here");<br /> exit;<br /> }<br /> 配置dispatcher.list<br /> # line format<br /> # setit(integer) destination(sip uri) flags (integer, optional) <br /> 1 sip:10.10.10.56:5060 #1<br /> 2 sip:10.10.10.54:5060<br /> <br /> <strong>测试</strong>:<br /> 登录10.10.10.57上的6000,登录10.10.10.56上的5000<br /> 从6000呼叫5000,会呼叫10.10.10.136上的5000,10.136重定向到10.56<br /> 从6000呼叫8002,会呼叫10.10.10.136上的8002,10.136重定向到10.54</p>    </div>    <p><br /> <span style="font-weight:bold;">Kamailio 3.3.0 是一个主要的版本,包含众多新特性,包括通用数据库集群,可选的 Cassandra 后端,SIP Outbound and GRUU, MSRP relaying, detection of broken active calls 以及一个嵌入式的 C# 解释器。</span></p>    <br />