SIP - FreeSwitch 安装 & 编译

本文详细介绍了如何在Windows和CentOS系统上安装FreeSWITCH,包括MSI和RPM方式,并指导了源代码编译过程,涉及库的构建和FreeSWITCH配置实例,适合开发者进行电话软交换平台搭建与调试。

SIP - FreeSwitch 安装 & 编译

FreeSWITCH是一个开源的电话软交换平台, 这里不做详细介绍, 只用于编译&安装测试 SIP 协议.
FreeSWITCH Installation

Windows MSI 安装

https://files.freeswitch.org/windows/installer/x64/
https://files.freeswitch.org/windows/installer/x64/sounds/

CentOS 7 RPM 安装

$ yum install -y https://files.freeswitch.org/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release
$ yum install -y freeswitch-config-vanilla freeswitch-lang-* freeswitch-sounds-*
$ systemctl enable freeswitch
$ systemctl start freeswitch

CentOS 8 RPM 安装

需使用第三方 okay repo:

$ rpm -ivh http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-5.el8.noarch.rpm

or 手动添加repo

[okay]
name=Extra OKay Packages for Enterprise Linux - $basearch
baseurl=http://repo.okay.com.mx/centos/$releasever/$basearch/release
failovermethod=priority
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-OKAY

[okay-debuginfo]
name=Extra OKay Packages for Enterprise Linux - $basearch - Debug
baseurl=http://repo.okay.com.mx/centos/$releasever/$basearch/debug
failovermethod=priority
enabled=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-OKAY
gpgcheck=0

安装:

$ yum install fusionpbx-all
$ freeswitch -version
FreeSWITCH version: 1.10.3-release~64bit (-release 64bit)

FreeSwitch源代码编译安装

注:
建议使用 fedora, CentOS 8 很多的依赖库需要自行编译;

先安装 libks & signalwire

build libks

$ git clone https://github.com/signalwire/libks 
$ cd libks && cmake . && make -j install

build signalwire

$git clone https://github.com/signalwire/signalwire-c
$ cd signalwire-c && cmake . && make -j install

build FreeSwitch

$ dnf install -y git alsa-lib-devel autoconf automake bison bzip2 curl-devel e2fsprogs-devel flite-devel \
gcc-c++ gdbm-devel gnutls-devel ldns-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel \
libogg-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 nspr-devel openssl-devel opus-devel pcre-devel perl \
perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python2-devel python-devel soundtouch-devel \
speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel speexdsp-devel speex-devel erlang libvpx-devel
 
$ git clone -b v1.8 https://github.com/signalwire/freeswitch.git freeswitch
$ cd freeswitch
$ export CFLAGS="-Wno-error=format-truncation -Wno-error=stringop-truncation"
$ ./bootstrap.sh -j

$ PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig \
./configure -C --enable-portable-binary \
            --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
            --with-gnu-ld --with-python --with-erlang --with-openssl \
            --enable-core-odbc-support --enable-zrtp \
            --enable-core-pgsql-support \
            --enable-static-v8 --disable-parallel-build-v8
$ find . -name Makefile -exec sed -i "s/-Werror //g" {} ';'
$ make
$ make -j install
$ make -j cd-sounds-install
$ make -j cd-moh-install

启动:

$ /usr/bin/freeswitch -nc 

停止:

$ /usr/bin/freeswitch -stop

日志

tail -f /var/log/freeswitch/freeswitch.log

FreeSWITCH 配置

创建用户

cd /etc/freeswitch/directory/default
cp 1000.xml 9999.xml
sed -i "s/1000/9999/" 9999.xml
vi /etc/freeswitch/dialplan/default.xml 
修改
expression="^(10[012][0-9]|9999)$"

批量添加用户

cd /etc/freeswitch/directory/default
for i in `seq 1020 1039`; do sed -e "s/1000/$i/" 1000.xml > $i.xml ; done

注: FreeSwitch 账户默认密码为 '1234’

默认拨号

numberExplanation
9664Keep music
9191Sign up for ClueCon
9195echo, echo test, delay 5 seconds
9196echo, echo test, no delay
9197milliwatte extension, ringtone generation
9198TGML ringtone generation example
9180Ring tone test, using the ring back tone generated by the far end
9181Ring tone test, produce British ring tone
9182Ring tone test, use music as ring tone, ring back tone
9183Answer first, then send an English ring tone
9184Answer first, then send music ringtone
9178Receive fax
9179send a fax
5000IVR demo
4000Voicemail de2021/8/4mo
33xxConference call, 48kHz
32xxConference call, 32kHz
31xxConference call, 16kHz
30xxConference call, 8kHz
2000~2002Call group
1000~1019Default extension

fs_cli

reloadxml 重新加载XML配置

fs_cli -x reloadxml

获取 profile 状态

freeswitch@centos7-170> sofia status profile external 
=================================================================================================
Name             	external
Domain Name      	N/A
Auto-NAT         	false
DBName           	sofia_reg_external
Pres Hosts       	
Dialplan         	XML
Context          	public
Challenge Realm  	auto_to
RTP-IP           	192.168.22.170
Ext-RTP-IP       	118.249.190.28
SIP-IP           	192.168.22.170
Ext-SIP-IP       	118.249.190.28
URL              	sip:mod_sofia@118.249.190.28:5080
BIND-URL         	sip:mod_sofia@118.249.190.28:5080;maddr=192.168.22.170;transport=udp,tcp
HOLD-MUSIC       	local_stream://moh
OUTBOUND-PROXY   	N/A
CODECS IN        	OPUS,G722,PCMU,PCMA,H264,VP8
CODECS OUT       	OPUS,G722,PCMU,PCMA,H264,VP8
TEL-EVENT        	101
DTMF-MODE        	rfc2833
CNG              	13
SESSION-TO       	0
MAX-DIALOG       	0
NOMEDIA          	false
LATE-NEG         	true
PROXY-MEDIA      	false
ZRTP-PASSTHRU    	true
AGGRESSIVENAT    	false
CALLS-IN         	0
FAILED-CALLS-IN  	0
CALLS-OUT        	0
FAILED-CALLS-OUT 	0
REGISTRATIONS    	0

softphone 客户端

  • freeswitch 注册 5060 端口需使用密码验证注册;
  • freeswitch 注册 5080 端口无需验证注册;
  • softphone 注册成功后拨打 9664 响应音乐即验证INVITE成功;

JitSiDesktop

https://jitsi.org/projects/
在这里插入图片描述
在这里插入图片描述

microsip

https://www.microsip.org/
在这里插入图片描述
在这里插入图片描述

<think>嗯,用户这次提出的需求相当具体,是关于在CentOS7上编译安装Freeswitch及相关组件的完整流程,还特别强调要包含安全配置和Linephone互联。看来用户正在搭建一个专业的VoIP服务器环境,可能是用于企业通信系统或者呼叫中心解决方案。用户引用了站内一篇关于Freeswitch安装的文档,但明确表示这些资料仅供参考。注意到用户特别强调“不是真正的需求”,说明用户需要的是完整、可靠的操作指南,而不是零散的代码片段。从技术细节要求来看,用户应该是有一定Linux基础的运维人员或通信工程师,对安全防护和系统互联这种生产环境需求很重视。考虑到编译安装Freeswitch的复杂性,准备把指南分为六个逻辑阶段:从准备依赖包开始,到最后的互联测试结束。每个阶段都需要考虑可能的坑点,比如Spandsp编译需要libtiff-devel这种容易遗漏的依赖。安全配置部分特别要强调,因为用户提到了ACL和防火墙双重防护,这通常是金融类企业才会要求的高安全标准。在Sofia-sip安装部分需要注意,用户提供的示例脚本存在操作风险(未使用sudo执行makeinstall),准备在正式步骤中修正为安全提权方式。对于核心的sip_profiles配置,准备详细说明ACL规则优先级,因为这是很多管理员容易出错的地方。最后Linephone互联测试会包含诊断建议,毕竟SIP协议协商失败在实际部署中很常见。虽然用户当前没提,但准备补充TLS配置的提示,因为现在VoIP安全越来越重要。</think> 以下是CentOS 7系统上编译安装FreeSWITCH 1.10.12 + Spandsp + Sofia-sip的完整指南,包含ACL防护、防火墙设置及Linphone互联配置: ### 一、环境准备 ```bash sudo yum -y update sudo yum -y groupinstall "Development Tools" sudo yum -y install epel-release sudo yum -y install git wget libtiff-devel libjpeg-devel \ libuuid-devel libcurl-devel sqlite-devel opus-devel \ speex-devel lua-devel openssl-devel libsndfile-devel \ yasm-devel ldns-devel autoconf automake ``` ### 二、编译安装依赖库 #### 1. Sofia-sip (1.12.11+) ```bash cd /usr/src git clone https://github.com/freeswitch/sofia-sip.git cd sofia-sip ./bootstrap.sh && ./configure --with-openssl && make sudo make install ``` #### 2. Spandsp (最新版) ```bash cd /usr/src wget https://www.soft-switch.org/download/spandsp/spandsp-0.0.6.tar.gz tar xvf spandsp-0.0.6.tar.gz cd spandsp-0.0.6 ./configure && make sudo make install echo /usr/local/lib > /etc/ld.so.conf.d/local.conf sudo ldconfig ``` ### 三、编译安装FreeSWITCH 1.10.12 ```bash cd /usr/src git clone -b v1.10.12 https://github.com/signalwire/freeswitch.git cd freeswitch ./bootstrap.sh -j ./configure --enable-core-odbc-support \ --enable-portable-binary \ --prefix=/usr/local/freeswitch \ --with-sofia-sip=/usr/local \ --with-spandsp=/usr/local make -j$(nproc) sudo make install ``` ### 四、ACL防护配置 编辑配置文件: ```bash sudo vi /usr/local/freeswitch/conf/autoload_configs/acl.conf.xml ``` ```xml <list name="allow-all" default="deny"> <node type="allow" cidr="192.168.1.0/24"/> <!-- 允许内网 --> <node type="allow" cidr="公网IP/32"/> <!-- 允许本机公网 --> </list> ``` ### 五、防火墙设置 1. 放行必要端口: ```bash sudo firewall-cmd --permanent --add-service={sip,sips,rtp} sudo firewall-cmd --permanent --add-port=5060/tcp --add-port=5060/udp sudo firewall-cmd --permanent --add-port=7443/tcp sudo firewall-cmd --permanent --add-port=16384-32768/udp sudo firewall-cmd --reload ``` 2. 应急防护规则 (防扫描): ```bash sudo firewall-cmd --direct --add-rule ipv4 filter INPUT 1 -p udp --dport 5060 -m string --hex-string "|53656e643041757468|" --algo bm -j DROP ``` ### 六、Linphone互联配置 1. **FreeSWITCH端**: ```xml <!-- conf/dialplan/public.xml --> <extension name="Linphone_to_Extension"> <condition field="destination_number" expression="^10(10|20)$"> <action application="bridge" data="user/${destination_number}@${domain}"/> </condition> </extension> ``` 2. **Linphone客户端设置**: - 服务器地址: `sip:公网IP或域名` - 用户名: 分机号 (如1010) - 密码: 在`conf/directory/default.xml`中配置的密码 - 传输协议: UDP/TCP ### 七、服务管理 ```bash # 启动服务 sudo /usr/local/freeswitch/bin/freeswitch -nc -nonat # 加入系统服务 (创建systemd服务文件) sudo vi /etc/systemd/system/freeswitch.service ``` 服务文件内容: ```ini [Unit] Description=FreeSWITCH VoIP PBX After=network.target [Service] User=freeswitch Group=freeswitch Type=forking ExecStart=/usr/local/freeswitch/bin/freeswitch -nc -nonat ExecStop=/usr/local/freeswitch/bin/freeswitch -stop TimeoutSec=2min [Install] WantedBy=multi-user.target ``` **安装验证**: ```bash fs_cli -x "version" # 应显示:1.10.12~release... netstat -anp | grep 5060 # 应显示LISTEN状态 ``` > **关键安全建议**: > 1. 定期更新补丁:`git pull && git checkout v1.10.x && make current` > 2. 启用TLS加密:修改`conf/sip_profiles/internal.xml`启用`tls`端口和证书 > 3. 禁用危险模块:`unimrcp`、`mod_skinny`等非常用模块[^1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值