重点说明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}"/>
然后软电话直接测试