coturn:需要帮助正确配置我的服务器

coturn: Need help configurating my server correctly

我正在尝试在我的本地计算机上为我的 webrtc 应用程序设置一个 STUN/TURN 服务器。我决定使用 coturn。请注意,我的服务器在 NAT 后面 运行。

所以我启动了我的 Ubuntu VM 并安装了它。在通读了 wiki 之后,我让它工作了,至少在我的本地网络上。出于测试目的,我使用 this site。因此,当我在那里尝试使用 192.168.178.25:3478 时,它有效。当我用 "public-ip":3478 尝试时,它没有。

这告诉我,它在本地工作,应该是 port/NAT 问题。我做了什么:

1) 我将虚拟机设置为桥接

2) 我在路由器上打开了端口 3478。为了测试这是否真的有效,我在远程机器上使用了 telnet 并且它有效。另一个测试是我在我的本地机器上的端口 3478 上设置了一个快速的 apache 服务器,它可以从外部访问。这告诉我存在或不应该存在 port/NAT 问题,我的 turn 服务器应该可以正常工作。

有什么想法吗?

我是 运行 我的服务器,命令如下:

"sudo turnserver -X "public-ip" -listening-port=3478 -v

turnserver.conf 看起来像这样:

由于 telnet 和 apache 服务器都在工作,我很确定我遇到了配置问题。我基本上整个周末都在尝试,但我真的不知道哪里出了问题。

感谢您的帮助!

来自turnserverdocumentation

-X, --external-ip <public-ip>[/private-ip] TURN Server public/private address mapping, if the server is behind NAT. In that situation, if a -X is used in form "-X " then that ip will be reported as relay IP address of all allocations. This scenario works only in a simple case when one single relay address is to be used, and no CHANGE_REQUEST STUN functionality is required. That single relay address must be mapped by NAT to the 'external' IP. The "external-ip" value, if not empty, is returned in XOR-RELAYED-ADDRESS field. For that 'external' IP, NAT must forward ports directly (relayed port 12345 must be always mapped to the same 'external' port 12345). In more complex case when more than one IP address is involved, that option must be used several times, each entry must have form "-X ", to map all involved addresses. CHANGE_REQUEST NAT discovery STUN functionality will work correctly, if the addresses are mapped properly, even when the TURN server itself is behind A NAT. By default, this value is empty, and no address mapping is used.

因此,仅将内部 LAN 的侦听端口公开到 public 网络是不够的,而是要公开所有要用于中继的端口。请注意同一文档中的内容:

--min-port <port> Lower bound of the UDP port range for relay endpoints allocation. Default value is 49152, according to RFC 5766.
--max-port <port> Upper bound of the UDP port range for relay endpoints allocation. Default value is 65535, according to RFC 5766.

您应该在服务器中选择一系列端口,用它们配置选项 --min-port 和 --max-port 并创建一个 NAT 规则以将这些端口暴露给服务器的 public 端没有变化的路由器。