freeswitch与外部网关链接


本文来自csdn lidphttp://blog.csdn.net/perfectpdl,转载注明出处,谢谢



我建了一个 Freeswitch 内核研究 交流群, 45211986, 欢迎加入, 另外,提供基于SIP的通信服务器及客户端解决方案,



注册到freeswitch的客户端可以互相拨打,但是当客户端想通过freeswitch呼叫那些并没有注册到freeswitch上的客户端怎么办?这就需要freeswitch与外部网关链接,比如与另一个sip server或者pstn测的运营商网络链接。Freeswitch引入网关概念来处理与外部链接问题。

Freeswitch中配置的网关在系统启动时注册到另一个sip服务器,类似于sip客户端注册到freeswitch

配置网关通常需要用户名,密码,以及要注册到的sip服务器ip地址。

网关相关配置保存在目录/conf/sofia_profiles/external

/usr/local/freeswitch/conf/sip_profiles/external.xmlfreeswitch作为客户端注册到另一个网关的全局配置,

/usr/local/freeswitch/conf/sip_profiles/external/目录下可以添加网关。

比如添加注册到asterisk得网关,/usr/local/freeswitch/conf/sip_profiles/external/reg_to_asterisk.xml

reg_to_asterisk.xml内容:

<include>

<gatewayname="asterisk">

<paramname="username" value="freeswitch"/>

<paramname="password" value="freeswitch"/>

<paramname="realm" value="demo.asterisk.org"/>

<paramname="proxy" value="demo.asterisk.org"/>

</gateway>

</include>

~

保存,控制台重启 sipprofile

freeswitch@openser-dev>sofia profile external restart

2012-08-18 20:21:47.254868[INFO] mod_enum.c:871 ENUM Reloaded

2012-08-18 20:21:47.254868[INFO] switch_time.c:1163 Timezone reloaded 530 definitions

Reload XML [Success]

restarting: external

freeswitch@openser-dev>2012-08-18 20:21:47.295211 [NOTICE] sofia.c:2500 Waiting for worker thread

2012-08-18 20:21:47.956692[NOTICE] sofia_glue.c:5707 deleted gateway example.com from profile external

2012-08-18 20:21:47.956692[NOTICE] sofia.c:5202 Started Profile external [sofia_reg_external]

2012-08-18 20:21:47.984023[NOTICE] sofia_reg.c:2944 Added gateway 'asterisk' to profile 'external'

2012-08-18 20:21:47.984023[NOTICE] sofia_reg.c:2944 Added gateway 'example.com' to profile 'external'

2012-08-18 20:21:49.975233[NOTICE] sofia_reg.c:415 Registering asterisk

freeswitch@openser-dev>

freeswitch@openser-dev>

查看注册状态

freeswitch@internal> sofiastatus

Name TypeData State

=================================================================================================

internal-ipv6 profilesip:mod_sofia@[::1]:5060RUNNING (0)

internal profilesip:mod_sofia@192.168.16.111:5060 RUNNING (0)

external profilesip:mod_sofia@192.168.16.111:5080RUNNING (0)

external::example.com gatewaysip:joeuser@example.com NOREG

external::asterisk gatewaysip:freeswitch@demo.asterisk.orgTRYING (retry: NEVER)

192.168.16.111 aliasinternal ALIASED

=================================================================================================

3 profiles 1 alias

a.通过网关呼出去

需要修改dialplan,conf/dialplan/default/目录下添加 route_to_asterisk.xml

<include>

<extension name="Dial Out asteriskGateway">

<condition field="destination_number"expression="^9(11)$">

<actionapplication="bridge"data="sofia/gateway/asterisk/$1"/>

</condition>

</extension>

</include>

Fs_cli 执行 reloadxml,客户端呼叫 911,呼叫会路由到asterisk网关上。

b.接收网关送过来的呼叫

通常,对于那些未经认证的呼叫,freeswitch认为是不安全的,包括网关送过来的呼叫,freeswitch会把这类呼叫路由到publicdialplan context中。

/usr/local/freeswitch/conf/dialplan/public.xml为此类呼叫的dialplan,可以在

/usr/local/freeswitch/conf/dialplan/public/目录添加对应网关送过来的dialplan

如:

Vim /usr/local/freeswitch/conf/dialplan/public/asterisk.xml

<include>

<extensionname="asterisk-inbound">

<condition field="destination_number"

expression="^(freeswitch)$">

<actionapplication="set" data="domain_name=$${domain}"/>

<actionapplication="transfer" data="1000 XML default"/>

</condition>

</extension>

</include>

asterisk送过来的被叫号码为freeswitch注册到asterisk上的用户号时,freeswitch转移到其用户1000

3)不需要手动配置网关,但与外部链接

如果外部网关需要diguest认证,则需要在freeswitch上配置网关,如果外部网关并不需要digesut认证,则不需要再freeswitch上手动配置(2)中的过程,有一些网关通过ip验证,这种方式相对更简单,但不如(2)中的安全。

比如default.xmldialplan中的

<actionapplication="bridge"data="sofia/${use_profile}/$1@conference.freeswitch.org"/>

即通过 internalsip profile送到freeswitch.org的网关上。


欢迎补充:)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值