WebRTC NAT穿透服务器 coturn服务搭建
文章目录
- 安装需要的环境
- 联网安装
- 安装gcc
- 安装make
- 安装openssl
- 安装wget
- 编译安装libevent(手动安装)
- 安装sqlite或mysql
- Centos7安装最新的sqlite3
- 下载coturn源码并编译
- 使用openssl创建密钥文件
- 设置用户名和密码
- 修改turnserver.conf配置文件
- 启用coturn并验证
- 离线安装
- 安装gcc
- 安装openssl
- 编译安装libevent(手动安装)
- 安装sqlite或mysql
- 下载coturn源码并编译
- 使用openssl创建密钥文件
- 设置用户名和密码
- 修改turnserver.conf配置文件
- 启用coturn并验证
- 验证coturn服务
参考:
做WebRTC,千万别把媒体和信令混在一起
WebRTC:stun/turn服务器搭建
webRTC(九):STUN_TURN服务器搭建
自己动手搭建 WebRTC TURN&STUN 服务器
5分钟快速打造WebRTC视频聊天
WebRTC协议学习之一(WebRTC简介)
webrtc笔记(1): 基于coturn项目的stun/turn服务器搭建
coturn穿透服务器搭建
安装需要的环境
联网安装
安装gcc
[root@2227b264a137 run_env]# yum -y install gcc gcc-c++ zlib-devel
安装make
[root@2227b264a137 run_env]# yum -y install automake autoconf libtool make
安装openssl
[root@2227b264a137 opt]# yum -y install openssl-devel
安装wget
[root@2227b264a137 opt]# yum -y install wget
编译安装libevent(手动安装)
[root@2227b264a137 run_env]# wget https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz
[root@2227b264a137 run_env]# tar -zxvf libevent-2.1.10-stable.tar.gz
[root@2227b264a137 run_env]# cd libevent-2.1.10-stable
[root@2227b264a137 libevent-2.1.10-stable]# ./configure
[root@2227b264a137 libevent-2.1.10-stable]# make & make install
linux无法编译libevent,一直报错,但是我有装openssl
当指定openssl安装目录,而不是默认安装路径时,需要指定以下指令:
在
/etc/profile
文件添加export PKG_CONFIG_PATH=/usr/local/openssl/lib/pkgconfig
在安装目录下执行
./configure CFLAGS="$(pkg-config --cflags openssl)" LDFLAGS="$(pkg-config --libs openssl)"
安装sqlite或mysql
参考: CentOS 安装Sqlite3 SQLite 简介 更新CentOS的SQLite版本
[root@2227b264a137 run_env]# yum -y install sqlite sqlite-devel
Centos7安装最新的sqlite3
#更新SQLite 3
#获取源代码(在主目录中运行)
[root@djangoServer ~]# cd ~
[root@djangoServer ~]# wget https://www.sqlite.org/2019/sqlite-autoconf-3270200.tar.gz
[root@djangoServer ~]# tar -zxvf sqlite-autoconf-3270200.tar.gz#构建并安装
[root@djangoServer ~]# cd sqlite-autoconf-3270200
[root@djangoServer sqlite-autoconf-3270200]# ./configure --prefix=/usr/local/sqlite
[root@djangoServer sqlite-autoconf-3270200]# make && make install#检查版本
## 最新安装的sqlite3版本
[root@djangoServer ~]# /usr/local/sqlite/bin/sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@djangoServer ~]# ## Centos7自带的sqlite3版本
[root@djangoServer ~]# /usr/bin/sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@djangoServer ~]# ## 可以看到sqlite3的版本还是旧版本,那么需要更新一下。
[root@djangoServer ~]# sqlite3 --version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
[root@djangoServer ~]# ## 更改旧的sqlite3
[root@djangoServer ~]# mv /usr/bin/sqlite3 /usr/bin/sqlite3_old## 软链接将新的sqlite3设置到/usr/bin目录下
[root@djangoServer ~]# ln -s /usr/local/sqlite/bin/sqlite3 /usr/bin/sqlite3## 查看当前全局sqlite3的版本
[root@djangoServer ~]# sqlite3 --version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0f6d7
[root@djangoServer ~]# #将路径传递给共享库
# 设置开机自启动执行,可以将下面的export语句写入 ~/.bashrc 文件中,如果如果你想立即生效,可以执行source 〜/.bashrc 将在每次启动终端时执行
[root@djangoServer ~]# export LD_LIBRARY_PATH=/usr/local/sqlite/lib
注:coturn的用户信息等,默认是持久化保存在sqlite中,如果想保存到mysql中,上面的sqlite安装选项,需要改成mysql相关的依赖项。
yum -y install mysql-server #可选(安装mysql)
yum -y install mysql-client
yum -y install libmysqlcppconn-dev libmysqlclient-dev libmysql++-dev
下载coturn源码并编译
使用 wget https://github.com/coturn/coturn/archive/4.5.1.3.tar.gz
下载安装包,或是使用 git clone https://github.com/coturn/coturn
下载源码:
[root@2227b264a137 run_env]# wget https://github.com/coturn/coturn/archive/4.5.1.3.tar.gz
[root@2227b264a137 run_env]# tar -zxvf 4.5.1.3.tar.gz
[root@2227b264a137 run_env]# cd coturn-4.5.1.3/
注意:一定要在
./configure
前,把sqlite或mysql依赖项安装好,否则./configure
时无法识别出sqlite或mysql。
[root@2227b264a137 coturn-4.5.1.3]# ./configure -prefix=/usr/local/coturn
sqlite/mysql安装失败时,
./configure
会有类似下面的显示:sqlite/mysql安装成功时,
./configure
会有类似下面的显示:
[root@2227b264a137 coturn-4.5.1.3]# make & make install
检验coturn是否安装成功,出现turnserver程序的详细路径则表示安装成功。
[root@2227b264a137 coturn-4.5.1.3]# whereis which turnserver
which:turnserver: /usr/local/bin/turnserver
使用openssl创建密钥文件
[root@2227b264a137 coturn-4.5.1.3]# openssl req -x509 -newkey rsa:2048 -keyout /etc/turn_server_pkey.pem -out /etc/turn_server_cert.pem -days 99999 -nodes
设置用户名和密码
创建用户ytest,密码为123,同时指定realm为realmtest,请根据实际情况修改。
[root@2227b264a137 coturn-4.5.1.3]# turnadmin -k -u ytest -p 123 -r realmtest
执行命令后会显示一串加密的密码字符串,在/etc目录下新建turnuserdb.conf文件,用于保存用户名和密码。
[root@2227b264a137 coturn-4.5.1.3]# vi /etc/turnuserdb.conf
用户名:密码 的格式
ytest:0x9da593d9d802bae2e1225717b8774253
修改turnserver.conf配置文件
将默认配置模式文件复制一份到/usr/local/etc/下
[root@2227b264a137 coturn-4.5.1.3]# cp /usr/local/etc/turnserver.conf.default /usr/local/etc/turnserver.conf
进入编辑模式:
[root@2227b264a137 coturn-4.5.1.3]# vi /usr/local/etc/turnserver.conf
修改下面几个关键项:
#监听端口
listening-port=3478
#监听的网卡
listening-device=eth0
# 中转网卡
relay-device=eth0
listening-ip=内网ip
tls-listening-port=5349
relay-ip=内网ip
external-ip=外网ip
relay-threads=50
lt-cred-mech
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
min-port=49152
max-port=65535
userdb=/etc/turnuserdb.conf
#turnuserdb.conf中的用户名和密码,可以有多个
user=ytest:0x36f65151a0636f98c27dc77e50836675
#一般与turnadmin创建用户时指定的realm一致,不指定realm时,默认为: 外网地址:3478
#realm=realmtest
启用coturn并验证
[root@2227b264a137 coturn-4.5.1.3]# turnserver -v -r realmtest -a -o -c /usr/local/etc/turnserver.conf
-r realmtest —— 意为指定realm,要与创建用户时指定的realm一致。
可用
lsof -i:3478
校验下是否启动成功,如果看到类似下面的输出,说明3478监听正常。
有问题可以参考: https://github.com/coturn/coturn/issues?q=Cannot+complete+Allocation
离线安装
安装gcc
https://blog.csdn.net/qq_43225978/article/details/88998755#_29
安装openssl
https://blog.csdn.net/qq_43225978/article/details/88998755#_105
编译安装libevent(手动安装)
[root@2227b264a137 run_env]# wget https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz
[root@2227b264a137 run_env]# tar -zxvf libevent-2.1.10-stable.tar.gz
[root@2227b264a137 run_env]# cd libevent-2.1.10-stable
[root@2227b264a137 libevent-2.1.10-stable]# ./configure
[root@2227b264a137 libevent-2.1.10-stable]# make & make install
linux无法编译libevent,一直报错,但是我有装openssl
当指定openssl安装目录,而不是默认安装路径时,需要指定以下指令:
在
/etc/profile
文件添加export PKG_CONFIG_PATH=/usr/local/openssl/lib/pkgconfig
在安装目录下执行
./configure CFLAGS="$(pkg-config --cflags openssl)" LDFLAGS="$(pkg-config --libs openssl)"
安装sqlite或mysql
https://blog.csdn.net/qq_43225978/article/details/88998755#_161
下载coturn源码并编译
http://turnserver.open-sys.org/downloads/ 通过此处下载编译后安装包
使用 wget https://github.com/coturn/coturn/archive/4.5.1.3.tar.gz
或 http://turnserver.open-sys.org/downloads/
下载安装包,或使用 git clone https://github.com/coturn/coturn
下载源码:
[root@2227b264a137 run_env]# wget https://github.com/coturn/coturn/archive/4.5.1.3.tar.gz
[root@2227b264a137 run_env]# tar -zxvf 4.5.1.3.tar.gz
[root@2227b264a137 run_env]# cd coturn-4.5.1.3/
注意:一定要在
./configure
前,把sqlite或mysql依赖项安装好,否则./configure
时无法识别出sqlite或mysql。
[root@2227b264a137 coturn-4.5.1.3]# ./configure -prefix=/usr/local/coturn
sqlite/mysql安装失败时,
./configure
会有类似下面的显示:
sqlite/mysql安装成功时,
./configure
会有类似下面的显示:
[root@2227b264a137 coturn-4.5.1.3]# make & make install
编译安装后:
......==================================================================1) If your system supports automatic start-up system daemon services,
then to enable the turnserver as a system service that is automatically
started, you have to:a) Create and edit /etc/turnserver.conf or /usr/local/etc/turnserver.conf . Use /usr/local/etc/turnserver.conf.default as an example.b) For user accounts settings: set up SQLite or PostgreSQL or MySQL or MongoDB or Redis database for user accounts.Use /usr/local/share/turnserver/schema.sql as SQL database schema,or use /usr/local/share/turnserver/schema.userdb.redis as Redisdatabase schema description and/or /usr/local/share/turnserver/schema.stats.redisas Redis status & statistics database schema description.If you are using SQLite, the default database location is in /var/db/turndb or in /usr/local/var/db/turndb or in /var/lib/turn/turndb.c) add whatever is necessary to enable start-up daemon for the /usr/local/bin/turnserver.2) If you do not want the turnserver to be a system service, then you can start/stop it "manually", using the "turnserver" executable with appropriate options (see the documentation).3) To create database schema, use schema in file
/usr/local/share/turnserver/schema.sql.4) For additional information, run:$ man turnserver$ man turnadmin$ man turnutils==================================================================[1]+ 退出 2 make
检验coturn是否安装成功,出现turnserver程序的详细路径则表示安装成功。
[root@2227b264a137 coturn-4.5.1.3]# whereis which turnserver
which:turnserver: /usr/local/bin/turnserver
使用openssl创建密钥文件
[root@2227b264a137 coturn-4.5.1.3]# openssl req -x509 -newkey rsa:2048 -keyout /usr/local/coturn/cert/turn_server_pkey.pem -out /usr/local/coturn/cert/turn_server_cert.pem -days 99999 -nodes
设置用户名和密码
创建用户ytest,密码为123,同时指定realm为realmtest,请根据实际情况修改。
[root@2227b264a137 coturn-4.5.1.3]# turnadmin -k -u ytest -p 123 -r stun.realmtest.cn
执行命令后会显示一串加密的密码字符串,在/etc目录下新建turnuserdb.conf文件,用于保存用户名和密码。
[root@2227b264a137 coturn-4.5.1.3]# vi/usr/local/coturn/etc/turnuserdb.conf
用户名:密码 的格式
ytest:0x9da593d9d802bae2e1225717b8774253
修改turnserver.conf配置文件
将默认配置模式文件复制一份到/usr/local/etc/下
[root@2227b264a137 coturn-4.5.1.3]# cp /usr/local/coturn/etc/turnserver.conf.default /usr/local/coturn/etc/turnserver.conf
进入编辑模式:
[root@2227b264a137 coturn-4.5.1.3]# vi /usr/local/coturn/etc/turnserver.conf
修改下面几个关键项:
#监听端口
listening-port=3478
#监听的网卡
listening-device=eth0
# 中转网卡
relay-device=eth0
listening-ip=内网ip
tls-listening-port=5349
relay-ip=内网ip
external-ip=外网ip
relay-threads=50
lt-cred-mech
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
min-port=49152
max-port=65535
userdb=/usr/local/coturn/etc/turnuserdb.conf
#turnuserdb.conf中的用户名和密码,可以有多个
user=ytest:0x36f65151a0636f98c27dc77e50836675
#一般与turnadmin创建用户时指定的realm一致,不指定realm时,默认为: 外网地址:3478
#realm=stun.realmtest.cn
cli-password=123456
启用coturn并验证
[root@2227b264a137 coturn-4.5.1.3]# turnserver -v -r stun.realmtest.cn -a -o -c /usr/local/etc/turnserver.conf
-r stun.realmtest.cn—— 意为指定realm,要与创建用户时指定的realm一致。
-o(此命令为后台启动,不占用窗口)
可用
lsof -i:3478
校验下是否启动成功,如果看到类似下面的输出,说明3478监听正常。
验证coturn服务
turnutils_uclient coturn服务所在服务器公网IP -u 用户名 -w 密码
turnutils_uclient 182.132.2.3 -u ytest -w 123
WebRTC NAT穿透服务器 coturn服务搭建相关推荐
- Centos7安装WebRtc打洞服务器Coturn方法
在使用WebRtc时,我们需要打洞服务器来打洞两部设备之间的通信,这里我们采用Coturn库.由于Turn服务器是Stun的一个拓展,Coturn包括了Turn和Stun,所有我们只需要部署Cotur ...
- webRTC+coturn穿透服务器的安装与搭建
webRTC+coturn穿透服务器的安装与搭建 系统环境:ubuntu-16.04-desktop-i386 1.首先安装信令服务器,以ProjectRTC为例; sudo apt-get inst ...
- webrtc笔记(1): 基于coturn项目的stun/turn服务器搭建
webrtc是google推出的基于浏览器的实时语音-视频通讯架构.其典型的应用场景为:浏览器之间端到端(p2p)实时视频对话,但由于网络环境的复杂性(比如:路由器/交换机/防火墙等),浏览器与浏览器 ...
- frps搭建内网穿透服务器(frp隧道)
frps搭建自己的内网穿透服务器 开发过程中,很多时候我们需要用到内网穿透,将自己的服务器映射到外网,下面说一下怎么用frps搭建自己的内网穿透服务器 frps Github地址 GitHub - f ...
- 从创建服务器到搭建一台内网穿透服务器
文章目录 创建服务器到搭建一台内网穿透服务器 解决VMware虚拟机ip地址经常变化的问题 安装lrzsz Linux中rz和sz命令用法详解 安装插件 安装jdk 安装maven 安装git 安装n ...
- zeroTier实现内网穿透-moon服务搭建
序言 frp 很多人都了解,是一个用于内网穿透的高性能的反向代理应用,简单点说就是可以把 NAT 后面的某台机器的端口转发到公网 IP上去,类似 ngrok 或者花生壳内网版,好处是可以自建. UDP ...
- WebRTC中的NAT穿透
NAT简介 我们知道,WebRTC会按照内网.P2P.中转的顺序来尝试连接.在大部分的情况下,实际是使用P2P或者中转的.这里P2P的场景主要使用的技术就是NAT穿透. 我们先简单了解下NAT.NAT ...
- windows 下frp服务启动_内网穿透frp linux服务端搭建和windows客户端使用
一.Linux 服务端搭建 1.下载安装 wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-in ...
- ubantu安装coturn穿透服务器
ubantu安装coturn穿透服务器 目录 安装软件包 配置coturn 完成安装 1. 安装软件包 购买阿里云服务器(闲鱼买一年60),安装ubantu系统 安装软件包 apt update ap ...
- frps搭建自己的内网穿透服务器
开发过程中,很多时候我们需要用到内网穿透,将自己的服务器映射到外网,下面说一下怎么用frps搭建自己的内网穿透服务器 frps Github地址 里面有中文文档,大家可以参考 服务器搭建 服务器搭建 ...
最新文章
- 05后都上清华了!首批丘成桐数学领军人才名单发布,三位菲尔兹奖得主为其授课,周末就来学校报到...
- 看图学NumPy:掌握n维数组基础知识点,看这一篇就够了
- 2010 .NET面试题整理之基础篇
- 使用JPA获取Oracle中的日期字段丢失时分秒
- 负载均衡服务器性能,服务器负载均衡:确保应用服务的高性能与高可用
- 她,既是一个风华绝代的演员,更是WiFi之母...
- 【Python 必会技巧】获取字典中(多个)最大值(value)的键(key)
- Android访问php webservice
- 【小超_Android】GitHub源码项目整理,希望对大家有帮助
- Ora-19804: Cannot reclaim 45561856 bytes disk space from 8589934592 limit
- CASS利用控制点进行图形坐标系转换(80转2000)
- 华为s5500t服务器硬盘,HuaweiOceanStor1T SAS 7.2K3.5寸WD1003FBYXS5500T存储硬盘
- 黑群晖DSM7.1.0物理机安装教程
- 清华大学计算机夏文韬,太猛了--南京外国语学校2007届高三毕业生去向
- iOS APP更换应用图标logo
- 易岸公考:最全版本!公务员报考条件
- Ant批量打包工具的使用
- 彩虹代刷源码+支付接口 搭建教程
- DVWA靶场-sql盲注
- html如何带入背景,html怎么导入背景图
热门文章
- html中调用javascript函数,如何在HTML中调用JavaScript函数
- 88se9230 linux raid,M.2转4口SATA 6G RAID阵列卡 (PCIe2.0),IO-M2F9230-4IR
- 免费将pdf文件转换成word
- [转]什么是UAT测试?
- 介绍几款在线编程工具(Python)
- Linux Vim快捷键
- 山东计算机平面设计学校,什么人适合学平面设计?山东有哪些开设平面设计的学校?...
- 使用Python实现XML文件转为Excel文件
- 将中文版pycharm改成英文版
- 智能化趋势 v3.0:模板、虚拟与现实交互、无限画布