VoIP系统大盘点

2023-05-24,,

一、VoIP拓扑

PBX是程控交换机,程控交换机有实体交换机和软件模拟的交换机。

软件模拟的交换机,即交换机服务器,常用开源的sip服务器有asterisk,freepbx, opensip, freeswitch等,商用的minisipserver也不错,也不贵。

PSTN网关是接入电信运营商网络需要的,暂时不需要。

测试的SIP客户端工具比较多zoiper, microSIP, X-lite, Yate, eyeBeam, Linphone等。

可以推荐一些基于Sip协议的开源IP电话客户端吗?

https://www.zhihu.com/question/20093472?sort=created

二、VoIP服务器部署

为了避开网络穿透的问题,我将SIP服务器装在了阿里云(百度云 / vultr的vps也都行)主机上,也就是NAT之后,如果装在本地(NAT之前),就需要stun/tun服务器来协助穿透。

1、minisipserver装在阿里云ECS的windows 2012 r2服务器主机上

注意

*关闭windows 2012 r2防火墙,先保持网络通畅,调完了在配置防火墙端口。

*不需要配置nat,只需要把NAT内网映射到外网,因为阿里云服务器主机分配了公网,并且在nat之后,minisipserver默认配置就行。

*端口必须映射,在网络和安全组里设置,常用的ssh是22号端口,sip默认的语音数据端口是5060,我为了调试方便开通了所有端口。

2、 minisipserver装在vultr vps的windows 2012 r2服务器上

同样需要注意

*关闭windows 2012 r2防火墙,先保持网络通畅,调完了在配置防火墙端口。

*不需要配置nat,只需要把NAT内网映射到外网,因为vps是公网,并且在nat之后,minisipserver默认配置就行。

*端口必须映射,在网络和安全组里设置,常用的ssh是22号端口,sip默认的语音数据端口是5060,我为了调试方便开通了所有端口。

3、FreePBX安装在阿里云ECS的centos 7.2主机上

minisipserver虽然简单,但功能单一,不支持创建电话会议,所以这里将VoIP服务器换成开源的freepbx。

freepbx安装手册

https://wiki.freepbx.org/display/FOP/Installing+FreePBX+14+on+CentOS+7

https://wiki.freepbx.org/display/FOP/Installing+FreePBX+14+on+Ubuntu+18.04

1) 一键安装freepbx的脚本很方便

http://www.freepbx.cn/

http://freepbx.org.cn/wiki/index.php?title=FreePBX

脚本的有些软件包失效了,比如asterisk-14-current.tar.gz,没有current版本,在脚本文件提供的网站里找到有效的版本,安装没报错就正常了。

2) 同样特别注意

*关闭centos 7.2防火墙,先保持网络通畅,调完了在配置防火墙端口。

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

*端口必须映射,在网络和安全组里设置,常用的ssh是22号端口,sip默认的语音数据端口是5060,我为了调试方便开通了所有端口。

*不需要配置nat,只需要把NAT内网映射到外网,因为阿里云服务器主机分配了公网,并且在nat之后

设置--->高级设置--->sip nat 配置成never或者no

 

*NAT本地IP到公网IP映射

设置--->Asterisk SIP设置--->NAT设置

扫描一下Detect Network Settings就行,我习惯性的把服务器本地IP也添上

配置好,添加分机,就可以用客户端工具连接了

新安装的freepbx可能模块加载不完全,最好重启一下freepbx

fwconsole start/restart

3) freepbx/asterisk( freepbx是带web ui的asterisk )常用指令

https://www.cnblogs.com/operationhome/p/9149171.html

4、freepbx安装到vultr的VPS上

装的FreePBX 14.0.5.2

https://www.freepbx.org/downloads/

1) vps安装freepbx

http://www.izcv.com/1310.html

http://www.izcv.com/1363.html

2) 同样的配置

设置--->高级设置--->sip nat 配置成never或者no

设置--->Asterisk SIP设置--->NAT设置

扫描一下Detect Network Settings就行,我习惯性的把服务器本地IP也添上

同样 新安装的freepbx可能模块加载不完全,最好重启一下freepbx

fwconsole start/restart

5、freeswitch

5.1、freeswitch安装

1) freeswitch一键安装脚本

https://blog.csdn.net/gredn/article/details/75393207

默认的配置注册不上,报403 Forbidden(Invalid domain in From: header)

2018-12-31
22:19:12.061220 [WARNING] sofia_reg.c:1792 SIP auth challenge
(REGISTER) on sofia profile 'internal' for [1001@182.61.56.247] from ip
119.131.168.166
2018-12-31 22:19:12.121205 [WARNING] sofia_reg.c:1737
SIP auth failure (REGISTER) on sofia profile 'internal' for
[1001@182.61.56.247] from ip 119.131.168.166

https://www.cnblogs.com/yoyotl/p/6552891.html

2) 快速安装

wget https://www.freeswitch.org.cn/Makefile && make install

找不到Makefile,地址已经失效了

3) 官网的安装手册也不一定靠谱,系统版本,各种依赖库一堆问题,下面是验证的可行的。

yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release
yum install -y freeswitch-config-vanilla freeswitch-lang-* freeswitch-sounds-*
systemctl enable freeswitch
freeswitch

4) freeswitch v1.0在阿里云centos 7.03上的安装

https://blog.csdn.net/MoSee/article/details/77945546

5.2、freeswitch配置

以上默认能拨通,但是没声音,30秒左右就自动断线了,明显跟freepbx一样是NAT的故障

我偷懒用yun install安装的freeswitch,配置文件在/etc/freeswitch目录,安装文件比较分散

/var/lib/yum/repos/x86_64/7/freeswitch
/var/lib/freeswitch
/var/cache/yum/x86_64/7/freeswitch
/var/log/freeswitch
/usr/lib64/freeswitch
/usr/share/freeswitch
/usr/bin/freeswitch
/run/freeswitch
/etc/sysconfig/freeswitch
/etc/freeswitch

1) 修改internal.xml

cd /etc/freeswitch/sip_profiles

vi internal.xml

<param name="ext-rtp-ip" value="auto-nat"/>
<param name="ext-sip-ip" value="auto-nat"/>

将atto-nat改成云服务器公网IP

2) 关闭centos 7.2防火墙,先保持网络通畅,调完了在配置防火墙端口。

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

重启freeswitch

freeswitch -stop

freeswitch

测试rtp已经通了

5.3、freeswitch测试

sample sipp scenarios for testing freeswitch

https://github.com/os11k/sipp2freeswitch

5.4、FreeSwitch默认只支持音频,为支持视频,修改vars.xml如下:

<X-PRE-PROCESS cmd="set" data="global_codec_prefs=PCMU,PCMA,GSM,H264,H263-1998,H263"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=PCMU,PCMA,GSM,H264,H263-1998,H263"/>

5.5、杜金房的个人网站

http://www.dujinfang.com/

6、VoIP客户端工具配置

1)android客户端连接,用zoiper注册,填如下几项就可以了

2) x-lite

3) tSIP与tSIP之间拨号

4) tSIP与eyebeam拨号

5) microsip与eyebeam拨号

三、网络穿透

虽然将服务器安装到公网主机上避免了网络穿透,但是网络问题是不得不面对的。因为国情,导致翻墙,打洞也成为了一门科学。

1、FireWall和NAT(防火墙和网络地址与端口转换)

具体细节参考Cisco VoIP

https://www.cisco.com/c/zh_cn/support/docs/ip/network-address-translation-nat/211269-NAT-in-VoIP.html

2、SIP穿越 NAT

1) NAT经常使用的分类例如以下:
Full Cone NAT(全然圆锥型)
Address Restricted Cone NAT(地址限制圆锥型 )
Port Restricted Cone NAT(port限制圆锥型)
Symmetric NAT(对称型)

https://www.cnblogs.com/jhcelue/p/7258803.html

2) NAT拓扑检测

A Python STUN client for getting NAT type and external IP (RFC 3489)

https://pypi.org/project/pystun/

办公司网路NAT类型是Address Restricted Cone NAT

3) stun/turn server穿越NAT

stun官网http://www.stunprotocol.org/

stun详解以及部分公用stun服务器  https://www.voip-info.org/stun

turn server安装 http://turnserver.open-sys.org/downloads/v3.2.4.4/INSTALL

3、网络跨域实战

stun server搭建与测试

https://blog.csdn.net/zhenzhen2014/article/details/45871397

http://nil.uniza.sk/sip/installing-and-configuring-restund-stunturn-server

https://www.cnblogs.com/jhcelue/p/7258803.html

免费的stun服务器

http://wiki.tomocha.net/SIP_STUNserver.html

基于pjsip实现p2p语音对讲

https://blog.csdn.net/voidreturn/article/details/65634390?locationNum=1&fps=1

四、其他开源VoIP服务器方案调研

1、Asterisk

Asterisk安装

https://blog.csdn.net/yuesichiu/article/details/41693577

Asterisk : Hello world 打通第一个电话
http://www.hiastar.com/doc/asterisk_cn/6914124.html

自己动手搭建免费VoIP服务器

https://blog.csdn.net/yuesichiu/article/details/41693577

在VPS上建asterisk server

https://www.v2ex.com/t/72698

其他补充

service httpd restart

service asterisk restart
service network restart
amportal restart
https://blog.csdn.net/liuxiao723846/article/details/79585897
https://blog.csdn.net/brandon2015/article/details/51811914

2、opensip安装

sudo apt-get update
sudo
apt-get install build-essential bison flex libncurses5 libncurses5-dev
perl libdbi-perl libdbd-mysql-perl libdbd-pg-perl libfrontier-rpc-perl
libterm-readline-gnu-perl libberkeleydb-perl
sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysqlclient-dev
make menuconfig

参考https://blog.csdn.net/croop520/article/details/79096516

1)编译
默认目录机构如下:
配置文件位置:/usr/local/etc/opensips/
mysql 数据库表创建sql语句:/usr/local/share/opensips/mysql/
安装模块目录:/usr/local/lib/opensips/modules/
opensips 控制台模板:/usr/local/lib/opensips/opensipsctl/
程序运行路径:/usr/local/sbin/

2)测试
#/usr/local/sbin/opensipsctl start
#/usr/local/sbin/opensipsctl stop
#/usr/local/sbin/opensipsctl restart
#/usr/local/sbin/opensipsdbctl create
#/usr/local/sbin/opensipsctl add <username>@opensips_address <password>
#/usr/local/sbin/opensipsctl add 100@172.18.97.146 100
#/usr/local/sbin/opensipsctl add 101@172.18.97.146 101
#/usr/local/sbin/opensipsctl ul show

root@iZwz9ic9ggky8kwzyfkfayZ:/usr/local/sbin# sudo opensipsctl add 100 100
sudo: unable to resolve host iZwz9ic9ggky8kwzyfkfayZ
new user '100' added
root@iZwz9ic9ggky8kwzyfkfayZ:/usr/local/sbin# sudo opensipsctl add 101 101
sudo: unable to resolve host iZwz9ic9ggky8kwzyfkfayZ
new user '101' added
root@iZwz9ic9ggky8kwzyfkfayZ:/usr/local/sbin# sudo opensipsctl add 102 102
sudo: unable to resolve host iZwz9ic9ggky8kwzyfkfayZ
new user '102' added
root@iZwz9ic9ggky8kwzyfkfayZ:/usr/local/sbin# sudo opensipsctl add 103 103
sudo: unable to resolve host iZwz9ic9ggky8kwzyfkfayZ
new user '103' added

3)配置
/usr/local/etc/opensips/

3、阿里云部署freeswitch

https://blog.csdn.net/MoSee/article/details/77945546?locationNum=4&fps=1

http://bbs.freeswitch.org.cn/t/freeswitch/2093

vultr端口检测
https://www.vultrcn.com/11.html

在VPS上建asterisk server

https://www.v2ex.com/t/72698

vps,EC2比较

http://www.laozuo.org/myvps

4、其他

SipDroid +miniSIPServer搭建SIP局域网语音通话

http://www.cnblogs.com/poe-blog/p/3553888.html

openmeetings

http://blog.51cto.com/jiangzhi2013/1218491

https://github.com/sippy

https://blog.csdn.net/ying357/article/details/10076967

https://blog.csdn.net/ying357/article/category/1342860

其他方案收集

1、resiprocate使用入门:内网搭建基于repro的sipproxy测试环境

https://blog.csdn.net/c359719435/article/details/54619139

Open Source VOIP applications, both clients and servers.

https://www.voip-info.org/open-source-voip-software

VoIP系统大盘点的相关教程结束。

《VoIP系统大盘点.doc》

下载本文的Word格式文档,以方便收藏与打印。