Asterisk ⟷ FreeSWITCH

Asterisk ⟷ FreeSWITCH

我在不同的 LAN 上有 2 个 SIP 服务器。一个是 Freeswitch,另一个是 Asterisk。

Asterisk 位于提供 DID 的提供商的 VPN 上。所有用户都在 Freeswitch 上注册。我如何通过 Asterisk 将呼叫路由到提供商并返回,

我尝试了 sofia/default/DIDNUMBER@ASTERISKSERVERIP:5060,但呼叫没有接通到提供商。

答案1

Asterisk ⟷ FreeSWITCH

您的需求当然可能会有所不同,但这是一个好的开始 - 我有几个带有私人连接的服务器,因此您可能需要调整身份验证措施,但这应该说明了来回通信和进入正确上下文的基础知识等。

星号

配置文件

[tel]
type=transport
protocol=udp
bind=10.8.0.2 # set asterisk's IP -- bind to this address

[acl]
type=acl
deny=0.0.0.0/0
permit=10.8.0.3/32 # allow only calls from freeswitch who is on 10.8.0.3 see above deny

[fs]
type=identify
endpoint=fs
match=10.8.0.3 # identify/auth traffic from freeswitch by its IP

[fs]
type=endpoint # set options for endpoint we identified just above
trust_id_inbound=yes
trust_id_outbound=yes
aors=fs
context=from-internal ## WHERE DO CALLS FROM FREESWITCH TO ASTERISK GO?
allow=!all,g722,ulaw
transport=tel

[fs]
type=aor
contact=sip:10.8.0.3 # address-of-record to find freeswitch so can dial to fs without it registering with us (this is fed up to [fs] type=endpoint via its aors above so calls to Dial(PJSIP/1234@fs) dials 1234 on FreeSWITCH 10.8.0.3)

扩展配置文件

[from-internal]
include = toFreeSWITCH

[toFreeSWITCH]
exten = _N11!,1,Dial(PJSIP/${EXTEN}@fs)
exten = _0!,1,Dial(PJSIP/${EXTEN}@fs)
exten = _3XX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _1NXXNXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _508NXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _774NXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)

自由交换

conf/autoload_configs/acl.conf.xml

添加这个<network-lists>

<list name="asterisk" default="deny">
  <node type="allow" cidr="10.8.0.2/32"/>
</list>

conf/sip_profiles/asterisk.xml

<profile name="asterisk">
    <gateways>
      <gateway name="asterisk">
        <param name="username" value="freeswitch"/>
        <param name="realm" value="your-asterisk-domain"/>
        <param name="password" value="unused-but-required-field"/>
        <param name="from-domain" value="your-asterisk-domain"/>
        <param name="proxy" value="10.8.0.2"/><!-- ASTERISK ADDRESS -->
        <param name="register" value="false"/><!-- INSTEAD WE SET AOR IN PJSIP.CONF -->
        <param name="cid-type" value="pid"/>
        <param name="rfc-5626" value="true"/>
       </gateway>
    </gateways>
    <settings>
        <param name="apply-inbound-acl" value="asterisk"/>
        <param name="auth-calls" value="false"/>
        <param name="context" value="public"/><!-- WHERE DO CALLS FROM ASTERISK COME INTO? -->
        <param name="rtp-ip" value="10.8.0.3"/><!-- this FreeSWITCH MEDIA IP -->
        <param name="sip-ip" value="10.8.0.3"/><!-- this FreeSWITCH SIP IP -->
    </settings>
</profile>

拨号计划.xml

调整并添加拨号计划

<extension name="to-asterisk">
  <condition field="destination_number" expression="^([2-9]11|1?[2-9]\d{2}[2-9]\d{6}|3\d{2})$">
    <action application="set" data="dialed_extension=$1"/>
    <action application="export" data="dialed_extension=$1"/>
    <action application="set" data="call_timeout=30"/>
    <action application="set" data="hangup_after_bridge=true"/>
    <action application="set" data="continue_on_fail=true"/>
    <action application="export" data="rtp_secure_media=false"/>
    <action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
  </condition>
</extension>

相关内容