Asterisk NAT SIP 2.0 Unathorized 401 奇怪的场景

Asterisk NAT SIP 2.0 Unathorized 401 Weird scenario

首先我已经看过类似的问题,例如:

https://serverfault.com/questions/392979/asterisk-sip-2-0-401-unauthorized 要么 https://serverfault.com/questions/574166/asterisk-401-unauthorized-when-trying-to-register-sip-clients

但它们不适用于我的情况或解决方案没有解决我的问题。

我在 站点 A 上有一个星号 1.8 框。 站点 A 有一个 public 静态 IP 和一个本地 class c 网络 192.168.1.X ,星号在 NAT 后面。 一些 phone 在同一个本地网络上,而另一些在 站点 B 中。 站点 B 有另一个 public 静态 IP 和一个本地 class c 网络 192.168.2.X。 因此,站点 B 上的 phone 也落后于 nat。

奇怪的是,站点 B 上的某些 phone 可以注册,而其他则不能。 最有趣的例子是一台 Grandstream gxp 2100。 此 phone 有 3 个帐户,配置如下:

[1000]
deny=0.0.0.0/0.0.0.0
secret=xxxxxx
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
trustrpid=yes
sendrpid=no
type=friend
nat=yes
port=5060
qualify=3000
qualifyfreq=60
transport=udp
encryption=no
callgroup=
pickupgroup=
dial=SIP/1000
mailbox=1000@device
permit=0.0.0.0/0.0.0.0
callerid=TONY - Lab Line 1 <1000>
callcounter=yes
faxdetect=no
cc_monitor_policy=generic

[3000]
deny=0.0.0.0/0.0.0.0
secret=xxxxxxx
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
trustrpid=yes
sendrpid=no
type=friend
nat=yes
port=5060
qualify=3000
qualifyfreq=60
transport=udp
encryption=no
callgroup=
pickupgroup=
dial=SIP/3000
mailbox=3000@device


[9000]
deny=0.0.0.0/0.0.0.0
secret=xxxxxxxxxxx
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
trustrpid=yes
sendrpid=no
type=friend
nat=yes
port=5060
qualify=3000
qualifyfreq=60
transport=udp
encryption=no
callgroup=
pickupgroup=
dial=SIP/9000
mailbox=9000@device

只有账号1000和3000可以注册,账号9000出现如下错误:

<--- SIP read from UDP:95.254.61.X:5064 --->
REGISTER sip:95.231.94.6 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.190:5064;branch=z9hG4bK1380984150;rport
From: <sip:9000@95.231.94.6>;tag=1294836145
To: <sip:9000@95.231.94.6>
Call-ID: 844020207-5064-1@BJC.BGI.C.BJA
CSeq: 2672 REGISTER
Contact: <sip:9000@192.168.2.190:5064>;reg-id=3;+sip.instance="<urn:uuid:00000000-0000-1000-8000-000B8251202A>"
X-Grandstream-PBX: true
Max-Forwards: 70
User-Agent: Grandstream GXP2100 1.0.5.23
Supported: path
Expires: 3600
Allow: INVITE, ACK, OPTIONS, CANCEL, BYE, SUBSCRIBE, NOTIFY, INFO, REFER, UPDATE, MESSAGE
Content-Length: 0

<------------->
--- (14 headers 0 lines) ---
Sending to 95.254.61.X:5064 (NAT)

<--- Transmitting (NAT) to 95.254.61.X:5064 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.2.190:5064;branch=z9hG4bK1380984150;received=95.254.61.248;rport=5064
From: <sip:9000@95.231.94.6>;tag=1294836145
To: <sip:9000@95.231.94.6>;tag=as54ceb003
Call-ID: 844020207-5064-1@BJC.BGI.C.BJA
CSeq: 2672 REGISTER
Server: FPBX-2.10.1(1.8.21.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="47737672"
Content-Length: 0


<------------>

您认为是什么导致了这个问题? 预先感谢您的支持和帮助!

这是星号的正常行为

星号答案为未授权,带有新的 nonce 数据包。在那个客户再次回答用那个随机数计算的 md5sum 之后。

很可能在您的情况下客户端由于某种原因(不正确的 nat 设置、防火墙等)没有收到该数据包