#各配置文件作用
vars.xml | 一些经常使用变量
directory/default/*.xml | SIP用户,每用户一个文件
dialplan/default.xml | 通常用于处理内部、可信任的呼叫
dialplan/public.xml | 通常用于处理来自外部的、不受信任的呼叫
sip_profiles/internal.xml | 一个SIP profile,或称做一个SIP-UA,默认端口5060,通常供内网用户使用
sip_profiles/externa.xml | 另外一个SIP-UA,用做外部链接,默认端口5080
autoload_configs/modules.conf.xml | 配置当FreeSWITCH启动时自动装载哪些模块
autoload_configs/switch.conf.xml | 主要用于配置全局参数
#批量创建用户xml放在默认路径下 (添加用户后记得修改拨号计划Local_Extension正则匹配规则,并执行reloadxml生效)
/usr/local/freeswitch-1.10.6/scripts/perl/add_user --users=1020-1039
#修改sip注册默认密码,可加快拨打响应时间,改完执行reloadxml生效
sed -i 's/default_password=1234/default_password=Aa123456/g' /usr/local/freeswitch/conf/vars.xml
#修改默认socket连接密码,改完重启或者重新加载模块(fs_cli -x "reload mod_event_socket")
sed -i 's/ClueCon/NewPa55w4/g' /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
#修改socket连接指定使用了哪个ACL列表
通过/usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml中
<param name="apply-inbound-acl" value="lan"/>的value指定acl列表名指定
#添加acl白名单ip(访问控制规则的优先级是从上到下依次判断的),然后执行 reloadacl 生效
sed -i '/name="lan"/a\ <node type="allow" cidr="172.20.128.1/32"/>' /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml
#修改客户端可以远程连接配置 (密码、监听端口也是这里面修改)
sed -i 's/127.0.0.1/0.0.0.0/g' /usr/local/freeswitch/conf/autoload_configs/event_socket.conf.xml
#如果机器不支持ipv6把相关配置删除
rm -rf /usr/local/freeswitch/conf/sip_profiles/external-ipv6* /usr/local/freeswitch/conf/sip_profiles/internal-ipv6*
#后台启动
freeswitch -nc -nonat
#停止
/usr/local/freeswitch/bin/freeswitch -stop
#登陆控制台
/usr/local/freeswitch/bin/fs_cli -P端口 -p密码 -l日志级别
#-x执行命令
/usr/local/freeswitch/bin/fs_cli -x "show calls as json"
- fs_cli控制台命令:
/help #列出可用的fs_cli命令
/quit 或 /exit 或 /bye 或 ... #都会退出控制台
console loglevel 0 #控制台日志级别,级别从0-7,级别越高日志越大。比如6设置成INFO级别;7设置成DEBUG级别
status #显示当前FreeSWITCH的运行状态
reload MODNAME #重新加载模块
reloadxml #重新加载XML配置文件
reloadacl #更新鉴权
global_getvar #显示当前定义的所有全局变量及其取值
eval $${domain} #查看变量
eval $${conf_dir} #查看配置文件位置
sofia status profile internal reg #查询已注册用户(或者 show registrations)
originate {origination_caller_id_number=6688}user/1001 &park #拨打1001用户,主叫号码为6688(park表示挂起)
originate {origination_caller_id_number=6688}user/1001 &hold #拨打1001用户,主叫号码为6688(hold表示保持)
originate {origination_caller_id_number=6688}user/1001 &echo #拨打1001用户,主叫号码为6688(echo表示有回声)
originate {origination_caller_id_number=400009xxxx}sofia/external/008617xxxx3967@10.21.254.72 &echo() #通过SIP协议连接到外部网关拨打电话
uuid_kill UUID #挂断一个用户
hupall #挂断所有用户
originate user/1001 &playback(/usr/local/freeswitch/sounds/wait.wav) #拨打1001,接通后直接播放wav文件
originate user/1001 &record(/usr/local/freeswitch/sounds/r.wav) #拨打1001,直接录音
uuid_record UUID start /usr/local/freeswitch/sounds/r.wav #uuid开始录音
originate user/1001 &bridge(user/1002) #1001和1002通话(先打1001,再打1002)
originate sofia/internal/1001@foo.com &bridge(sofia/internal/1002@bar.com) #发起两通呼叫并bridge
originate user/1001 1002 XML default #将呼叫发送到用户1001,并转到目标号码1002上
sofia status profile external #查看对外配置信息(通常是对外通信)
sofia status profile internal #查看对内配置信息(通常是内部设备)
sofia profile internal/external restart #重启网关配置
module_exists mod_em #查询目标模块是否已经加载
- 未接通播放早期媒体(也就是彩铃)配置示例
<include>
<context name="public">
<extension name="inbound">
<condition field="destination_number" expression="^(\+86xxxxxxxx33|400xxxxxx5)$">
<action application="set" data="enable_early_media=true"/>
<action application="set" data="sip_ph_P-Early-Media=sendrecv"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="sip_sticky_contact=true"/>
<action application="pre_answer" data=""/>
<action application="playback" data="/usr/local/freeswitch/sounds/cailing.wav"/>
<action application="hangup" data="SUBSCRIBER_ABSENT"/>
</condition>
</extension>
</context>
</include>
- 模拟中继配置示例
<include>
<context name="public">
<extension name="any_answer">
<condition field="destination_number" expression="[0-9]$">
<action application="set" data="hangup_after_bridge=true"/>
<action application="ring_ready" data=""/>
<action application="sleep" data="${expr(randomize(&x);ceil(random(1000,3000,&x)))}"/>
<action application="unset" data="sip_rh_Remote-Party-ID" />
<action application="set" ><![CDATA[sip_rh_Remote-Party-ID="11111" <sip:{$caller_id_number}@test.com>;screen=yes;privacy=off]]></action>
<action application="pre_answer" data=""/>
<action application="answer" data=""/>
<action application="playback" data="/usr/local/freeswitch/sounds/test.mp3" />
<action application="sleep" data="${expr(randomize(&x);ceil(random(10000,15000,&x)))}"/>
<action application="hangup" data="" />
</condition>
</extension>
</context>
</include>
