我最近设置了版本 16.4.0 LTS 的 Asterisk 服务器。我对 Asterisk 完全陌生,但我已经设法设置了带有该服务的服务器,它在 LAN 用户之间运行顺畅,并且在我的国家(智利)的 ISP 上也能正常使用互联网。但我认为 PJSIP 文件的配置参数存在一些问题,因为我遇到了与 NAT 问题相关的不同问题。
我在巴西,我的服务器在智利,我还有一个来自德国的用户在测试。
我可以呼叫服务器,也可以呼叫服务器上的任何端点。我设置了一个 hello world 测试,我可以毫无问题地呼叫并听到 hello world。启用 RTP 调试选项后,我可以看到数据包如何顺利到达我在巴西的端点。但每当我呼叫任何用户并尝试通信时,双方都听不到任何声音。德国用户也遇到了同样的情况。
当我查看 CLI 时,我得到了以下信息:
-- PJSIP/Brasil-0000000b answered PJSIP/Chile-0000000a
> 0x7f380c041530 -- Strict RTP learning after remote address set to: 179.155.225.168:49202
> 0x7f380c03a4f0 -- Strict RTP learning after remote address set to: 192.168.1.200:53250
-- Channel PJSIP/Brasil-0000000b joined 'simple_bridge' basic-bridge <ec2f76a3-8e8c-453a-ada4-fb9326489237>
-- Channel PJSIP/Chile-0000000a joined 'simple_bridge' basic-bridge <ec2f76a3-8e8c-453a-ada4-fb9326489237>
> Bridge ec2f76a3-8e8c-453a-ada4-fb9326489237: switching from simple_bridge technology to native_rtp
> Locally RTP bridged 'PJSIP/Chile-0000000a' and 'PJSIP/Brasil-0000000b' in stack
-- Channel PJSIP/Brasil-0000000b left 'native_rtp' basic-bridge <ec2f76a3-8e8c-453a-ada4-fb9326489237>
-- Channel PJSIP/Chile-0000000a left 'native_rtp' basic-bridge <ec2f76a3-8e8c-453a-ada4-fb9326489237>
== Spawn extension (from-internal, 110, 1) exited non-zero on 'PJSIP/PruebaLocal-0000000a'
上述情况适用,双方都无法听到对方的声音。
但是,当进行内部呼叫时,用户可以互相呼叫并听到对方的声音,没有任何问题。当他们进行内部呼叫时,我在 CLI 中看到以下内容;
== Setting global variable 'SIPDOMAIN' to '192.168.1.20'
-- Executing [104@from-internal:1] Dial("PJSIP/Chile1-00000011", "PJSIP/Chile2,30") in new stack
-- Called PJSIP/Chile2
-- PJSIP/Chile2-00000012 is ringing
-- PJSIP/Chile2-00000012 is ringing
-- PJSIP/Chile2-00000012 answered PJSIP/Chile1-00000011
> 0x7f380c020920 -- Strict RTP learning after remote address set to: 192.168.1.102:53848
> 0x7f380c0461e0 -- Strict RTP learning after remote address set to: 192.168.1.107:16400
-- Channel PJSIP/Chile2-00000012 joined 'simple_bridge' basic-bridge <54d507b3-7af2-4b8c-ae73-61dc84b5d2c8>
-- Channel PJSIP/Chile1-00000011 joined 'simple_bridge' basic-bridge <54d507b3-7af2-4b8c-ae73-61dc84b5d2c8>
> Bridge 54d507b3-7af2-4b8c-ae73-61dc84b5d2c8: switching from simple_bridge technology to native_rtp
> Remotely bridged 'PJSIP/Chile1-00000011' and 'PJSIP/Chile2-00000012' - media will flow directly between them
> 0x7f380c020920 -- Strict RTP learning after remote address set to: 192.168.1.102:53848
> 0x7f380c0461e0 -- Strict RTP learning after remote address set to: 192.168.1.107:16400
-- Channel PJSIP/Chile1-00000011 left 'native_rtp' basic-bridge <54d507b3-7af2-4b8c-ae73-61dc84b5d2c8>
-- Channel PJSIP/Chile2-00000012 left 'native_rtp' basic-bridge <54d507b3-7af2-4b8c-ae73-61dc84b5d2c8>
== Spawn extension (from-internal, 104, 1) exited non-zero on 'PJSIP/Chile1-00000011'
我的 PJSIP 如下所示:
;
;General Settings first
;
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
;bind=0.0.0.0
local_net=192.168.1.0/24
external_media_address=THE_IP_FOR_MY_SERVER
external_signaling_address=THE_IP_FOR_MY_SERVER
;
;Phones on LAN
;
[endpoint_internal](!)
type=endpoint
context=from-internal
disallow=all
allow=alaw
allow=ulaw
;allow=g729
direct_media=no
;
;Phones outside LAN
;
[endpoint_external](!)
type=endpoint
context=from-internal
disallow=all
allow=alaw
allow=ulaw
;allow=g729
;From here testing
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
ice_support=yes
;
;Auth options for our clients
;
[auth_userpass](!)
type=auth
auth_type=userpass
[aor_dynamic](!)
type=aor
remove_existing=yes
max_contacts=10
;Internal Users
[Chile](endpoint_internal)
auth=Chile
aors=Chile
[Chile](auth_userpass)
password=STRONG_PASSWORD
username=Chile
[Chile](aor_dynamic)
;External users
[Brasil](endpoint_external)
auth=Brasil
aors=Brasil
[Brasil](auth_userpass)
password=STRONG_PASSWORD
username=Brasil
[Brasil](aor_dynamic)
我的扩展配置如下:
[Phones]
exten=>110,1,Dial(PJSIP/Brasil,30)
exten=>111,1,Dial(PJSIP/Chile,30)
如果有人有想法或者能指出解决这个问题的方向,我将不胜感激。
问候。
答案1
确保两台服务器(巴西和德国)的 RTP 端口都已转发。您可以参考 中设置的值rtp.conf
。默认情况下,它是 10000 到 20000 UDP。
答案2
我禁用了 CentOS 机器上的防火墙(我们整个局域网还有另一个防火墙),现在一切正常。