Asterisk

使用 Asterisk 作為 Provider 的網關

  • August 11, 2018

我在不同的 LAN 上有 2 個 sip 伺服器。Freeswitch和另一個是Asterisk。

Asterisk 與提供 DID 的提供商一起坐在 VPN 上。所有使用者都在 Freeswitch 上註冊。如何通過 Asterisk 將呼叫路由到提供程序並返回,

我嘗試了 sofia/default/DIDNUMBER@ASTERISKSERVERIP:5060 但呼叫沒有通過提供商。

Asterisk ⟷ FreeSWITCH

當然,您的需求可能會有所不同,但這是一個好的開始——我有幾台具有專用連接的伺服器,因此您可能需要調整身份驗證措施,但這應該說明來回通信的基礎知識以及放入正確的上下文等.

星號

pjsip.conf

[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)

extensions.conf

[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>

引用自:https://serverfault.com/questions/922637