Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 168 章 Voice over IP(VoIP)

目录

168.1. FreeSWITCH
168.1.1. 注册用户并创建令牌
168.1.2. Rocky Linux / AlmiLinux 安装
168.1.3. 防火墙端口
168.1.4. 配置 freeswitch
168.1.5. MySQL 模块配置
168.1.6. 测试号码
168.1.7. fs_cli
168.1.8. 中文语音包
168.1.9. fusionPBX
168.1.10. 开发
168.2. Kamailio
168.2.1. Docker 安装 Kamailio
168.2.2. RPM 包安装 kamailio
168.2.3. 配置 kamailio
168.2.4. 管理 Kamailio
168.3. Yate - Yet Another Telephony Engine (includes SIP to H.323 translation)
168.3.1. Yate Server
168.3.2. 配置文件样本
168.3.3. 添加用户
168.3.4. regexroute.conf
168.3.5. 测试
168.3.6. SBC(SIP Session Border Controller) 会话边界控制器
168.3.7. 配置路由
168.3.8. 配置会议室
168.3.9. Yate Client
168.4. Gnu Gatekeeper
168.4.1. Gnu Gatekeeper Install
168.4.2. Gnu Gatekeeper Configure
168.4.3. Gnu Gatekeeper Test
168.5. OpenSIPS
168.5.1. 安装 OpenSIPS
168.5.2. 数据库部署
168.5.3. 测试 opensips
168.6. Asterisk (OpenSource Linux PBX that supports both SIP and H.323)
168.6.1. Redhat/CentOS/RockyLinux/AlmiLinux
168.6.2. 源码安装 asterisk-22
168.6.3. Ubuntu
168.6.4. RasPBX – Asterisk for Raspberry Pi
168.6.5. 配置文件
168.6.6. 拨号规则设置
168.6.7. pjsip
168.6.8. 配置例子
168.7. VOCAL (includes a SIP to H.323 translator)
168.8. RTP
168.8.1. RTPProxy
168.8.2. rtpengine
168.9. sngrep - SIP Messages flow viewer
168.9.1. Rocky Linux 安装 sngrep
168.9.2. MacOS
168.9.3. debian 安装sngrep
168.9.4. 命令行参数
168.9.5. UI 快捷鍵
168.10. 电话
168.10.1. Linksys/PAP2T-5.1.6(LS) 登录 freeSWITCH 和 asterisk 失败
168.10.2. Avaya
168.10.3. linphone
168.10.4. Jami
168.10.5. MicroSIP
168.11. FAQ
168.11.1. SIP ALG

安装环境 ubuntu 13.10

168.1. FreeSWITCH

https://www.freeswitch.org/

168.1.1. 注册用户并创建令牌

前往 https://signalwire.com 注册账号

点击自己头像,选择“Personal Access Tokens” 进入个人访问令牌页面,然后点击“+ Add New” 创建令牌。

Token Name 处输入令牌名称,然后点击 “Generate Token” 生成令牌。

PERSONAL ACCESS TOKEN 下面一串字符,就是令牌,请复制出来并保存好。

168.1.2. Rocky Linux / AlmiLinux 安装

		
echo "netkiller" > /etc/yum/vars/signalwireusername
echo "pat_hbpgtYbJHMMS5Wcy868dW1o2" > /etc/yum/vars/signalwiretoken
dnf install -y https://$(< /etc/yum/vars/signalwireusername):$(< /etc/yum/vars/signalwiretoken)@freeswitch.signalwire.com/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release
		
		

查看相关包

		
[root@netkiller ~]# dnf search freeswitch
FreeSWITCH Packages for Enterprise Linux 9 - x86_64                                                                                                    174 kB/s | 752 kB     00:04    
FreeSWITCH Packages for Enterprise Linux 9 - x86_64 - Debug                                                                                            168 kB/s | 752 kB     00:04    
FreeSWITCH Packages for Enterprise Linux 9 - x86_64 - Source                                                                                           174 kB/s | 752 kB     00:04    
========================================================================= Name & Summary Matched: freeswitch ==========================================================================
freeswitch.src : FreeSWITCH open source telephony platform
freeswitch.x86_64 : FreeSWITCH open source telephony platform
freeswitch-application-abstraction.x86_64 : FreeSWITCH mod_abstraction
freeswitch-application-avmd.x86_64 : FreeSWITCH voicemail detector
freeswitch-application-blacklist.x86_64 : FreeSWITCH blacklist module
freeswitch-application-callcenter.x86_64 : FreeSWITCH mod_callcenter Call Queuing Application
freeswitch-application-cidlookup.x86_64 : FreeSWITCH mod_cidlookup
freeswitch-application-conference.x86_64 : FreeSWITCH mod_conference
freeswitch-application-curl.x86_64 : FreeSWITCH mod_curl
freeswitch-application-db.x86_64 : FreeSWITCH mod_db
freeswitch-application-directory.x86_64 : FreeSWITCH mod_directory
freeswitch-application-distributor.x86_64 : FreeSWITCH mod_distributor
freeswitch-application-easyroute.x86_64 : FreeSWITCH mod_easyroute
freeswitch-application-enum.x86_64 : FreeSWITCH mod_enum
freeswitch-application-esf.x86_64 : FreeSWITCH mod_esf
freeswitch-application-expr.x86_64 : FreeSWITCH mod_expr
freeswitch-application-fifo.x86_64 : FreeSWITCH mod_fifo
freeswitch-application-fsk.x86_64 : FreeSWITCH mod_fsk
freeswitch-application-fsv.x86_64 : FreeSWITCH mod_fsv
freeswitch-application-hash.x86_64 : FreeSWITCH mod_hash
freeswitch-application-httapi.x86_64 : FreeSWITCH mod_httapi
freeswitch-application-http-cache.x86_64 : FreeSWITCH mod_http_cache
freeswitch-application-lcr.x86_64 : FreeSWITCH mod_lcr
freeswitch-application-limit.x86_64 : FreeSWITCH mod_limit
freeswitch-application-memcache.x86_64 : FreeSWITCH mod_memcache
freeswitch-application-mongo.x86_64 : FreeSWITCH mod_mongo
freeswitch-application-nibblebill.x86_64 : FreeSWITCH mod_nibblebill
freeswitch-application-rad_auth.x86_64 : FreeSWITCH mod_rad_auth
freeswitch-application-redis.x86_64 : FreeSWITCH mod_redis
freeswitch-application-rss.x86_64 : FreeSWITCH mod_rss
freeswitch-application-signalwire.x86_64 : FreeSWITCH mod_signalwire
freeswitch-application-sms.x86_64 : FreeSWITCH mod_sms
freeswitch-application-snapshot.x86_64 : FreeSWITCH mod_snapshot
freeswitch-application-snom.x86_64 : FreeSWITCH mod_snom
freeswitch-application-soundtouch.x86_64 : FreeSWITCH mod_soundtouch
freeswitch-application-spy.x86_64 : FreeSWITCH mod_spy
freeswitch-application-stress.x86_64 : FreeSWITCH mod_stress
freeswitch-application-translate.x86_64 : FreeSWITCH mod_translate
freeswitch-application-valet_parking.x86_64 : FreeSWITCH mod_valet_parking
freeswitch-application-video_filter.x86_64 : FreeSWITCH video filter bugs
freeswitch-application-voicemail.x86_64 : FreeSWITCH mod_voicemail
freeswitch-application-voicemail-ivr.x86_64 : FreeSWITCH mod_voicemail_ivr
freeswitch-asrtts-flite.x86_64 : FreeSWITCH mod_flite
freeswitch-asrtts-pocketsphinx.x86_64 : FreeSWITCH mod_pocketsphinx
freeswitch-asrtts-tts-commandline.x86_64 : FreeSWITCH mod_tts_commandline
freeswitch-asrtts-unimrcp.x86_64 : FreeSWITCH mod_unimrcp
freeswitch-codec-bv.x86_64 : BroadVoice16 and BroadVoice32 WideBand Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-codec2.x86_64 : Codec2 Narrow Band Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-h26x.x86_64 : H.263/H.264 Video Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-ilbc.x86_64 : iLCB Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-isac.x86_64 : iSAC Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-mp4v.x86_64 : MP4V Video Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-opus.x86_64 : Opus Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-passthru-amr.x86_64 : Pass-through AMR Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-passthru-amrwb.x86_64 : Pass-through AMR WideBand Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-passthru-g723_1.x86_64 : Pass-through g723.1 Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-passthru-g729.x86_64 : Pass-through g729 Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-silk.x86_64 : Silk Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-siren.x86_64 : Siren Codec support for FreeSWITCH open source telephony platform
freeswitch-codec-theora.x86_64 : Theora Video Codec support for FreeSWITCH open source telephony platform
freeswitch-config-vanilla.x86_64 : Basic vanilla config set for the FreeSWITCH Open Source telephone platform.
freeswitch-database-mariadb.x86_64 : MariaDB native support for FreeSWITCH
freeswitch-database-pgsql.x86_64 : PostgreSQL native support for FreeSWITCH
freeswitch-debuginfo.x86_64 : Debug information for package freeswitch
freeswitch-devel.x86_64 : Development package for FreeSWITCH open source telephony platform
freeswitch-endpoint-dingaling.x86_64 : Generic XMPP support for FreeSWITCH open source telephony platform
freeswitch-endpoint-portaudio.x86_64 : PortAudio endpoint support for FreeSWITCH open source telephony platform
freeswitch-endpoint-rtc.x86_64 : Verto endpoint support for FreeSWITCH open source telephony platform
freeswitch-endpoint-rtmp.x86_64 : RTPM Endpoint support for FreeSWITCH open source telephony platform
freeswitch-endpoint-skinny.x86_64 : Skinny/SCCP endpoint support for FreeSWITCH open source telephony platform
freeswitch-endpoint-verto.x86_64 : Verto endpoint support for FreeSWITCH open source telephony platform
freeswitch-event-cdr-mongodb.x86_64 : MongoDB CDR Logger for the FreeSWITCH open source telephony platform
freeswitch-event-cdr-pg-csv.x86_64 : PostgreSQL CDR Logger for the FreeSWITCH open source telephony platform
freeswitch-event-cdr-sqlite.x86_64 : SQLite CDR Logger for the FreeSWITCH open source telephony platform
freeswitch-event-erlang-event.x86_64 : Erlang Event Module for the FreeSWITCH open source telephony platform
freeswitch-event-format-cdr.x86_64 : JSON and XML Logger for the FreeSWITCH open source telephony platform
freeswitch-event-json-cdr.x86_64 : JSON CDR Logger for the FreeSWITCH open source telephony platform
freeswitch-event-multicast.x86_64 : Multicast Event System for the FreeSWITCH open source telephony platform
freeswitch-event-radius-cdr.x86_64 : RADIUS Logger for the FreeSWITCH open source telephony platform
freeswitch-event-rayo.x86_64 : Rayo (XMPP 3PCC) server for the FreeSWITCH open source telephony platform
freeswitch-event-snmp.x86_64 : SNMP stats reporter for the FreeSWITCH open source telephony platform
freeswitch-format-local-stream.x86_64 : Local File Streamer for the FreeSWITCH open source telephony platform
freeswitch-format-mod-shout.x86_64 : Implements Media Steaming from arbitrary shell commands for the FreeSWITCH open source telephony platform
freeswitch-format-native-file.x86_64 : Native Media File support for the FreeSWITCH open source telephony platform
freeswitch-format-portaudio-stream.x86_64 : PortAudio Media Steam support for the FreeSWITCH open source telephony platform
freeswitch-format-shell-stream.x86_64 : Implements Media Steaming from arbitrary shell commands for the FreeSWITCH open source telephony platform
freeswitch-format-ssml.x86_64 : Adds Speech Synthesis Markup Language (SSML) parser format for the FreeSWITCH open source telephony platform
freeswitch-format-tone-stream.x86_64 : Implements TGML Tone Generation for the FreeSWITCH open source telephony platform
freeswitch-freetdm.x86_64 : Provides a unified interface to hardware TDM cards and ss7 stacks for FreeSWITCH
freeswitch-kazoo.x86_64 : Kazoo Module for the FreeSWITCH open source telephony platform
freeswitch-lang-de.x86_64 : Provides german language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-en.x86_64 : Provides english language dependent modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-es.x86_64 : Provides Spanish language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-fr.x86_64 : Provides french language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-he.x86_64 : Provides hebrew language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-pt.x86_64 : Provides Portuguese language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-ru.x86_64 : Provides russian language dependent modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lang-sv.x86_64 : Provides Swedish language dependend modules and speech config for the FreeSWITCH Open Source telephone platform.
freeswitch-lua.x86_64 : Lua support for the FreeSWITCH open source telephony platform
freeswitch-perl.x86_64 : Perl support for the FreeSWITCH open source telephony platform
freeswitch-python.x86_64 : Python support for the FreeSWITCH open source telephony platform
freeswitch-release-repo.noarch : FreeSWITCH Packages for Enterprise Linux repository configuration
freeswitch-sounds-en-ca-june.noarch : FreeSWITCH fr-CA June prompts
freeswitch-sounds-en-ca-june-16000.noarch : FreeSWITCH 16kHz fr CA June prompts
freeswitch-sounds-en-ca-june-32000.noarch : FreeSWITCH 32kHz fr CA June prompts
freeswitch-sounds-en-ca-june-48000.noarch : FreeSWITCH 48kHz fr CA June prompts
freeswitch-sounds-en-ca-june-8000.noarch : FreeSWITCH 8kHz fr CA June prompts
freeswitch-sounds-en-ca-june-all.noarch : FreeSWITCH fr CA June prompts
freeswitch-sounds-en-us-allison.noarch : FreeSWITCH en-us Allison prompts
freeswitch-sounds-en-us-allison-16000.noarch : FreeSWITCH 16kHz en-us Allison prompts
freeswitch-sounds-en-us-allison-32000.noarch : FreeSWITCH 32kHz en-us Allison prompts
freeswitch-sounds-en-us-allison-48000.noarch : FreeSWITCH 48kHz en-us Allison prompts
freeswitch-sounds-en-us-allison-8000.noarch : FreeSWITCH 8kHz en-us Allison prompts
freeswitch-sounds-en-us-allison-all.noarch : FreeSWITCH en-us Allison prompts
freeswitch-sounds-en-us-callie.noarch : FreeSWITCH en-us Callie prompts
freeswitch-sounds-en-us-callie-16000.noarch : FreeSWITCH 16kHz en-us Callie prompts
freeswitch-sounds-en-us-callie-32000.noarch : FreeSWITCH 32kHz en-us Callie prompts
freeswitch-sounds-en-us-callie-48000.noarch : FreeSWITCH 48kHz en-us Callie prompts
freeswitch-sounds-en-us-callie-8000.noarch : FreeSWITCH 8kHz en-us Callie prompts
freeswitch-sounds-en-us-callie-all.noarch : FreeSWITCH en-us Callie prompts
freeswitch-sounds-fr-ca-june.noarch : FreeSWITCH fr-CA June prompts
freeswitch-sounds-fr-ca-june-16000.noarch : FreeSWITCH 16kHz fr CA June prompts
freeswitch-sounds-fr-ca-june-32000.noarch : FreeSWITCH 32kHz fr CA June prompts
freeswitch-sounds-fr-ca-june-48000.noarch : FreeSWITCH 48kHz fr CA June prompts
freeswitch-sounds-fr-ca-june-8000.noarch : FreeSWITCH 8kHz fr CA June prompts
freeswitch-sounds-fr-ca-june-all.noarch : FreeSWITCH fr CA June prompts
freeswitch-sounds-music.noarch : FreeSWITCH Music on Hold soundfiles
freeswitch-sounds-music-16000.noarch : FreeSWITCH 16kHz Music On Hold soundfiles
freeswitch-sounds-music-32000.noarch : FreeSWITCH 32kHz Music On Hold soundfiles
freeswitch-sounds-music-48000.noarch : FreeSWITCH 48kHz Music On Hold soundfiles
freeswitch-sounds-music-8000.noarch : FreeSWITCH 8kHz Music On Hold soundfiles
freeswitch-sounds-pt-BR-karina.noarch : FreeSWITCH pt-BR Karina prompts
freeswitch-sounds-pt-BR-karina-16000.noarch : FreeSWITCH 16kHz fr BR Karina prompts
freeswitch-sounds-pt-BR-karina-32000.noarch : FreeSWITCH 32kHz fr BR Karina prompts
freeswitch-sounds-pt-BR-karina-48000.noarch : FreeSWITCH 48kHz fr BR Karina prompts
freeswitch-sounds-pt-BR-karina-8000.noarch : FreeSWITCH 8kHz fr BR Karina prompts
freeswitch-sounds-pt-BR-karina-all.noarch : FreeSWITCH fr BR Karina prompts
freeswitch-sounds-ru-RU-elena.noarch : FreeSWITCH ru-RU Elena prompts
freeswitch-sounds-ru-RU-elena-16000.noarch : FreeSWITCH 16kHz ru-RU Elena prompts
freeswitch-sounds-ru-RU-elena-32000.noarch : FreeSWITCH 32kHz ru-RU Elena prompts
freeswitch-sounds-ru-RU-elena-48000.noarch : FreeSWITCH 48kHz ru-RU Elena prompts
freeswitch-sounds-ru-RU-elena-8000.noarch : FreeSWITCH 8kHz ru-RU Elena prompts
freeswitch-sounds-ru-RU-elena-all.noarch : FreeSWITCH ru-RU Elena prompts
freeswitch-sounds-sv-se-jakob.noarch : FreeSWITCH sv-se Jakob prompts
freeswitch-sounds-sv-se-jakob-16000.noarch : FreeSWITCH 16kHz sv-se jakob prompts
freeswitch-sounds-sv-se-jakob-32000.noarch : FreeSWITCH 32kHz sv-se jakob prompts
freeswitch-sounds-sv-se-jakob-48000.noarch : FreeSWITCH 48kHz sv-se jakob prompts
freeswitch-sounds-sv-se-jakob-8000.noarch : FreeSWITCH 8kHz sv-se jakob prompts
freeswitch-sounds-sv-se-jakob-all.noarch : FreeSWITCH sv-se jakob prompts
freeswitch-timer-posix.x86_64 : Provides posix timer for the FreeSWITCH Open Source telephone platform.
freeswitch-xml-cdr.x86_64 : Provides XML CDR interface for the FreeSWITCH Open Source telephone platform.
freeswitch-xml-curl.x86_64 : Provides XML Curl interface for the FreeSWITCH Open Source telephone platform.
============================================================================== Name Matched: freeswitch ===============================================================================
freeswitch-format-opusfile.x86_64 : Plays Opus encoded files
freeswitch-logger-graylog2.x86_64 : GELF logger for Graylog2 and Logstash
============================================================================= Summary Matched: freeswitch =============================================================================
perl-ESL.x86_64 : The Perl ESL module allows for native interaction with FreeSWITCH over the event socket interface.
python-ESL.x86_64 : The Python ESL module allows for native interaction with FreeSWITCH over the event socket interface.		
		
		

查看版本信息

		
[root@netkiller ~]# dnf info freeswitch
Last metadata expiration check: 0:03:19 ago on Sat 05 Apr 2025 07:50:56 AM CST.
Available Packages
Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : src
Size         : 59 M
Source       : None
Repository   : freeswitch
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.

Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : src
Size         : 59 M
Source       : None
Repository   : freeswitch-debuginfo
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.

Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : src
Size         : 59 M
Source       : None
Repository   : freeswitch-source
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.

Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : x86_64
Size         : 3.2 M
Source       : freeswitch-1.10.11.release.18-1.el7.src.rpm
Repository   : freeswitch
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.

Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : x86_64
Size         : 3.2 M
Source       : freeswitch-1.10.11.release.18-1.el7.src.rpm
Repository   : freeswitch-debuginfo
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.

Name         : freeswitch
Version      : 1.10.11.release.18
Release      : 1.el7
Architecture : x86_64
Size         : 3.2 M
Source       : freeswitch-1.10.11.release.18-1.el7.src.rpm
Repository   : freeswitch-source
Summary      : FreeSWITCH open source telephony platform
URL          : http://www.freeswitch.org/
License      : MPL1.1
Description  : FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice
             : and chat driven products scaling from a soft-phone up to a soft-switch.  It can be used as a
             : simple switching engine, a media gateway or a media server to host IVR applications using
             : simple scripts or XML to control the callflow.
             : 
             : We support various communication technologies such as SIP, H.323 and GoogleTalk making
             : it easy to interface with other open source PBX systems such as sipX, OpenPBX, Bayonne, YATE or Asterisk.
             : 
             : We also support both wide and narrow band codecs making it an ideal solution to bridge legacy
             : devices to the future. The voice channels and the conference bridge module all can operate
             : at 8, 16 or 32 kilohertz and can bridge channels of different rates.
             : 
             : FreeSWITCH runs on several operating systems including Windows, Max OS X, Linux, BSD and Solaris
             : on both 32 and 64 bit platforms.
             : 
             : Our developers are heavily involved in open source and have donated code and other resources to
             : other telephony projects including sipXecs, OpenSER, Asterisk, CodeWeaver and OpenPBX.		
		
		

安装 freeswitch

安装 compat-openssl10 https://pkgs.org/download/compat-openssl10

		
[root@netkiller ~]# dnf install -y https://pkgs.sysadmins.ws/el8/extras/x86_64/compat-openssl10-1.0.2o-3.el8.x86_64.rpm
[root@netkiller ~]# dnf install -y https://repo.almalinux.org/almalinux/9/CRB/x86_64/os/Packages/libmemcached-awesome-1.1.0-12.el9.x86_64.rpm
[root@netkiller ~]# dnf install -y https://cdn.amazonlinux.com/2/core/2.0/x86_64/6b0225ccc542f3834c95733dcf321ab9f1e77e6ca6817469771a8af7c49efe6c/../../../../../blobstore/9696af59b58e65548eb6c3256ef10b139190dee9c3efd8a28602db3497a80441/ldns-1.6.16-10.amzn2.x86_64.rpm
[root@netkiller ~]# dnf install -y freeswitch-config-vanilla freeswitch-lang-en freeswitch-sounds-en-us-* freeswitch-sounds-music-* freeswitch-codec-opus freeswitch-lua
		
		

启动 freeswitch

		
[root@netkiller ~]# systemctl enable freeswitch
[root@netkiller ~]# systemctl start freeswitch
[root@netkiller ~]# systemctl status freeswitch
		
		

168.1.3. 防火墙端口

		
FireWall Ports  Network Protocol    Application Protocol    Description

1719    UDP H.323 Gatekeeper RAS port
1720    TCP H.323 Call Signaling

3478    UDP STUN service    Used for NAT traversal
3479    UDP STUN service    Used for NAT traversal

5002    TCP MLP protocol server
5003    UDP Neighborhood service

5060    UDP & TCP   SIP UAS Used for SIP signaling (Standard SIP Port, for default Internal Profile)
5070    UDP & TCP   SIP UAS Used for SIP signaling (For default "NAT" Profile)
5080    UDP & TCP   SIP UAS Used for SIP signaling (For default "External" Profile)

8021    TCP ESL Used for mod_event_socket *

16384-32768 UDP RTP/ RTCP multimedia streaming  Used for audio/video data in SIP and other protocols

5066    TCP Websocket   Used for WebRTC
7443    TCP Websocket   Used for WebRTC		
		
		

fail2ban 自动拦截恶意注册

		
firewall-cmd --zone=public --add-port=1719/udp  --permanent
firewall-cmd --zone=public --add-port=1720/tcp  --permanent
firewall-cmd --zone=public --add-port=3478-3479/udp  --permanent
firewall-cmd --zone=public --add-port=5002/tcp  --permanent
firewall-cmd --zone=public --add-port=5003/udp  --permanent
firewall-cmd --zone=public --add-port=5060/udp  --permanent
firewall-cmd --zone=public --add-port=5060/tcp  --permanent
firewall-cmd --zone=public --add-port=5070/udp  --permanent
firewall-cmd --zone=public --add-port=5080/udp  --permanent
firewall-cmd --zone=public --add-port=5006/tcp  --permanent
firewall-cmd --zone=public --add-port=5007/tcp  --permanent
firewall-cmd --zone=public --add-port=5008/tcp  --permanent
firewall-cmd --zone=public --add-port=8021/tcp  --permanent
firewall-cmd --zone=public --add-port=16384-32768/udp  --permanent
firewall-cmd --zone=public --add-port=5066/tcp  --permanent
firewall-cmd --zone=public --add-port=7443/tcp  --permanent
		
		
		

重启防火墙

		
firewall-cmd --reload		
		
		

查看已开放的端口

		
firewall-cmd --list-ports
		
		

168.1.4. 配置 freeswitch

168.1.4.1. 基本配置 /etc/freeswitch/vars.xml

默认密码
			
[root@netkiller ~]# cp /etc/freeswitch/vars.xml{,.backup}
			
				

随机产生密码

			
[root@netkiller ~]# randpasswd | cut -c -10
NLYPx9JjSx			
			
				

修改默认密码,将 1234 改为

			
  <X-PRE-PROCESS cmd="set" data="default_password=1234"/>
改为   
  <X-PRE-PROCESS cmd="set" data="default_password=NLYPx9JjSx"/>
			
				
领域

配置领域

			
<X-PRE-PROCESS cmd="set" data="domain=sip.netkiller.cn"/>			
			
				
公网IP地址

配置公网IP地址

适用场景,公网IP直接在Linux eth0 网卡上配置。

			
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=stun:stun.freeswitch.org"/>
改为
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=host:sip.netkiller.cn"/>
或
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=IP地址"/>
			
				
NAT 配置

前面的基本配置,是物理服务器网卡直接配置公网IP地址,很多云主机采用弹性IP机制,将公网IP映射到云主机上。这种模式就需要用到 NAT

配置方法还是修改 /etc/freeswitch/vars.xml 文件

			
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=autonat:你的公网IP地址"/>
			
				

			
  <X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=autonat:121.37.25.251"/>
  <X-PRE-PROCESS cmd="stun-set" data="external_sip_ip=autonat:121.37.25.251"/>	
			
				
编码
			
  <X-PRE-PROCESS cmd="set" data="global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>
  <X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>
			
				
控制台日志级别
			
<X-PRE-PROCESS cmd="set" data="console_loglevel=4"/>
或
<X-PRE-PROCESS cmd="set" data="console_loglevel=info"/>
			
				

样本参考

例 168.1. /etc/freeswitch/vars.xml

这是我的配置仅供参考

				
[root@netkiller ~]# xmlstarlet ed -d '//comment()' /etc/freeswitch/vars.xml
<?xml version="1.0"?>
<include>
  <X-PRE-PROCESS cmd="set" data="default_password=******"/>
  <X-PRE-PROCESS cmd="set" data="sound_prefix=$${sounds_dir}/en/us/callie"/>
  <X-PRE-PROCESS cmd="set" data="domain=sip.aigcsst.com"/>
  <X-PRE-PROCESS cmd="set" data="domain_name=$${domain}"/>
  <X-PRE-PROCESS cmd="set" data="hold_music=local_stream://moh"/>
  <X-PRE-PROCESS cmd="set" data="use_profile=external"/>
  <X-PRE-PROCESS cmd="set" data="rtp_sdes_suites=AEAD_AES_256_GCM_8|AEAD_AES_128_GCM_8|AES_CM_256_HMAC_SHA1_80|AES_CM_192_HMAC_SHA1_80|AES_CM_128_HMAC_SHA1_80|AES_CM_256_HMAC_SHA1_32|AES_CM_192_HMAC_SHA1_32|AES_CM_128_HMAC_SHA1_32|AES_CM_128_NULL_AUTH"/>
  <X-PRE-PROCESS cmd="set" data="global_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>
  <X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=OPUS,G722,PCMU,PCMA,H264,VP8"/>
  <X-PRE-PROCESS cmd="set" data="xmpp_client_profile=xmppc"/>
  <X-PRE-PROCESS cmd="set" data="xmpp_server_profile=xmpps"/>
  <X-PRE-PROCESS cmd="set" data="bind_server_ip=auto"/>
  <X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=autonat:121.37.215.251"/>
  <X-PRE-PROCESS cmd="stun-set" data="external_sip_ip=autonat:121.37.215.251"/>
  <X-PRE-PROCESS cmd="set" data="unroll_loops=true"/>
  <X-PRE-PROCESS cmd="set" data="outbound_caller_name=FreeSWITCH"/>
  <X-PRE-PROCESS cmd="set" data="outbound_caller_id=0000000000"/>
  <X-PRE-PROCESS cmd="set" data="call_debug=false"/>
  <X-PRE-PROCESS cmd="set" data="console_loglevel=info"/>
  <X-PRE-PROCESS cmd="set" data="default_areacode=918"/>
  <X-PRE-PROCESS cmd="set" data="default_country=US"/>
  <X-PRE-PROCESS cmd="set" data="presence_privacy=false"/>
  <X-PRE-PROCESS cmd="set" data="au-ring=%(400,200,383,417);%(400,2000,383,417)"/>
  <X-PRE-PROCESS cmd="set" data="be-ring=%(1000,3000,425)"/>
  <X-PRE-PROCESS cmd="set" data="ca-ring=%(2000,4000,440,480)"/>
  <X-PRE-PROCESS cmd="set" data="cn-ring=%(1000,4000,450)"/>
  <X-PRE-PROCESS cmd="set" data="cy-ring=%(1500,3000,425)"/>
  <X-PRE-PROCESS cmd="set" data="cz-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="de-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="dk-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="dz-ring=%(1500,3500,425)"/>
  <X-PRE-PROCESS cmd="set" data="eg-ring=%(2000,1000,475,375)"/>
  <X-PRE-PROCESS cmd="set" data="es-ring=%(1500,3000,425)"/>
  <X-PRE-PROCESS cmd="set" data="fi-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="fr-ring=%(1500,3500,440)"/>
  <X-PRE-PROCESS cmd="set" data="hk-ring=%(400,200,440,480);%(400,3000,440,480)"/>
  <X-PRE-PROCESS cmd="set" data="hu-ring=%(1250,3750,425)"/>
  <X-PRE-PROCESS cmd="set" data="il-ring=%(1000,3000,400)"/>
  <X-PRE-PROCESS cmd="set" data="in-ring=%(400,200,425,375);%(400,2000,425,375)"/>
  <X-PRE-PROCESS cmd="set" data="jp-ring=%(1000,2000,420,380)"/>
  <X-PRE-PROCESS cmd="set" data="ko-ring=%(1000,2000,440,480)"/>
  <X-PRE-PROCESS cmd="set" data="pk-ring=%(1000,2000,400)"/>
  <X-PRE-PROCESS cmd="set" data="pl-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="ro-ring=%(1850,4150,475,425)"/>
  <X-PRE-PROCESS cmd="set" data="rs-ring=%(1000,4000,425)"/>
  <X-PRE-PROCESS cmd="set" data="ru-ring=%(800,3200,425)"/>
  <X-PRE-PROCESS cmd="set" data="sa-ring=%(1200,4600,425)"/>
  <X-PRE-PROCESS cmd="set" data="tr-ring=%(2000,4000,450)"/>
  <X-PRE-PROCESS cmd="set" data="uk-ring=%(400,200,400,450);%(400,2000,400,450)"/>
  <X-PRE-PROCESS cmd="set" data="us-ring=%(2000,4000,440,480)"/>
  <X-PRE-PROCESS cmd="set" data="bong-ring=v=-7;%(100,0,941.0,1477.0);v=-7;&gt;=2;+=.1;%(1400,0,350,440)"/>
  <X-PRE-PROCESS cmd="set" data="beep=%(1000,0,640)"/>
  <X-PRE-PROCESS cmd="set" data="sit=%(274,0,913.8);%(274,0,1370.6);%(380,0,1776.7)"/>
  <X-PRE-PROCESS cmd="set" data="df_us_ssn=(?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}"/>
  <X-PRE-PROCESS cmd="set" data="df_luhn=?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11}"/>
  <XX-PRE-PROCESS cmd="set" data="digits_dialed_filter=(($${df_luhn})|($${df_us_ssn}))"/>
  <X-PRE-PROCESS cmd="set" data="default_provider=example.com"/>
  <X-PRE-PROCESS cmd="set" data="default_provider_username=joeuser"/>
  <X-PRE-PROCESS cmd="set" data="default_provider_password=password"/>
  <X-PRE-PROCESS cmd="set" data="default_provider_from_domain=example.com"/>
  <X-PRE-PROCESS cmd="set" data="default_provider_register=false"/>
  <X-PRE-PROCESS cmd="set" data="default_provider_contact=5000"/>
  <X-PRE-PROCESS cmd="set" data="sip_tls_version=tlsv1,tlsv1.1,tlsv1.2"/>
  <X-PRE-PROCESS cmd="set" data="sip_tls_ciphers=ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"/>
  <X-PRE-PROCESS cmd="set" data="internal_auth_calls=true"/>
  <X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/>
  <X-PRE-PROCESS cmd="set" data="internal_tls_port=5061"/>
  <X-PRE-PROCESS cmd="set" data="internal_ssl_enable=false"/>
  <X-PRE-PROCESS cmd="set" data="external_auth_calls=false"/>
  <X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/>
  <X-PRE-PROCESS cmd="set" data="external_tls_port=5081"/>
  <X-PRE-PROCESS cmd="set" data="external_ssl_enable=false"/>
  <X-PRE-PROCESS cmd="set" data="rtp_video_max_bandwidth_in=3mb"/>
  <X-PRE-PROCESS cmd="set" data="rtp_video_max_bandwidth_out=3mb"/>
  <X-PRE-PROCESS cmd="set" data="suppress_cng=true"/>
  <X-PRE-PROCESS cmd="set" data="rtp_liberal_dtmf=true"/>
  <X-PRE-PROCESS cmd="set" data="video_mute_png=$${images_dir}/default-mute.png"/>
  <X-PRE-PROCESS cmd="set" data="video_no_avatar_png=$${images_dir}/default-avatar.png"/>
</include>
				
					

168.1.4.2. 配置 sip_profiles

通常在 /etc/freeswitch/vars.xml 中配置,在 internal.xml 和 external.xml 中通过变量引用

			
[root@netkiller ~]# cp /etc/freeswitch/sip_profiles/internal.xml{,.backup}
[root@netkiller ~]# cp /etc/freeswitch/sip_profiles/external.xml{,.backup}
[root@netkiller ~]# cp /etc/freeswitch/sip_profiles/internal-ipv6.xml{,.backup}
[root@netkiller ~]# cp /etc/freeswitch/sip_profiles/external-ipv6.xml{,.backup}
			
			

NAT 配置 172.16.0.10 替换成公网 IP 地址

			
[root@netkiller ~]# vim /etc/freeswitch/sip_profiles/internal.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="autonat:172.16.0.10"/>
	<param name="ext-sip-ip" value="autonat:172.16.0.10"/>		
	
			
			

			
[root@netkiller ~]# vim /etc/freeswitch/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="autonat:172.16.0.10"/>
	<param name="ext-sip-ip" value="autonat:172.16.0.10"/>    			
			
			
旁路模式

配置 inbound-bypass-media 可以开启旁路模式,在此模式 下FreeSWITCH 只负责 SIP 信令交换,两个 endpoint 话机 RIP 语音通信是点对点方式。这样比较节省流量,但是国内网络复杂,层层 NAT 常常出现局域网正常,部署到广域网就会失败,现象是拨通之后没有语音。

				
[root@netkiller ~]# grep -r 'inbound-bypass-media' /etc/freeswitch/sip_profiles/internal.xml
    <!--<param name="inbound-bypass-media" value="true"/>-->	
				
				
启用 100rel
				
[root@netkiller ~]# grep 100rel /etc/freeswitch/sip_profiles/internal.xml
        There are known issues (asserts and segfaults) when 100rel is enabled.
        It is not recommended to enable 100rel at this time.
    <!--<param name="enable-100rel" value="true"/>-->

[root@netkiller ~]# vim /etc/freeswitch/sip_profiles/internal.xml

[root@netkiller ~]# systemctl restart  freeswitch

[root@netkiller ~]# grep 100rel /etc/freeswitch/sip_profiles/internal.xml
        There are known issues (asserts and segfaults) when 100rel is enabled.
        It is not recommended to enable 100rel at this time.
    <param name="enable-100rel" value="true"/>				
				
				

168.1.4.3. switch.conf.xml

			
[root@netkiller ~]# cp /etc/freeswitch/autoload_configs/switch.conf.xml{,.backup}
[root@netkiller ~]# xmlstarlet ed -d '//comment()' /etc/freeswitch/autoload_configs/switch.conf.xml
			
			

配置交换机名称

			
    <param name="switchname" value="netkiller"/>			
			
			

RTP 端口范围

			
    <!-- RTP port range -->
    <!-- <param name="rtp-start-port" value="16384"/> -->
    <!-- <param name="rtp-end-port" value="32768"/> -->			
			
			

日志级别

			
<param name="loglevel" value="debug"/>
			
			

168.1.4.4. fs_cli Socket Client 配置

默认是 :: 表示 ipv6 localhost,如果需要远程访问可以改为 listen-ip 0.0.0.0

			
[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			
			
			

168.1.4.5. 网关配置

参考 /etc/freeswitch/sip_profiles/external/example.xml 文件

			
[root@netkiller ~]# cat /etc/freeswitch/sip_profiles/external/example.xml
<include>
  <!--<gateway name="asterlink.com">-->
  <!--/// account username *required* ///-->
  <!--<param name="username" value="cluecon"/>-->
  <!--/// auth realm: *optional* same as gateway name, if blank ///-->
  <!--<param name="realm" value="asterlink.com"/>-->
  <!--/// username to use in from: *optional* same as  username, if blank ///-->
  <!--<param name="from-user" value="cluecon"/>-->
  <!--/// domain to use in from: *optional* same as  realm, if blank ///-->
  <!--<param name="from-domain" value="asterlink.com"/>-->
  <!--/// account password *required* ///-->
  <!--<param name="password" value="2007"/>-->
  <!--/// extension for inbound calls: *optional* same as username, if blank ///-->
  <!--<param name="extension" value="cluecon"/>-->
  <!--/// proxy host: *optional* same as realm, if blank ///-->
  <!--<param name="proxy" value="asterlink.com"/>-->
  <!--/// send register to this proxy: *optional* same as proxy, if blank ///-->
  <!--<param name="register-proxy" value="mysbc.com"/>-->
  <!--/// expire in seconds: *optional* 3600, if blank ///-->
  <!--<param name="expire-seconds" value="60"/>-->
  <!--/// do not register ///-->
  <!--<param name="register" value="false"/>-->
  <!-- which transport to use for register -->
  <!--<param name="register-transport" value="udp"/>-->
  <!--How many seconds before a retry when a failure or timeout occurs -->
  <!--<param name="retry-seconds" value="30"/>-->
  <!--Use the callerid of an inbound call in the from field on outbound calls via this gateway -->
  <!--<param name="caller-id-in-from" value="false"/>-->
  <!--extra sip params to send in the contact-->
  <!--<param name="contact-params" value=""/>-->
  <!-- Put the extension in the contact -->
  <!--<param name="extension-in-contact" value="true"/>-->
  <!--send an options ping every x seconds, failure will unregister and/or mark it down-->
  <!--<param name="ping" value="25"/>-->
  <!--<param name="cid-type" value="rpid"/>-->
  <!--rfc5626 : Abilitazione rfc5626 ///-->
  <!--<param name="rfc-5626" value="true"/>-->
  <!--rfc5626 : extra sip params to send in the contact-->
  <!--<param name="reg-id" value="1"/>-->
  <!--</gateway>-->
</include>
			
			

配置网关

			
[root@netkiller ~]# cat > /etc/freeswitch/sip_profiles/external/hamsoverip.xml <<EOF
<include>
	<gateway name="hamsoverip">
		<param name="username" value="300177"/>
		<param name="realm" value="pbx-ap.hamsoverip.com:5160"/>
		<param name="password" value="178aee323ef95"/>
		<param name="register" value="true"/>
		<param name="register-transport" value="udp"/>
	</gateway>
</include>
EOF
			
			

配置拨号规则

			
[root@netkiller ~]# cat > /etc/freeswitch/dialplan/default/hamsoverip.com.xml <<"EOF"
<include>
	<extension name="hamsoverip.com">
		<condition field="destination_number" expression="^300(\d+)$">
			<action application="bridge" data="sofia/gateway/hamsoverip/300$1"/>
		</condition>
	</extension>
</include>
EOF
			
			

168.1.4.6. 新增号段

			
[root@netkiller ~]# cp /etc/freeswitch/dialplan/default.xml{,.backup}			
			
			
			
[root@netkiller ~]# vim /etc/freeswitch/dialplan/default.xml			
    <extension name="Local_Extension">
      <condition field="destination_number" expression="^(10[01][0-9])$">
        <action application="export" data="dialed_extension=$1"/>
        <!-- bind_meta_app can have these args <key> [a|b|ab] [a|b|o|s] <app> -->
        <action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
        <action application="bind_meta_app" data="2 b s record_session::$${recordings_dir}/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
        <action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
        <action application="bind_meta_app" data="4 b s execute_extension::att_xfer XML features"/>
        <action application="set" data="ringback=${us-ring}"/>
        <action application="set" data="transfer_ringback=$${hold_music}"/>
        <action application="set" data="call_timeout=30"/>
        <!-- <action application="set" data="sip_exclude_contact=${network_addr}"/> -->
        <action application="set" data="hangup_after_bridge=true"/>
        <!--<action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION"/> -->
        <action application="set" data="continue_on_fail=true"/>
        <action application="hash" data="insert/${domain_name}-call_return/${dialed_extension}/${caller_id_number}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/${dialed_extension}/${uuid}"/>
        <action application="set" data="called_party_callgroup=${user_data(${dialed_extension}@${domain_name} var callgroup)}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/${called_party_callgroup}/${uuid}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/global/${uuid}"/>
        <!--<action application="export" data="nolocal:rtp_secure_media=${user_data(${dialed_extension}@${domain_name} var rtp_secure_media)}"/>-->
        <action application="hash" data="insert/${domain_name}-last_dial/${called_party_callgroup}/${uuid}"/>
        <action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
        <action application="answer"/>
        <action application="sleep" data="1000"/>
        <action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>
      </condition>
    </extension>
			
			

默认拨号规则是 1000~1019

			
<condition field="destination_number" expression="^(10[01][0-9])$">			
			
			

改为 1000~1099

			
<condition field="destination_number" expression="^(10[0-9][0-9])$">			
			
			

分机号段为 1000~1999,2000

			
<condition field="destination_number" expression="^(1[0-9][0-9][0-9]|2000)$">			
			
			

30000~39999 | 1000~1019

			
  <condition field="destination_number" expression="^(3\d{4}|10[01][0-9])$">
			
			

长度 3 或 4 位数 100~199, 1000~1999

			
<condition field="destination_number" expression="^(1\d{2,3})$">			
			
			

例 168.2. 拨号规则,配置两个号段 100~199,1000~1999

拨出规则

				
[root@netkiller ~]# vim /etc/freeswitch/dialplan/default.xml				
    <extension name="Local_Extension">
      <!-- <condition field="destination_number" expression="^(10[01][0-9])$"> -->
      <condition field="destination_number" expression="^(1\d{2,3})$">
        <action application="export" data="dialed_extension=$1"/>
        <!-- bind_meta_app can have these args <key> [a|b|ab] [a|b|o|s] <app> -->
        <action application="bind_meta_app" data="1 b s execute_extension::dx XML features"/>
        <action application="bind_meta_app" data="2 b s record_session::$${recordings_dir}/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
        <action application="bind_meta_app" data="3 b s execute_extension::cf XML features"/>
        <action application="bind_meta_app" data="4 b s execute_extension::att_xfer XML features"/>
        <action application="set" data="ringback=${us-ring}"/>
        <action application="set" data="transfer_ringback=$${hold_music}"/>
        <action application="set" data="call_timeout=30"/>
        <!-- <action application="set" data="sip_exclude_contact=${network_addr}"/> -->
        <action application="set" data="hangup_after_bridge=true"/>
        <!--<action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION"/> -->
        <action application="set" data="continue_on_fail=true"/>
        <action application="hash" data="insert/${domain_name}-call_return/${dialed_extension}/${caller_id_number}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/${dialed_extension}/${uuid}"/>
        <action application="set" data="called_party_callgroup=${user_data(${dialed_extension}@${domain_name} var callgroup)}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/${called_party_callgroup}/${uuid}"/>
        <action application="hash" data="insert/${domain_name}-last_dial_ext/global/${uuid}"/>
        <!--<action application="export" data="nolocal:rtp_secure_media=${user_data(${dialed_extension}@${domain_name} var rtp_secure_media)}"/>-->
        <action application="hash" data="insert/${domain_name}-last_dial/${called_party_callgroup}/${uuid}"/>
        <action application="bridge" data="user/${dialed_extension}@${domain_name}"/>
        <action application="answer"/>
        <action application="sleep" data="1000"/>
        <action application="bridge" data="loopback/app=voicemail:default ${domain_name} ${dialed_extension}"/>
      </condition>
    </extension>				
				
				

拨入规则

				
[root@netkiller ~]# cp /etc/freeswitch/dialplan/public.xml{,.backup}

    <extension name="public_extensions">
      <!-- <condition field="destination_number" expression="^(10[01][0-9])$"> -->
      <condition field="destination_number" expression="^(1\d{2,3})$">
        <action application="transfer" data="$1 XML default"/>
      </condition>
    </extension>
				
				

168.1.4.7. logfile.conf.xml

			
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/logfile.conf.xml 
<configuration name="logfile.conf" description="File Logging">
  <settings>
   <!-- true to auto rotate on HUP, false to open/close -->
   <param name="rotate-on-hup" value="true"/>
  </settings>
  <profiles>
    <profile name="default">
      <settings>
        <!-- File to log to -->
        <!--<param name="logfile" value="/var/log/freeswitch.log"/>-->
        <!-- At this length in bytes rotate the log file (0 for never) -->
        <param name="rollover" value="1048576000"/>
                <!-- Maximum number of log files to keep before wrapping -->
                <!-- If this parameter is enabled, the log filenames will not include a date stamp -->
                <param name="maximum-rotate" value="32"/>
        <!-- Prefix all log lines by the session's uuid  -->
        <param name="uuid" value="true" />
      </settings>
      <mappings>
        <!-- 
             name can be a file name, function name or 'all' 
             value is one or more of debug,info,notice,warning,err,crit,alert,all
             Please see comments in console.conf.xml for more information
        -->
        <map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
      </mappings>
    </profile>
  </profiles>
</configuration>			
			
			

168.1.4.8. 视频通话

新增一项 proxy_media 配置

		
echo '<X-PRE-PROCESS cmd="set" data="proxy_media=true"/>' >> /etc/freeswitch/vars.xml

[root@netkiller ~]# echo '<X-PRE-PROCESS cmd="set" data="proxy_media=true"/>' >> /etc/freeswitch/vars.xml
[root@netkiller ~]# grep  'proxy_media' /etc/freeswitch/vars.xml
<X-PRE-PROCESS cmd="set" data="proxy_media=true"/>
		
			

去掉 inbound-proxy-media 注释

		
[root@netkiller ~]# egrep "inbound-proxy-media|inbound-late-negotiation" /etc/freeswitch/sip_profiles/internal.xml
    <!--<param name="inbound-proxy-media" value="true"/>-->
    <param name="inbound-late-negotiation" value="true"/>
    
<!--<param name="inbound-proxy-media" value="true"/>-->
修改
<param name="inbound-proxy-media" value="true"/>
    
[root@netkiller ~]# egrep "inbound-proxy-media|inbound-late-negotiation" /etc/freeswitch/sip_profiles/internal.xml
    <param name="inbound-proxy-media" value="true"/>
    <param name="inbound-late-negotiation" value="true"/>    
		
			

168.1.4.9. 语音邮箱(voicemail)

确认 voicemail 模块是否启用

		
[root@netkiller ~]# grep voicemail /etc/freeswitch/autoload_configs/modules.conf.xml 
    <load module="mod_voicemail"/>		
		
			

语音信箱存储目录

		
[root@netkiller ~]# ls /var/lib/freeswitch/storage/voicemail/default/sip.aigcsst.com/
1000  1001  1002  1003  1004  1005  1006  1007  1009  1010  1011  1012  1013		
		
			

拨打4000,根据提示输入user id和密码,就可以收听到留言了。

168.1.4.10. 多租户(多领域)配置

[root@production ~]# cat /etc/freeswitch/directory/default/1000.xml <include> <domain name="sip.netkiller.cn"> <user id="1000"> <params> <param name="password" value="1234"/> </params> </user> <user id="1001"> <params> <param name="password" value="1234"/> </params> </user> </domain> <domain name="voip.netkiller.cn"> <user id="1000"> <params> <param name="password" value="1234"/> </params> </user> <user id="1001"> <params> <param name="password" value="1234"/> </params> </user> </domain> </include>

168.1.5. MySQL 模块配置

168.1.5.1. 安装 mariadb

			
yum install -y mariadb mariadb-server
service mariadb start
systemctl enable mariadb
mysql_secure_installation 			
			
			

168.1.5.2. 安装模块

			
[root@netkiller ~]# dnf install -y freeswitch-database-mariadb			
			
			

168.1.5.3. 启用 mysql 支持

			
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/pre_load_modules.conf.xml
<configuration name="pre_load_modules.conf" description="Modules">
  <modules>
    <!-- Databases -->
    <!-- <load module="mod_mariadb"/> -->
    <load module="mod_pgsql"/>
  </modules>
</configuration>		
			
			

注释 mod_pgsql 启用 mod_mariadb

			
    <load module="mod_mariadb"/>
    <!-- <load module="mod_pgsql"/> -->
			
			

168.1.5.4. db.conf.xml

			
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/db.conf.xml 
<configuration name="db.conf" description="LIMIT DB Configuration">
  <settings>
    <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
  </settings>
</configuration>			
			
			

			
<configuration name="db.conf" description="LIMIT DB Configuration">
  <settings>
    <param name="core-db-dsn" value="mariadb://Server=192.168.0.11;Port=3307;Database=freeswitch;Uid=root;Pwd=123456;" />
  </settings>
</configuration>
			
			
			

168.1.5.5. switch.conf.xml

修改下面文件中的 core-db-dsn

			
[root@netkiller ~]# vim /etc/freeswitch/autoload_configs/switch.conf.xml		
			
			
			
[root@netkiller ~]# cat /etc/freeswitch/autoload_configs/switch.conf.xml | grep dsn
    <!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'" /> -->
    <!-- <param name="core-db-dsn" value="postgresql://freeswitch:@127.0.0.1/freeswitch?options=-c%20client_min_messages%3DNOTICE" /> -->
    <param name="core-db-dsn" value="mariadb://Server=localhost;Database=freeswitch;Uid=freeswitch;Pwd=pass;" />
    <!-- <param name="core-db-dsn" value="dsn:username:password" /> -->			
			
			

168.1.5.6. 修改 sip_profile 配置文件

数据源格式

			
mariadb://Server=localhost;Database=freeswitch;Uid=freeswitch;Pwd=pass;		
			
			

修改下面文件中的 odbc-dsn

			
[root@netkiller ~]# vim /etc/freeswitch/autoload_configs/switch.conf.xml
[root@netkiller ~]# vim /etc/freeswitch/autoload_configs/db.conf.xml
[root@netkiller ~]# vim /etc/freeswitch/sip_profiles/internal.xml
[root@netkiller ~]# vim /etc/freeswitch/sip_profiles/internal-ipv6.xml
			
			

168.1.5.7. 检查配置

用下面命令检查是否遗漏

			
[root@netkiller ~]# grep -r 'odbc-dsn' /etc/freeswitch/*/*.xml
[root@netkiller ~]# grep -r 'core-db-dsn' /etc/freeswitch/*/*.xml
			
			

168.1.6. 测试号码

freeswitch提供了测试号码

		
号码		说明
9664	保持音乐
9196	echo,回音测试
9195	echo,回音测试,延迟5秒
9197	milliwatte extension,铃音生成
9198	TGML 铃音生成示例
5000	示例IVR4000听取语音信箱
33xx	电话会议,48K(其中xx可为00-99,下同)
32xx	电话会议,32K
31xx	电话会议,16K
30xx	电话会议,8K
2000-2002	呼叫组
1000-1019	默认分机号
		
		

168.1.6.1. 测试分机号

1000-1019 测试账号位置

			
[root@netkiller ~]# ls /etc/freeswitch/directory/default/
1000.xml  1002.xml  1004.xml  1006.xml  1008.xml  1010.xml  1012.xml  1014.xml  1016.xml  1018.xml  brian.xml    example.com.xml
1001.xml  1003.xml  1005.xml  1007.xml  1009.xml  1011.xml  1013.xml  1015.xml  1017.xml  1019.xml  default.xml  skinny-example.xml			
			
			

用户配置文件

			
[root@netkiller ~]# cat /etc/freeswitch/directory/default/1000.xml 
<include>
  <user id="1000">
    <params>
      <param name="password" value="$${default_password}"/>
      <param name="vm-password" value="1000"/>
    </params>
    <variables>
      <variable name="toll_allow" value="domestic,international,local"/>
      <variable name="accountcode" value="1000"/>
      <variable name="user_context" value="default"/>
      <variable name="effective_caller_id_name" value="Extension 1000"/>
      <variable name="effective_caller_id_number" value="1000"/>
      <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
      <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
      <variable name="callgroup" value="techsupport"/>
    </variables>
  </user>
</include>
			
			

账号密码在 /etc/freeswitch/vars.xml 配置文件中

			
<X-PRE-PROCESS cmd="set" data="default_password=eFyS2wcZo1zKZ3KG"/>
			
			

用下面方法查看密码

			
[root@netkiller ~]# cat /etc/freeswitch/vars.xml | grep default_password
       YOU SHOULD CHANGE THIS default_password value if you don't want to be subject to any
  <X-PRE-PROCESS cmd="set" data="default_password=eFo1zKZyS2wcZ3KG"/>		
			
			

168.1.7. fs_cli

进入 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	
		
		

168.1.7.1. 退出 fs_cli

			
/exit
			
			

168.1.7.2. 日志

loglevel

console loglevel (0~7)

			
console loglevel 3			
			
				
关闭日志
			
freeswitch@-ERR switchname Command not found!> /nolog
+OK no longer logging			
			
				

168.1.7.3. profile

			
打开sip详细日志
sofia profile internal siptrace on

关闭sip详细日志
sofia profile internal siptrace off			
			
			

168.1.7.4. sofia status

			
[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			
			
			

168.1.7.5. sip 抓包

			
sofia profile internal siptrace on
sofia profile external siptrace on	
			
			

168.1.7.6. internal 状态查看

			
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.aigcsst.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
			
			
			

168.1.7.7. external 状态

			
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			
			
			

168.1.7.8. 注册状态查看

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

168.1.7.9. 呼叫

重新扫描加载 sip profile

			
sofia profile internal rescan
sofia profile external rescan
			
			

重启 sip profile

			
sofia profile internal restart
sofia profile external restart
			
			

168.1.7.10. 呼叫

			
# 显示当前呼叫
show calls

# 显示呼叫数量
show calls count

# 挂断某个呼叫
uuid_kill 59b857d2-d7b8-4c7e-6666-e19be0f16643

# 挂断所有呼叫
hupall

# 拨打某个用户并启用echo回音
originate user/1000 &echo
			
			

168.1.7.11. 呼叫测试

			
回音测试
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
			
			

168.1.7.12. 正则测试

			
regex 123123 | \d
regex 123123 | ^\d*
			
			

168.1.7.13. 变量求值

			
eval $${mod_dir}
eval $${recording_dir}
			
			

168.1.8. 中文语音包

https://files.freeswitch.org/releases/sounds/
		
[   ]	freeswitch-sounds-zh-cn-sinmei-8000-1.0.51.tar.gz	2014-10-09 20:21	296K	 
[   ]	freeswitch-sounds-zh-cn-sinmei-8000-1.0.51.tar.gz.md5	2014-10-09 20:21	92	 
[   ]	freeswitch-sounds-zh-cn-sinmei-8000-1.0.51.tar.gz.sha1	2014-10-09 20:21	101	 
[   ]	freeswitch-sounds-zh-cn-sinmei-8000-1.0.51.tar.gz.sha256	2014-10-09 20:21	127	 
[   ]	freeswitch-sounds-zh-cn-sinmei-16000-1.0.51.tar.gz	2014-10-09 20:21	583K	 
[   ]	freeswitch-sounds-zh-cn-sinmei-16000-1.0.51.tar.gz.md5	2014-10-09 20:21	93	 
[   ]	freeswitch-sounds-zh-cn-sinmei-16000-1.0.51.tar.gz.sha1	2014-10-09 20:21	102	 
[   ]	freeswitch-sounds-zh-cn-sinmei-16000-1.0.51.tar.gz.sha256	2014-10-09 20:21	128	 
[   ]	freeswitch-sounds-zh-cn-sinmei-32000-1.0.51.tar.gz	2014-10-09 20:21	1.1M	 
[   ]	freeswitch-sounds-zh-cn-sinmei-32000-1.0.51.tar.gz.md5	2014-10-09 20:21	93	 
[   ]	freeswitch-sounds-zh-cn-sinmei-32000-1.0.51.tar.gz.sha1	2014-10-09 20:21	102	 
[   ]	freeswitch-sounds-zh-cn-sinmei-32000-1.0.51.tar.gz.sha256	2014-10-09 20:21	128	 
[   ]	freeswitch-sounds-zh-cn-sinmei-48000-1.0.51.tar.gz	2014-10-09 20:21	1.6M	 
[   ]	freeswitch-sounds-zh-cn-sinmei-48000-1.0.51.tar.gz.md5	2014-10-09 20:21	93	 
[   ]	freeswitch-sounds-zh-cn-sinmei-48000-1.0.51.tar.gz.sha1	2014-10-09 20:21	102	 
[   ]	freeswitch-sounds-zh-cn-sinmei-48000-1.0.51.tar.gz.sha256	2014-10-09 20:21	128	 
		
		

编译 mod_say_zh 模块

		
cd /usr/local/src/freeswitch/src/mod/say/mod_say_zh
 
make && make install		
		
		

autoload_configs/modules.conf.xml

		
    <!-- Say -->
    <load module="mod_say_en"/>
 
    <load module="mod_say_zh"/>
		
		
		

		
cd /usr/local/freeswitch/conf/lang/
cp -fr en zh
cd zh
mv en.xml zh.xml
		
		
		

zh.xml

		
<language name="zh" say-module="zh" sound-prefix="$${sounds_dir}/zh/cn/link" tts-engine="mod_tts_commandline" tts-voice="link">		
		
		

vars.xml

		
  <X-PRE-PROCESS cmd="set" data="sound_prefix=$${sounds_dir}/zh/cn/link"/>
  <X-PRE-PROCESS cmd="set" data="default_language=zh"/>
  <X-PRE-PROCESS cmd="set" data="default_dialect=cn"/>
  <X-PRE-PROCESS cmd="set" data="default_voice=link"/>		
		
		

freeswitch.xml

		
<X-PRE-PROCESS cmd="include" data="lang/zh/*.xml"/>		
		
		

fs_cli 手动加载模块

		 
load mod_say_zh
reloadxml
		
		
		

配置 Dialplan 拨号计划 dialplan/default.xml

		
    <!--say测试-->
	<extension name="socket_767_example">
		<condition field="destination_number" expression="^767\d+$">
		    <action application="answer"/>
			<action application="say" data="zh name_spelled intered 3456789"></action>
            <action application="say" data="en NUMBER intered 3456789"></action>
            <action application="say" data="zh TELEPHONE_NUMBER intered 13781655437"></action>
            <action application="playback" data="voicemail/vm-goodbye.wav"></action>
		</condition>
	</extension>
		
		

单个用户配置 1001.xml

		
<variable name="language" value="zh"/>
<variable name="default_language" value="zh"/>		
		
		

dialplan中配置中文

		
	<extension name="ivr_demo">
      <condition field="destination_number" expression="^5000$">
        <action application="set" data="language=zh"/>
        <action application="answer"/>
        <action application="sleep" data="2000"/>
        <action application="ivr" data="demo_ivr"/>
      </condition>
    </extension>
		
		
		

168.1.9. fusionPBX

168.1.10. 开发

168.1.10.1. FreeSWITCH 用户管理

https://github.com/netkiller/freeswitch
			
# freeswitch 用户管理

## 安装依赖

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

## 帮助信息

```shell
PS D:\GitHub\freeswitch> python.exe .\freeswitch.py -h
usage: freeswitch.py [-h] [-a <number> <callsign> <callgroup> [<number> <callsign> <callgroup> ...]] [-r 1000] [-l] [-s 1000] [-d]

FreeSWITCH 用户管理工具

options:
  -h, --help            show this help message and exit
  -a <number> <callsign> <callgroup> [<number> <callsign> <callgroup> ...], --add <number> <callsign> <callgroup> [<number> <callsign> <callgroup> ...]
                        添加用户
  -r 1000, --remove 1000
                        删除用户
  -l, --list            列出用户
  -s 1000, --show 1000  查看用户
  -d, --debug           调试模式

Author: netkiller - https://www.netkiller.cn/linux/

```

## 添加用户

```shell
PS D:\GitHub\freeswitch> python.exe .\freeswitch.py -a 1000 BG7NYT admin 
```

## 查看用于

```shell
PS D:\GitHub\freeswitch> python.exe .\freeswitch.py -s 1000             
<include>
        <user id="1000">
                <params>
                        <param name="password" value="B5AbNCYj"/>
                        <param name="vm-password" value="1000"/>
                </params>
                <variables>
                        <variable name="toll_allow" value="domestic,international,local"/>
                        <variable name="accountcode" value="1000"/>
                        <variable name="user_context" value="default"/>
                        <variable name="effective_caller_id_name" value="BG7NYT"/>
                        <variable name="effective_caller_id_number" value="1000"/>
                        <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
                        <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
                        <variable name="callgroup" value="admin"/>
                </variables>
        </user>
</include>
```

## 列出所有用户

```shell
PS D:\GitHub\freeswitch> python.exe .\freeswitch.py -l                  
+----------+--------+----------+----------+--------+
| 电话号码 |  呼号  |   密码   | 语音信箱 | 呼叫组 |
+==========+========+==========+==========+========+
| 1000     | BG7NYT | HbM3imgb | 2031     | admin  |
+----------+--------+----------+----------+--------+
| 1003     | BG7NYT | 1u3Fc6t4 | 5927     | 33333  |
+----------+--------+----------+----------+--------+

```

## 删除用户

```shell
PS D:\GitHub\freeswitch> python.exe .\freeswitch.py -r 1000
```			
			
			

168.1.10.2. Java 开发包

			
        <dependency>
            <groupId>link.thingscloud</groupId>
            <artifactId>freeswitch-esl-spring-boot-starter</artifactId>
            <version>2.0.0</version>
        </dependency>