freeswitch與外部網關連結

來源:互聯網
上載者:User


本文來自csdn lidp http://blog.csdn.net/perfectpdl,轉載註明出處,謝謝

我建了一個 Freeswitch 核心研究 交流群, 45211986, 歡迎加入, 另外,提供基於SIP的通訊伺服器及用戶端解決方案,

VOIP行業資訊和技術趨勢請參考:
www.voip123.cn

註冊到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.xml為freeswitch作為用戶端註冊到另一個網關的全域配置,

/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          Type                                      Data      State

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

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

                 internal         profile                   sip:mod_sofia@192.168.16.111:5060      RUNNING (0)

                 external         profile         sip:mod_sofia@192.168.16.111:5080     RUNNING (0)

    external::example.com       gateway                   sip:joeuser@example.com      NOREG

       external::asterisk       gateway          sip:freeswitch@demo.asterisk.org     TRYING (retry: NEVER)

           192.168.16.111         alias                                  internal      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的網關上。


歡迎補充:)


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.