重點說明freeswitch的配置
我們假設asterisk的IP為210.134.185.9,有個sip号碼為60006
1、asterisk配置
修改sip.conf,添加如下内容:
[fs_zmrh]
username=fs_zmrh
secret=123
host=dynamic
type=peer
nat=yes
context=from-internal
2、配置domain
修改freeswitch安裝目錄下conf/drectory/default.xml,添加如下内容:
<domain name="210.134.185.9">
<params>
<param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
</params>
<variables>
<variable name="record_stereo" value="true"/>
<variable name="default_areacode" value="$${default_areacode}"/>
<variable name="transfer_fallback_extension" value="operator"/>
</variables>
<user id="210.134.185.9">
<gateways>
<X-PRE-PROCESS cmd="include" data="gateway/*.xml"/>
</gateways>
</user>
</domain>
3、配置網關(gateway)
在freeswtich的conf/directory/目錄下建立檔案夾gateway,在gateway檔案夾下建立一個xml檔案,内容如下:
<include>
<gateway name="asterisk">
<param name="username" value="fs_zmrh"/>
<param name="password" value="123"/>
<param name="realm" value="210.134.185.9"/>
<param name="from-domain" value="210.134.185.9"/>
<param name="expire-seconds" value="600"/>
<param name="register" value="false"/>
</gateway>
</include>
4、配置呼叫規則
修改freeswtich安裝目錄下的conf/dialplan/default.xml,添加内容如下:
<extension name="extension-asterisk">
<condition field="destination_number" expression="^(6[01][01][0-9][0-9])$">
<action application="set" data="dialed_extension=$1"/>
<action application="bridge" data="sofia/gateway/asterisk/$1"/>
</condition>
</extension>
配置完畢,啟動freeswitch即可進行呼叫
注意:
如果freeswitch和asterisk都在内網,請修改freeswtich安裝目錄下的conf/sip_profiles下的external.xml,如下,原來為:
<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
<param name="ext-sip-ip" value="$${external_sip_ip}"/>
修改為:
<param name="ext-rtp-ip" value="$${local_ip_v4}"/>
<param name="ext-sip-ip" value="$${local_ip_v4}"/>
然後軟電話直接測試