| 知乎专栏 |
进入 fs_cli
[root@netkiller ~]# fs_cli .=======================================================. | _____ ____ ____ _ ___ | | | ___/ ___| / ___| | |_ _| | | | |_ \___ \ | | | | | | | | | _| ___) | | |___| |___ | | | | |_| |____/ \____|_____|___| | | | .=======================================================. | Anthony Minessale II, Ken Rice, | | Michael Jerris, Travis Cross | | FreeSWITCH (http://www.freeswitch.org) | | Paypal Donations Appreciated: paypal@freeswitch.org | | Brought to you by ClueCon http://www.cluecon.com/ | .=======================================================. .=======================================================================================================. | _ _ ____ _ ____ | | / \ _ __ _ __ _ _ __ _| | / ___| |_ _ ___ / ___|___ _ __ | | / _ \ | '_ \| '_ \| | | |/ _` | | | | | | | | |/ _ \ | / _ \| '_ \ | | / ___ \| | | | | | | |_| | (_| | | | |___| | |_| | __/ |__| (_) | | | | | | /_/ \_\_| |_|_| |_|\__,_|\__,_|_| \____|_|\__,_|\___|\____\___/|_| |_| | | | | ____ _____ ____ ____ __ | | | _ \_ _/ ___| / ___|___ _ __ / _| ___ _ __ ___ _ __ ___ ___ | | | |_) || || | | | / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \ | | | _ < | || |___ | |__| (_) | | | | _| __/ | | __/ | | | (_| __/ | | |_| \_\|_| \____| \____\___/|_| |_|_| \___|_| \___|_| |_|\___\___| | | | | ____ _ ____ | | / ___| |_ _ ___ / ___|___ _ __ ___ ___ _ __ ___ | | | | | | | | |/ _ \ | / _ \| '_ \ / __/ _ \| '_ ` _ \ | | | |___| | |_| | __/ |__| (_) | | | | _ | (_| (_) | | | | | | | | \____|_|\__,_|\___|\____\___/|_| |_| (_) \___\___/|_| |_| |_| | | | .=======================================================================================================. Type /help <enter> to see a list of commands
输入密码,并进入客户端
fs_cli -H 127.0.0.1 -P 8021 -p password
默认是 :: 表示 ipv6 localhost,如果需要远程访问可以改为 listen-ip 0.0.0.0
[root@netkiller ~]# cp /etc/freeswitch/autoload_configs/event_socket.conf.xml{,.backup}
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/event_socket.conf.xml
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="::"/>
<param name="listen-port" value="8021"/>
<param name="password" value="ClueCon"/>
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
<!--<param name="stop-on-bind-error" value="true"/>-->
</settings>
</configuration>
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/event_socket.conf.xml
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8021"/>
<param name="password" value="netkiller"/>
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
<!--<param name="stop-on-bind-error" value="true"/>-->
</settings>
</configuration>
[root@netkiller ~]# fs_cli -p netkiller
打开sip详细日志 sofia profile internal siptrace on 关闭sip详细日志 sofia profile internal siptrace off
[root@netkiller ~]# fs_cli -x "sofia status"
Name Type Data State
=================================================================================================
external-ipv6 profile sip:mod_sofia@[::1]:5080 RUNNING (0)
sip.netkiller.cn alias internal ALIASED
external profile sip:mod_sofia@192.168.0.230:5080 RUNNING (0)
external::example.com gateway sip:joeuser@example.com NOREG
external::hamsoverip gateway sip:300177@pbx-ap.hamsoverip.com:5160 REGED
internal-ipv6 profile sip:mod_sofia@[::1]:5060 RUNNING (0)
internal profile sip:mod_sofia@192.168.0.230:5060 RUNNING (0)
=================================================================================================
4 profiles 1 alias
freeswitch@-ERR switchname Command not found!> sofia status profile internal ================================================================================================= Name internal Domain Name N/A Auto-NAT true DBName sofia_reg_internal Pres Hosts sip.netkiller.com,192.168.0.230 Dialplan XML Context public Challenge Realm auto_from RTP-IP 192.168.0.230 Ext-RTP-IP 121.37.215.251 SIP-IP 192.168.0.230 Ext-SIP-IP 121.37.215.251 URL sip:mod_sofia@192.168.0.230:5060 BIND-URL sip:mod_sofia@192.168.0.230:5060;transport=udp,tcp WS-BIND-URL sip:mod_sofia@192.168.0.230:5066;transport=ws WSS-BIND-URL sips:mod_sofia@192.168.0.230:7443;transport=wss HOLD-MUSIC local_stream://moh OUTBOUND-PROXY N/A CODECS IN OPUS,G722,G729,PCMU,PCMA,H264,VP8 CODECS OUT OPUS,G722,G729,PCMU,PCMA,H264,VP8 TEL-EVENT 101 DTMF-MODE rfc2833 CNG 13 SESSION-TO 0 MAX-DIALOG 0 MAX-RECV-RPS 1000 NOMEDIA false LATE-NEG true PROXY-MEDIA true AGGRESSIVENAT false CALLS-IN 195 FAILED-CALLS-IN 99 CALLS-OUT 22 FAILED-CALLS-OUT 14 REGISTRATIONS 8
freeswitch@-ERR switchname Command not found!> sofia status profile external ================================================================================================= Name external Domain Name N/A Auto-NAT true DBName sofia_reg_external Pres Hosts Dialplan XML Context public Challenge Realm auto_to RTP-IP 192.168.0.230 Ext-RTP-IP 121.37.215.251 SIP-IP 192.168.0.230 Ext-SIP-IP 121.37.215.251 URL sip:mod_sofia@192.168.0.230:5080 BIND-URL sip:mod_sofia@192.168.0.230:5080;transport=udp,tcp HOLD-MUSIC local_stream://moh OUTBOUND-PROXY N/A CODECS IN OPUS,G722,G729,PCMU,PCMA,H264,VP8 CODECS OUT OPUS,G722,G729,PCMU,PCMA,H264,VP8 TEL-EVENT 101 DTMF-MODE rfc2833 CNG 13 SESSION-TO 0 MAX-DIALOG 0 MAX-RECV-RPS 1000 NOMEDIA false LATE-NEG true PROXY-MEDIA false AGGRESSIVENAT false CALLS-IN 3 FAILED-CALLS-IN 3 CALLS-OUT 0 FAILED-CALLS-OUT 0 REGISTRATIONS 0
[root@netkiller ~]# fs_cli -x "sofia status profile internal reg" Registrations: ================================================================================================= Call-ID: 1_4246134458@192.168.123.55 User: 1008@sip.netkiller.cn Contact: "1008" <sip:1008@192.168.123.55:5060;fs_nat=yes;fs_path=sip%3A1008%40223.74.131.87%3A20508> Agent: Yealink SIP-T21P_E2 52.84.0.125 Status: Registered(UDP-NAT)(unknown) EXP(2025-04-06 19:32:38) EXPSECS(2540) Ping-Status: Reachable Ping-Time: 0.00 Host: netkiller IP: 223.74.131.87 Port: 20508 Auth-User: 1008 Auth-Realm: sip.netkiller.cn MWI-Account: 1008@sip.netkiller.cn Call-ID: 212FF149-109A-40AF-A2CF-23003FC53819 User: 1002@sip.netkiller.cn Contact: "BG7NYT" <sip:1002@172.16.0.11:5060;fs_nat=yes;fs_path=sip%3A1002%40112.97.167.132%3A13917> Agent: Jami Daemon 16.0.0-fc3402940f (macOS) Status: Registered(UDP-NAT)(unknown) EXP(2025-04-06 19:39:37) EXPSECS(2959) Ping-Status: Reachable Ping-Time: 0.00 Host: netkiller IP: 112.97.167.132 Port: 13917 Auth-User: 1002 Auth-Realm: sip.netkiller.cn MWI-Account: 1002@sip.netkiller.cn Call-ID: 139311fc-5f0ee947@172.16.0.10 User: 1000@sip.netkiller.cn Contact: "BG7NYT" <sip:1000@172.16.0.10:5060;fs_nat=yes;fs_path=sip%3A1000%40112.97.167.132%3A12689> Agent: Linksys/PAP2T-5.1.6(LS) Status: Registered(UDP-NAT)(unknown) EXP(2025-04-06 19:39:51) EXPSECS(2973) Ping-Status: Reachable Ping-Time: 0.00 Host: netkiller IP: 112.97.167.132 Port: 12689 Auth-User: 1000 Auth-Realm: sip.netkiller.cn MWI-Account: 1000@sip.netkiller.cn Call-ID: 5A7530FB452FDFDC5BDCD7E3A73DF6EEBC4D93D0 User: 1006@sip.netkiller.cn Contact: "" <sip:1006@10.65.4.4:23015;rinstance=18F4361D;fs_nat=yes;fs_path=sip%3A1006%40167.99.119.244%3A23015%3Brinstance%3D18F4361D> Agent: Acrobits SIPIS Status: Registered(UDP-NAT)(unknown) EXP(2025-04-06 18:57:03) EXPSECS(405) Ping-Status: Reachable Ping-Time: 0.00 Host: netkiller IP: 167.99.119.244 Port: 23015 Auth-User: 1006 Auth-Realm: sip.netkiller.cn MWI-Account: 1006@sip.netkiller.cn Total items returned: 4 =================================================================================================
重新扫描加载 sip profile
sofia profile internal rescan sofia profile external rescan
重启 sip profile
sofia profile internal restart sofia profile external restart
# 显示当前呼叫 show calls # 显示呼叫数量 show calls count # 挂断某个呼叫 uuid_kill 59b857d2-d7b8-4c7e-6666-e19be0f16643 # 挂断所有呼叫 hupall # 拨打某个用户并启用echo回音 originate user/1000 &echo
回音测试
originate user/1000 &echo
停泊
originate user/1000 &park # 停泊
保持
originate user/1000 &hold # 保持
播放放音
originate user/1000 &playback(/root/welclome.wav) # 播放音乐
呼叫并录音
originate user/1000 &record(/tmp/vocie_of_alice.wav) # 呼叫并录音
同振与顺振
#经过特定的SIP服务器发起外呼,下面的命令会将INVITE先发送到192.168.2.4:5060上
bgapi originate sofia/external/8005@001.com;fs_path=sip:192.168.2.4:5060 &echo
经过特定SIP服务器
#经过特定的SIP服务器发起外呼,下面的命令会将INVITE先发送到192.168.2.4:5060上
bgapi originate sofia/external/8005@001.com;fs_path=sip:192.168.2.4:5060 &echo
忽略early media
originate {ignore_early_media=true}user/1000 &echo
播放假的early media
originate {transfer_ringback=local_stream://moh}user/1000 &echo
立即播放early media
originate {instant_ringback=true}{transfer_ringback=local_stream://moh}user/1000 &echo
设置外显号码
originate {origination_callee_id_name=7777}user/1000