Centos7 Freeswitch 1.10.12+Spandsp+Sofia-sip 编译安装、防火墙保护和Linephone互联

1.安装依赖

yum install gcc gcc-c++  
yum install -y wget zlib-devel libjpeg-devel freetype-devel

 2.安装官方插件

yum install -y epel-release 
yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel libdb4-devel e2fsprogs-devel erlang flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel libshout-devel libmpg123-devel lame-devel rpm-build libX11-devel libyuv-devel

3.编译环境准备

3.1 安装cmake

    安装脚本如下:

wget https://homemedical-jy-dev.obs.cn-north-4.myhuaweicloud.com/cmake-3.23.0.tar.gz
tar -zvxf cmake-3.23.0.tar.gz
cd cmake-3.23.0
./bootstrap //编译
make //安装
make install
 #链接
sudo ln -sf /usr/local/bin/cmake /usr/bin/cmake
sudo ln -sf /usr/local/bin/cpack /usr/bin/cpack
sudo ln -sf /usr/local/bin/ctest /usr/bin/ctest

    安装完毕后检查如下:

#检查
cmake -version

3.2 安装autoconf

    autoconf-2.71及以上版本(http://mirrors.kernel.org/gnu/autoconf/),安装脚本如下:

#autoconf-2.71及以上版本(http://mirrors.kernel.org/gnu/autoconf/)
wget http://mirrors.kernel.org/gnu/autoconf/autoconf-2.71.tar.gz
tar xzvf autoconf-2.71.tar.gz
cd autoconf-2.71
./configure  //做相关编译前的环境检查
make
make install

    安装完毕后检查如下:

#检查
autoconf -V

3.3 安装yasm

    安装脚本如下:

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -xvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make && make install

    安装完毕后检查如下:

#检查
yasm -version

3.4 安装nasm

安装脚本如下:

wget https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz
(wget https://homemedical-jy-dev.obs.cn-north-4.myhuaweicloud.com/nasm-2.14.tar.gz)
tar -zxvf nasm-2.14.tar.gz
cd nasm-2.14
./configure
make && make install

    安装完毕后检查如下:

#检查
nasm -version

3.5 安装opus

    opus需要提前安装,否则可能报错。报错You must install libopus-dev to build mod_opus. Stop. 安装前需要先卸载自带的opus,执行如下脚本:

yum remove opus

    安装指定版本的opus,安装脚本如下:

wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xvfz opus-1.3.1.tar.gz
cd opus-1.3.1
./configure
make
make install

    安装完毕后,拷贝相关文件,脚本如下:

#cp opus.*(当前安装目录) /usr/lib64/pkgconfig/
cp /usr/local/lib/pkgconfig/opus.*   /usr/lib64/pkgconfig/

    最后,重新安装libsndfile-devel

yum install libsndfile-devel

4.下载Freeswitch 1.10.12+Spandsp+Sofia-sip

    4.1 freeswitch 1.10.12下载

cd ~
git clone -b v1.10.12 https://github.com/signalwire/freeswitch
cd freeswitch

    4.2 spandsp下载(下载后放入到freeswitch目录下)

    注意:这里下载的是从0d2e6ac65e0e8f53d652665a743015a88bf048d4对应提交的版本。

cd ~/freeswitch
git clone https://github.com/freeswitch/spandsp.git
cd spandsp
git checkout -b specialcommit20250228 0d2e6ac65e0e8f53d652665a743015a88bf048d4

    一定注意按照上述指定版本进行安装,不然在对freeswitch进行安装时候会提示如下错误信息

making all mod_spandsp
make[4]: Entering directory `/root/freeswitch/src/mod/applications/mod_spandsp'
  CC       mod_spandsp_la-mod_spandsp.lo
  CC       mod_spandsp_la-udptl.lo
  CC       mod_spandsp_la-mod_spandsp_fax.lo
  CC       mod_spandsp_la-mod_spandsp_dsp.lo
mod_spandsp_dsp.c: In function 'get_v18_mode':
mod_spandsp_dsp.c:159:10: error: 'V18_MODE_5BIT_4545' undeclared (first use in this function)
  int r = V18_MODE_5BIT_4545;
          ^
mod_spandsp_dsp.c:159:10: note: each undeclared identifier is reported only once for each function it appears in
mod_spandsp_dsp.c:165:8: error: 'V18_MODE_5BIT_50' undeclared (first use in this function)
    r = V18_MODE_5BIT_50;
        ^
mod_spandsp_dsp.c: In function 'spandsp_tdd_send_session':
mod_spandsp_dsp.c:216:2: error: too few arguments to function 'v18_init'
  tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  ^
In file included from /usr/local/include/spandsp.h:114:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
mod_spandsp_dsp.c: In function 'spandsp_tdd_encode_session':
mod_spandsp_dsp.c:263:2: error: too few arguments to function 'v18_init'
  pvt->tdd_state = v18_init(NULL, TRUE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
  ^
In file included from /usr/local/include/spandsp.h:114:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
mod_spandsp_dsp.c: In function 'spandsp_tdd_decode_session':
mod_spandsp_dsp.c:341:2: error: too few arguments to function 'v18_init'
  pvt->tdd_state = v18_init(NULL, FALSE, get_v18_mode(session), V18_AUTOMODING_GLOBAL, put_text_msg, pvt);
  ^
In file included from /usr/local/include/spandsp.h:114:0,
                 from mod_spandsp.h:50,
                 from mod_spandsp_dsp.c:36:
/usr/local/include/spandsp/v18.h:138:29: note: declared here
 SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                             ^
make[4]: *** [mod_spandsp_la-mod_spandsp_dsp.lo] Error 1
make[4]: Leaving directory `/root/freeswitch/src/mod/applications/mod_spandsp'
make[3]: *** [mod_spandsp-all] Error 1
make[3]: Leaving directory `/root/freeswitch/src/mod'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/freeswitch/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/freeswitch'
make: *** [all] Error 2
[root@localhost freeswitch]# 

    4.3 sofia-sip下载(下载后放入到freeswitch目录下)

cd ~/freeswitch
git clone https://github.com/freeswitch/sofia-sip.git

5.spandsp安装

    安装spandsp脚本如下:

cd ~/freeswitch/spandsp
./bootstrap.sh -j
./configure
make
make install

    安装完毕后,执行如下命令修改当前用户下文件~/.bashrc,命令如下:

vi ~/.bashrc

    对文件~/.bashrc修改的内容如下:

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} 

    然后执行如下命令使之生效:

source ~/.bashrc

    或者也可以执行如下命令使之生效:

#添加库的路径到系统
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} 
sudo ldconfig

6.sofia-sip安装

    sofia-sip安装脚本如下:

cd ~/freeswitch/sofia-sip
./bootstrap.sh
./configure
make
make install

7.freeswitch 1.10.12安装

    回到freeswitch目录,执行编译命令:

./bootstrap.sh -j

    修改~/freeswitch/module.conf,修改如下内容:

  • 注释掉applications/mod_signalwire
  • 注释掉applications/mod_av
  • 注释掉endpoints/mod_verto
  • 放开注释xml_int/mod_xml_curl

    编译安装freeswitch,脚本如下:

cd ~/freeswitch/
./configure 
make
make -j install

    安装成功后提示信息如下:

----------------------------------------------------------------------
make[5]: Leaving directory `/root/freeswitch/src/mod/xml_int/mod_xml_rpc'
make[4]: Leaving directory `/root/freeswitch/src/mod/xml_int/mod_xml_rpc'
make[3]: Leaving directory `/root/freeswitch/src/mod'
make[3]: Entering directory `/root/freeswitch/src'
make[4]: Entering directory `/root/freeswitch/src'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/root/freeswitch/src'
make[3]: Leaving directory `/root/freeswitch/src'
make[2]: Leaving directory `/root/freeswitch/src'
Making install in build
make[2]: Entering directory `/root/freeswitch/build'
 +---------- FreeSWITCH install Complete ----------+
 + FreeSWITCH has been successfully installed.     +
 +                                                 +
 +       Install sounds:                           +
 +       (uhd-sounds includes hd-sounds, sounds)   +
 +       (hd-sounds includes sounds)               +
 +       ------------------------------------      +
 +                make cd-sounds-install           +
 +                make cd-moh-install              +
 +                                                 +
 +                make uhd-sounds-install          +
 +                make uhd-moh-install             +
 +                                                 +
 +                make hd-sounds-install           +
 +                make hd-moh-install              +
 +                                                 +
 +                make sounds-install              +
 +                make moh-install                 +
 +                                                 +
 +       Install non english sounds:               +
 +       replace XX with language                  +
 +       (ru : Russian)                            +
 +       (fr : French)                             +
 +       ------------------------------------      +
 +                make cd-sounds-XX-install        +
 +                make uhd-sounds-XX-install       +
 +                make hd-sounds-XX-install        +
 +                make sounds-XX-install           +
 +                                                 +
 +       Upgrade to latest:                        +
 +       ----------------------------------        +
 +                make current                     +
 +                                                 +
 +       Rebuild all:                              +
 +       ----------------------------------        +
 +                make sure                        +
 +                                                 +
 +       Install/Re-install default config:        +
 +       ----------------------------------        +
 +                make samples                     +
 +                                                 +
 +                                                 +
 +       Additional resources:                     +
 +       ----------------------------------        +
 +       https://www.freeswitch.org                +
 +       https://freeswitch.org/confluence         +
 +       https://freeswitch.org/jira               +
 +       http://lists.freeswitch.org               +
 +                                                 +
 +       irc.freenode.net / #freeswitch            +
 +                                                 +
 +       Register For ClueCon:                     +
 +       ----------------------------------        +
 +       https://www.cluecon.com                   +
 +                                                 +
 +-------------------------------------------------+
.=======================================================================================================.
|       _                            _    ____ _             ____                                       |
|      / \   _ __  _ __  _   _  __ _| |  / ___| |_   _  ___ / ___|___  _ __                             |
|     / _ \ | '_ \| '_ \| | | |/ _` | | | |   | | | | |/ _ \ |   / _ \| '_ \                            |
|    / ___ \| | | | | | | |_| | (_| | | | |___| | |_| |  __/ |__| (_) | | | |                           |
|   /_/   \_\_| |_|_| |_|\__,_|\__,_|_|  \____|_|\__,_|\___|\____\___/|_| |_|                           |
|                                                                                                       |
|    ____ _____ ____    ____             __                                                             |
|   |  _ \_   _/ ___|  / ___|___  _ __  / _| ___ _ __ ___ _ __   ___ ___                                |
|   | |_) || || |     | |   / _ \| '_ \| |_ / _ \ '__/ _ \ '_ \ / __/ _ \                               |
|   |  _ < | || |___  | |__| (_) | | | |  _|  __/ | |  __/ | | | (_|  __/                               |
|   |_| \_\|_| \____|  \____\___/|_| |_|_|  \___|_|  \___|_| |_|\___\___|                               |
|                                                                                                       |
|     ____ _             ____                                                                           |
|    / ___| |_   _  ___ / ___|___  _ __         ___ ___  _ __ ___                                       |
|   | |   | | | | |/ _ \ |   / _ \| '_ \       / __/ _ \| '_ ` _ \                                      |
|   | |___| | |_| |  __/ |__| (_) | | | |  _  | (_| (_) | | | | | |                                     |
|    \____|_|\__,_|\___|\____\___/|_| |_| (_)  \___\___/|_| |_| |_|                                     |
|                                                                                                       |
.=======================================================================================================.
Checking module integrity in target [/usr/local/freeswitch/mod]


make[2]: Leaving directory `/root/freeswitch/build'
Making install in tests/unit
make[2]: Entering directory `/root/freeswitch/tests/unit'
make[3]: Entering directory `/root/freeswitch/tests/unit'
make[3]: Nothing to be done for `install-data-am'.
 /usr/bin/mkdir -p '/usr/local/freeswitch/bin'
  /bin/sh /root/freeswitch/libtool   --mode=install /usr/bin/install -c switch_eavesdrop '/usr/local/freeswitch/bin'
libtool: install: /usr/bin/install -c .libs/switch_eavesdrop /usr/local/freeswitch/bin/switch_eavesdrop
make[3]: Leaving directory `/root/freeswitch/tests/unit'
make[2]: Leaving directory `/root/freeswitch/tests/unit'
make[1]: Leaving directory `/root/freeswitch'

    安装完毕后,添加如下软连接:

ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/
ln -sf /usr/local/freeswitch/bin/fs_cli     /usr/bin/

    相关声音文件,安装脚本如下:

cd ~/freeswitch/
make sounds-install
make moh-install 

    相关模块根据需要可以后续添加,参照如下命令执行:

make mod_xml_curl
make mod_xml_curl-install

    至此,freeswtich安装完毕。

8.freeswitch运维命令

    8.1 命令/usr/local/freeswitch/bin/freeswitch介绍

        执行命令freeswitch -help罗列freeswitch命令,如下:

[root@localhost ~]# freeswitch -help
Usage: freeswitch [OPTIONS]

These are the optional arguments you can pass to freeswitch:
	-nf                    -- no forking
	-reincarnate           -- restart the switch on an uncontrolled exit
	-reincarnate-reexec    -- run execv on a restart (helpful for upgrades)
	-u [user]              -- specify user to switch to
	-g [group]             -- specify group to switch to
	-core                  -- dump cores
	-help                  -- this message
	-version               -- print the version and exit
	-rp                    -- enable high(realtime) priority settings
	-lp                    -- enable low priority settings
	-np                    -- enable normal priority settings
	-vg                    -- run under valgrind
	-nosql                 -- disable internal sql scoreboard
	-heavy-timer           -- Heavy Timer, possibly more accurate but at a cost
	-nonat                 -- disable auto nat detection
	-nonatmap              -- disable auto nat port mapping
	-nocal                 -- disable clock calibration
	-nort                  -- disable clock clock_realtime
	-stop                  -- stop freeswitch
	-nc                    -- do not output to a console and background
	-ncwait                -- do not output to a console and background but wait until the system is ready before exiting (implies -nc)
	-c                     -- output to a console and stay in the foreground

	Options to control locations of files:
	-base [basedir]         -- alternate prefix directory
	-cfgname [filename]     -- alternate filename for FreeSWITCH main configuration file
	-conf [confdir]         -- alternate directory for FreeSWITCH configuration files
	-log [logdir]           -- alternate directory for logfiles
	-run [rundir]           -- alternate directory for runtime files
	-db [dbdir]             -- alternate directory for the internal database
	-mod [moddir]           -- alternate directory for modules
	-htdocs [htdocsdir]     -- alternate directory for htdocs
	-scripts [scriptsdir]   -- alternate directory for scripts
	-temp [directory]       -- alternate directory for temporary files
	-grammar [directory]    -- alternate directory for grammar files
	-certs [directory]      -- alternate directory for certificates
	-recordings [directory] -- alternate directory for recordings
	-storage [directory]    -- alternate directory for voicemail storage
	-cache [directory]      -- alternate directory for cache files
	-sounds [directory]     -- alternate directory for sound files

    freeswitch命令说明如下:

参数英文说明中文说明
-nfno forking不允许Fork新进程
-reincarnaterestart the switch on an uncontrolled exit
-reincarnate-reexecrun execv on a restart (helpful for upgrades)
-u [user]  specify user to switch to启动后以非root用户user身份运行
-g [group]specify group to switch to启动后以非root组group身份运行
-coredump cores启用核心转储(生成崩溃时的调试文件)。
-help    -help                  -- this message显示本帮助信息
-versionprint the version and exit
-rpenable high(realtime) priority settings开启高优先级(实时)设置
-lpenable low priority settings开启低优先级设置
-npenable normal priority settings普通优先级
-vgrun under valgrind在valgrind下运行,调试内存泄露时使用
-nosql disable internal sql scoreboard

禁用SQL模块(如SQLite、PostgreSQL等)的加载。

不使用SQL,show channels类的命令将不能显示结果

-heavy-timerHeavy Timer, possibly more accurate but at a cost更精确的时钟。可能会更精确,但对系统要求更高
-nonatdisable auto nat detection

禁用NAT(网络地址转换)自动检测功能。

如果路由器支持uPnP或NAT-PMP,则FreeSWITCH可以自动解决NAT穿越问题。如果路由器不支持,则该选项可以使启动更快

-nonatmapdisable auto nat port mapping禁用NAT映射模块的加载。
-nocal disable clock calibration

禁用日历模块(如mod_calendar)的加载。

关闭时钟核准。FreeSWITCH理想的运行环境是1000Hz的内核时钟。如果你的内核时钟小于1000Hz或在虚拟机上,可以尝试关闭该选项

-nortdisable clock clock_realtime关闭实时时钟
-stopstop freeswitch关闭 FreeSWITCH,它会在run目录中查找 PID文件
-ncdo not output to a console and background以“非控制台模式”(后台守护进程)运行FreeSWITCH。
-ncwaitdo not output to a console and background but wait until the system is ready before exiting (implies -nc)-ncwait --后台模式,等待系统完全初始化完毕之后再退出父进程,隐含“-nc”选项
-coutput to a console and stay in the foreground

    控制文件位置的选项命令参数如下:

命令参数英文说明中文说明
-base [basedir]alternate prefix directory指定其他的基准目录,在配置文件中使用$${base}
-cfgname [filename]alternate filename for FreeSWITCH main configuration file
-conf [confdir]alternate directory for FreeSWITCH configuration files指定自定义配置文件目录(默认是/usr/local/freeswitch/conf)。
-log [logdir]alternate directory for logfiles指定日志文件目录(默认是/usr/local/freeswitch/log)。
-run [rundir]alternate directory for runtime files指定运行时文件目录(如PID文件,默认是/usr/local/freeswitch/run)。
-db [dbdir] alternate directory for the internal database指定数据库文件目录(默认是/usr/local/freeswitch/db)。
-mod [moddir]alternate directory for modules指定模块加载目录(默认是/usr/local/freeswitch/mod)。
-htdocs [htdocsdir]alternate directory for htdocs指定其他 HTTP根目录
-scripts [scriptsdir]alternate directory for scripts指定脚本文件目录(如Lua脚本,默认是/usr/local/freeswitch/scripts)。
-temp [directory]alternate directory for temporary files指定其他临时文件目录
-grammar [directory]alternate directory for grammar files指定其他语法目录
-certs [directory]alternate directory for certificates指定其他SSL证书路径
-recordings [directory]alternate directory for recordings指定其他录音目录
-storage [directory]alternate directory for voicemail storage指定其他存储目录(语音信箱等)
-cache [directory]alternate directory for cache files
-sounds [directory]alternate directory for sound files

指定其他声音文件目录

常见用法示例:

    (1)常用启动命令

#1.连接到远程服务器
fs_cli -H 192.168.1.100 -P 8021 -p mypassword

#2.执行单条命令后退出
fs_cli -x "show channels"

#3.自动重连并记录日志
fs_cli -r -l -L /var/log/fs_cli.log

#4.禁用颜色输出并调试
fs_cli -n -d

#5.运行 Lua 脚本
fs_cli -s /scripts/monitor.lua

    (2)常用查询服务命令

#查看freeswitch安装路径
whereis freeswitch
查看进程号
ps -ef | grep freeswithch
查看freeswitch端口是否被监听
netstat -anp | grep 5060
#查看freeswitch的运行状态
status(控制台模式执行)
#查看freewitch内置用户是否注册
sofia status profile internal reg(控制台模式执行)

    (3)开启event_socket

#进入freeswitch配置文件路径	
cd /usr/local/freeswitch/conf/autoload_configs/
#修改配置
vim event_socket.conf.xml
#更改结果<param name="listen-ip" value="::"/>  改为 <param name="listen-ip" value="0.0.0.0"/>
#重启freeswitch
freeswitch -stop
freeswitch -nc -nonat
fs_cli

    8.2 命令/usr/local/freeswitch/bin/fs_cli 介绍

    fs_cli是一个类似Telnet的客户端(也类似于Asterisk中的“asterisk-r”命令),它使用FreeSWITCH的ESL(Event Socket Library)协议与FreeSWITCH通信。

    执行命令fs_cli -help罗列freeswitch命令,如下:

[root@localhost ~]# fs_cli -help
.=======================================================.
|            _____ ____     ____ _     ___              |
|           |  ___/ ___|   / ___| |   |_ _|             |
|           | |_  \___ \  | |   | |    | |              |
|           |  _|  ___) | | |___| |___ | |              |
|           |_|   |____/   \____|_____|___|             |
|                                                       |
.=======================================================.
| 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


[This app Best viewed at 160x60 or more..]
Usage: fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [-t <timeout_ms>] [profile]

  -?,-h --help                    Usage Information
  -H, --host=hostname             Host to connect
  -P, --port=port                 Port to connect (1 - 65535)
  -u, --user=user@domain          user@domain
  -p, --password=password         Password
  -i, --interrupt                 Allow Control-c to interrupt
  -x, --execute=command           Execute Command and Exit
  -l, --loglevel=command          Log Level
  -U, --log-uuid                  Include UUID in log output
  -S, --log-uuid-short            Include shortened UUID in log output
  -q, --quiet                     Disable logging
  -r, --retry                     Retry connection on failure
  -R, --reconnect                 Reconnect if disconnected
  -d, --debug=level               Debug Level (0 - 7)
  -b, --batchmode                 Batch mode
  -t, --timeout                   Timeout for API commands (in milliseconds)
  -T, --connect-timeout           Timeout for socket connection (in milliseconds)
  -n, --no-color                  Disable color
  -s, --set-log-uuid              Set UUID to filter log events

    fs_cli 命令的常用参数及其含义的表格:

参数含义
-h 或 --help显示帮助信息,列出所有支持的参数及其说明。
-H <host>指定连接的 FreeSWITCH 服务器地址(默认为 localhost)。
-P <port>指定连接的 FreeSWITCH ESL(Event Socket)端口(默认为 8021)。
-p <password>指定连接密码(默认为 ClueCon)。
-x <command>执行指定命令后立即退出(非交互模式)。
-r 或 --reconnect在连接断开时自动尝试重新连接。
-v 或 --verbose启用详细输出模式,显示更多连接和事件细节。
-q 或 --quiet静默模式,减少输出信息(仅显示关键内容)。
-d 或 --debug启用调试模式,输出详细的调试信息(如协议交互细节)。
-t <seconds>设置连接超时时间(单位:秒)。
-l 或 --log将输出日志保存到文件(默认不记录)。
-L <logfile>指定日志文件的路径(需配合 -l 使用)。
-n 或 --no-ansi禁用 ANSI 颜色输出(适用于无颜色支持的终端)。
-c <command>进入交互模式后执行指定命令(可多次使用)。
-i 或 --interactive强制进入交互模式(默认行为)。
-V 或 --version显示 fs_cli 的版本信息。
-s <script>执行指定的 Lua 脚本文件(需脚本支持 ESL 交互)。

常见用法示例:

#1.连接到远程服务器
fs_cli -H 192.168.1.100 -P 8021 -p mypassword

#2.执行单条命令后退出
fs_cli -x "show channels"

#3.自动重连并记录日志
fs_cli -r -l -L /var/log/fs_cli.log

#4.禁用颜色输出并调试
fs_cli -n -d

#5.运行 Lua 脚本
fs_cli -s /scripts/monitor.lua

9.相关错误处理

    9.1 404 Not found

服务ip地址不可用

原因:freeswtich没有启动或者端口被占用,总之Eyebeam不能到达指定domain

解决方法:
确保freeswitch已经启动并且5060端口没被占用
#netstat -napl|grep 5060

    9.2 403 forbidden

用户名密码错误

原因:freeswitch一开始安装好 默认会给你配置好20个account (1000-1019),密码统一是1234,这个可以在freeswitch/conf/vars.xml里面修改
解决方法:
检查用户名密码是否错误

    9.3 408 timeout

连接超时
原因:Eyebeam上配置的domain不正确, 或者网络有问题

解决方法:
a、确保所填的域名是正确的ip地址
b、确保已经关闭防火墙(centos下)
关闭防火墙:
systemctl stop firewalld.service
查看防火墙状态
firewall-cmd --state 
输出:not running  //说明防火墙已经关闭
c、查看iptables

10.开启防火墙,将freeswitch保护起来

    很多博客一上来就建议关闭机器的防火墙,这样方便客户端连接到freeswitch,个人不建议,这里我们实践如何将freeswitch通过防火墙firewald保护起来,首先编写一个名字为firewald.sh的shell脚本,里面集成防火墙的安装、放开SSH端口22和放开指定IP和网段的IP,最后启动防火墙,脚本内容如下:

#!/bin/bash

#install firewalld
yum -y install firewalld

#start firewalld
systemctl start firewalld

#set default zone
firewall-cmd --set-default-zone=public

#open SSH port
firewall-cmd --permanent --zone=public --add-port=22/tcp

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.30.0.162" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="172.30.0.0/24" accept"

echo "#firewall-cmd --reload"
firewall-cmd --reload

echo "#firewall-cmd --state"
firewall-cmd --state

echo "#firewall-cmd --list-all"
firewall-cmd --list-all

    注意:

  • 如果要放开指定IP,请参照"172.30.0.162";
  • 如果要放开一个网段,请参照"172.30.0.0/24"。

    给上述脚本添加执行权限,并执行脚本:

chmod +x firewald.sh
./firewald.sh

    执行后结果如下:

[root@localhost ~]# chmod +x firewald.sh 
[root@localhost ~]# ./firewald.sh 
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository custom is listed more than once in the configuration
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
base                                                                                                                  | 3.6 kB  00:00:00     
centosplus                                                                                                            | 2.9 kB  00:00:00     
custom                                                                                                                | 2.9 kB  00:00:00     
http://192.168.19.41:58004/epel/7/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article 

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

extras                                                                                                                | 2.9 kB  00:00:00     
updates                                                                                                               | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package firewalld.noarch 0:0.6.3-11.el7 will be updated
--> Processing Dependency: firewalld = 0.6.3-11.el7 for package: firewall-config-0.6.3-11.el7.noarch
---> Package firewalld.noarch 0:0.6.3-13.el7_9 will be an update
--> Processing Dependency: python-firewall = 0.6.3-13.el7_9 for package: firewalld-0.6.3-13.el7_9.noarch
--> Processing Dependency: firewalld-filesystem = 0.6.3-13.el7_9 for package: firewalld-0.6.3-13.el7_9.noarch
--> Running transaction check
---> Package firewall-config.noarch 0:0.6.3-11.el7 will be updated
---> Package firewall-config.noarch 0:0.6.3-13.el7_9 will be an update
---> Package firewalld-filesystem.noarch 0:0.6.3-11.el7 will be updated
---> Package firewalld-filesystem.noarch 0:0.6.3-13.el7_9 will be an update
---> Package python-firewall.noarch 0:0.6.3-11.el7 will be updated
---> Package python-firewall.noarch 0:0.6.3-13.el7_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                                  Arch                       Version                               Repository                   Size
=============================================================================================================================================
Updating:
 firewalld                                noarch                     0.6.3-13.el7_9                        updates                     449 k
Updating for dependencies:
 firewall-config                          noarch                     0.6.3-13.el7_9                        updates                     137 k
 firewalld-filesystem                     noarch                     0.6.3-13.el7_9                        updates                      51 k
 python-firewall                          noarch                     0.6.3-13.el7_9                        updates                     355 k

Transaction Summary
=============================================================================================================================================
Upgrade  1 Package (+3 Dependent packages)

Total download size: 993 k
Downloading packages:
No Presto metadata available for updates
(1/4): firewall-config-0.6.3-13.el7_9.noarch.rpm                                                                      | 137 kB  00:00:00     
(2/4): firewalld-0.6.3-13.el7_9.noarch.rpm                                                                            | 449 kB  00:00:00     
(3/4): firewalld-filesystem-0.6.3-13.el7_9.noarch.rpm                                                                 |  51 kB  00:00:00     
(4/4): python-firewall-0.6.3-13.el7_9.noarch.rpm                                                                      | 355 kB  00:00:00     
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        1.0 MB/s | 993 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : python-firewall-0.6.3-13.el7_9.noarch                                                                                     1/8 
  Updating   : firewalld-filesystem-0.6.3-13.el7_9.noarch                                                                                2/8 
  Updating   : firewalld-0.6.3-13.el7_9.noarch                                                                                           3/8 
  Updating   : firewall-config-0.6.3-13.el7_9.noarch                                                                                     4/8 
  Cleanup    : firewall-config-0.6.3-11.el7.noarch                                                                                       5/8 
  Cleanup    : firewalld-0.6.3-11.el7.noarch                                                                                             6/8 
  Cleanup    : firewalld-filesystem-0.6.3-11.el7.noarch                                                                                  7/8 
  Cleanup    : python-firewall-0.6.3-11.el7.noarch                                                                                       8/8 
  Verifying  : firewalld-filesystem-0.6.3-13.el7_9.noarch                                                                                1/8 
  Verifying  : firewalld-0.6.3-13.el7_9.noarch                                                                                           2/8 
  Verifying  : python-firewall-0.6.3-13.el7_9.noarch                                                                                     3/8 
  Verifying  : firewall-config-0.6.3-13.el7_9.noarch                                                                                     4/8 
  Verifying  : python-firewall-0.6.3-11.el7.noarch                                                                                       5/8 
  Verifying  : firewalld-filesystem-0.6.3-11.el7.noarch                                                                                  6/8 
  Verifying  : firewalld-0.6.3-11.el7.noarch                                                                                             7/8 
  Verifying  : firewall-config-0.6.3-11.el7.noarch                                                                                       8/8 

Updated:
  firewalld.noarch 0:0.6.3-13.el7_9                                                                                                          

Dependency Updated:
  firewall-config.noarch 0:0.6.3-13.el7_9      firewalld-filesystem.noarch 0:0.6.3-13.el7_9      python-firewall.noarch 0:0.6.3-13.el7_9     

Complete!
Warning: ZONE_ALREADY_SET: public
success
success
success
success
#firewall-cmd --reload
success
#firewall-cmd --state
running
#firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: dhcpv6-client ssh
  ports: 22/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
	rule family="ipv4" source address="172.30.0.162" accept
	rule family="ipv4" source address="172.30.0.0/24" accept
[root@localhost ~]# 

11.通过软电话Linphone连接freeswitch,并拨打内置的号码

    11.1 自行安装软电话Linephone

    11.2 在软电话Linephone中添加注册的SIP账户

    FreeSWITCH默认配置了1000~1019共20个用户,你可以随便选择一个用户进行配置,配置过程如下:

    点击“偏好设置”--“SIP账户”--“添加账户”,截图说明如下:

    添加SIP地址、SIP服务器地址、登记期限和协议UDP,截图说明如下:

    点击左上角的默认用户,选择刚新增的SIP账户,Linephone会自动尝试去连接我们搭建的freeswitch服务端,连接成功后以绿色对勾展示,截图说明如下:

    11.3 使用软电话Linephone拨打内置号码9664

    freeswitch自带拨号如下:

    这里我们拨打9664保持音乐,效果截图如下:

### 安装 FreeSWITCH 1.10.12 #### 下载源码 为了安装特定版本FreeSWITCH,首先需要获取该版本的源代码。可以使用 `wget` 或者其他工具来下载指定版本的压缩包。 ```bash cd /usr/local/src/ wget http://files.freeswitch.org/freeswitch-releases/freeswitch-1.10.12-release.tar.gz tar -xvf freeswitch-1.10.12-release.tar.gz ``` #### 编译前准备 确保系统已经安装编译所需的各种依赖项,这通常包括开发工具链以及一些额外的支持库。对于 CentOS 来说,可以通过 yum 组装这些组件: ```bash yum groupinstall "Development Tools" yum install autoconf automake libtool pkgconfig openssl-devel curl-devel zlib-devel pcre-devel speexdsp-devel opus-devel sox-devel sqlite-devel json-c-devel lua-devel python-devel perl-devel tcl-devel gsm-devel spandsp-devel srtp-devel resample-devel bzip2-devel ncurses-devel newt-devel gtk2-devel wxGTK-devel qt-devel jack-audio-connection-kit-devel alsa-lib-devel pulseaudio-libs-devel portaudio-devel ffmpeg-devel openal-soft-devel ladspa-sdk-devel faad2-devel faac-devel lame-devel twolame-devel vorbis-tools flite-devel festival-devel espeak-devel pocketsphinx-devel sphinxbase-devel ``` #### 配置与编译 解压后的目录中执行配置脚本并开始编译过程。 ```bash cd freeswitch-1.10.12-release ./configure make ``` #### 安装软件 完成编译之后就可以正式安装 FreeSWITCH 到系统当中去了。 ```bash make install ``` 此时,默认情况下 FreeSWITCH 将会被部署至 `/usr/local/freeswitch/` 文件夹内[^2]。 #### 启动服务 最后一步就是启动刚刚安装的服务实例,并验证是否能够正常工作。 ```bash cd /usr/local/freeswitch/bin ./freeswitch ``` 如果一切顺利的话,在终端窗口里应该能看到 FreeSWITCH 成功启动的日志信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值