转ubuntu--sip服务器openser 的搭建


http://jituo666.blog.163.com/blog/static/294817212010224468542/

ubuntu--sip服务器openser 的搭建  

2010-03-24 16:06:08|  分类: VOIP related |字号 订阅

本文作者:宣寄托

1,搭建sip测试用的环境(ubuntu 9.10/9.04)

sip服务器(proxy):openser,也可以用asterisk但无法支持sipmessge 发送。
sip客户端:linphone (或自写sip测试程序)

2,sip服务器搭建.

采用openser服务器。

2.1
首先安装mysql,可以在终端提示符后运行下列命令:

sudo apt-get install mysql-server
sudo apt-get install mysql-client

一旦安装完成,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:

sudo netstat -tap | grep mysql

当您运行该命令时,您可以看到类似下面的行:

tcp 0 0 localhost.localdomain:mysql *:* LISTEN -

如果服务器不能正常运行,您可以通过下列命令启动它:

sudo /etc/init.d/mysql restart

进入mysql

mysql -uroot -p

(输入mysql的root密码)

配置 MySQL 的管理员密码:

sudo mysqladmin -u root password newpassword

2.2 安装openser

可以到synaptic Package Manager 里面去选择openser的部件安装.包括:

(1)openner1.3.2-3
(2)openner-mysql-module 1.3.2-3


开始配置,首先创建openser所需的数据库及数据表:
sudo gedit /etc/openser/openserctlrc
这个东西会在openserdbctl时使用需要放开注释的项目并配置相应值
DBENGINE=MYSQL
执行如下:

xuanjt@ubuntu:~$ sudo /usr/sbin/openserdbctl create        //一定注意这个在ubuntu下是openserdbctl,在其他版本linux可能会是openser_mysql.sh
ERROR: database engine not specified, please setup on
e in the config script
xuanjt@ubuntu:~$ sudo /usr/sbin/openserdbctl create
MySQL password for root:                                      //这里输入root用户密码
INFO: test server charset
INFO: creating database openser ...
INFO: Core OpenSER tables succesfully created.
Install presence related tables? (y/n): y
INFO: creating presence tables into openser ...
INFO: Presence tables succesfully created.
Install tables for imc cpl siptrace domainpolicy carrierroute? (y/n): y
INFO: creating extra tables into openser ...
INFO: Extra tables succesfully created.

添加用户:

这里需要用到openser数据库的密码,默认是openserrw


例如:

xuanjt@ubuntu:~$ openserctl add 8004 8004 [email protected]
MySQL password for user 'openser@localhost':
new user '8004' added


一次添加:
> openserctl add 8001 1111 [email protected]
~> openserctl add 8002 1111 [email protected]
~> openserctl add 8003 1111 [email protected]

执行命令:openser 如下:


xuanjt@ubuntu:~$ openser
Listening on
             udp: 127.0.0.1 [127.0.0.1]:5060
             udp: 192.168.0.101 [192.168.0.101]:5060
             tcp: 127.0.0.1 [127.0.0.1]:5060
             tcp: 192.168.0.101 [192.168.0.101]:5060
Aliases:
             tcp: ubuntu.local:5060
             tcp: localhost:5060
             udp: ubuntu.local:5060
             udp: localhost:5060



如此就可以测试sip终端功能了。


测试用例:
两个sip终端都用linpone,一个是在ubuntu系统下的linphone(3.1.2在ubuntu9.10下通过source software manager安装),和sipserver即openser在一个物理机器。
另一个是在windows下用linphone 3.2.0(window 版本);
安装后配置:preference->Manage sip Account->Proxy acount

配置完成后启动sipserver即可以互打电话了。……。

可以用wireshark抓包工具观察sip数据包情况,注意区分eth0和lo的去别,一个是局域网,以个是loopback即本机对本机。











//--------------------------------------------------------------附录---------------------------------------------------------------------

 -- command 'start|stop|restart'

 restart ............................ restart OpenSER
 start .............................. start OpenSER
 stop ............................... stop OpenSER

 -- command 'acl' - manage access control lists (acl)

 acl show [<username>] .............. show user membership
 acl grant <username> <group> ....... grant user membership (*)
 acl revoke <username> [<group>] .... grant user membership(s) (*)

 -- command 'lcr' - manage least cost routes (lcr)

   * IP addresses must be entered in dotted quad format e.g. 1.2.3.4 *
   * <uri_scheme> and <transport> must be entered in integer or text,*
   * e.g. transport '2' is identical to transport 'tcp'.             *
   *   scheme: 1=sip, 2=sips;   transport: 1=udp, 2=tcp, 3=tls       *
   * Examples:  lcr addgw_grp usa 1                                  *
   *            lcr addgw level3 1.2.3.4 5080 sip tcp 1              *
   *            lcr addroute +1 '' 1 1                               *
 lcr show .....................................................................
           ............. show routes, gateways and groups
 lcr reload ...................................................................
           ............. reload lcr gateways
 lcr addgw_grp <grp_name> <grp_id> ............................................
           .............. add gateway group, autocreate grp_id if not present .
 lcr rmgw_grp  <grp_id> .......................................................
           ............... delete the gw_grp
 lcr addgw <gw_name> <ip> <port> <scheme> <transport> <grp_id> <prefix> <strip>
           ............... add a gateway with prefix and strip ................
           ................(prefix and strip are optional arguments) ..........
 lcr rmgw  <gw_name> ..........................................................
           ............... delete a gateway
 lcr addroute <prefix> <from> <grp_id> <prio> .................................
           .............. add a route ( use '' to match anything in <from> )
 lcr rmroute  <prefix> <from> <grp_id> <prio> .................................
           .............. delete a route

 -- command 'cr' - manage carrierroute tables

 cr show ........................................................ show tables
 cr reload ...................................................... reload tables
 cr addrt <routing_tree_id> <routing_tree> ...................... add a tree
 cr rmrt  <routing_tree> ........................................ rm a tree
 cr addcarrier <carrier> <scan_prefix> <domain> <rewrite_host> ................
               <prob> <strip> <rewrite_prefix> <rewrite_suffix> ...............
               <comment> ........................................ add a carrier
               (strip, rewrite_prefix, rewrite_suffix and comment are optional
                arguments) ....................................................
 cr rmcarrier  <carrier> <scan_prefix> <domain> ................. rm a carrier

 -- command 'rpid' - manage Remote-Party-ID (RPID)

 rpid add <username> <rpid> ......... add rpid for a user (*)
 rpid rm <username> ................. set rpid to NULL for a user (*)
 rpid show <username> ............... show rpid of a user

 -- command 'add|mail|passwd|rm' - manage subscribers

 add <username> <password> <email> .. add a new subscriber (*)
 passwd <username> <passwd> ......... change user's password (*)
 rm <username> ...................... delete a user (*)
 mail <username> .................... send an email to a user

 -- command 'add|dump|reload|rm|show' - manage trusted

 trusted show ...................... show db content
 trusted dump ...................... show cache content
 trusted reload .................... reload db table into cache
 trusted add <src_ip> <proto> <from_pattern> <tag>
             ....................... add a new entry
             ....................... (from_pattern and tag are optional arguments)
 trusted rm <src_ip> ............... remove all entres for the given src_ip

 -- command 'dispatcher' - manage dispatcher

   * Examples:  dispatcher addgw 1 sip:1.2.3.1:5050 'outbound gateway'
   *            dispatcher addgw 2 sip:1.2.3.4:5050
   *            dispatcher rmgw 4
 dispatcher show ..................... show dispatcher gateways
 dispatcher reload ................... reload dispatcher gateways
 dispatcher dump ..................... show in memory dispatcher gateways
 dispatcher addgw <setid> <destination> <description>
            .......................... add gateway
 dispatcher rmgw <id> ................ delete gateway

 -- command 'cisco_restart' - restart CISCO phone (NOTIFY)

 cisco_restart <uri> ................ restart phone configured for <uri>

 -- command 'on line' - dump on line users from memory

 on line ............................. display on line users

 -- command 'monitor' - show internal status

 monitor ............................ show server's internal status

 -- command 'ping' - ping a SIP URI (OPTIONS)

 ping <uri> ......................... ping <uri> with SIP OPTIONS

 -- command 'ul|alias' - manage user location or aliases

 ul show [<username>]................ show in-RAM on line users
 ul show --brief..................... show in-RAM on line users in short format
 ul rm <username> [<contact URI>].... delete user's usrloc entries
 ul add <username> <uri> ............ introduce a permanent usrloc entry
 ul add <username> <uri> <expires> .. introduce a temporary usrloc entry

 -- command 'fifo'

 fifo ............................... send raw FIFO command

你可能感兴趣的:(转ubuntu--sip服务器openser 的搭建)