Asterisk NAT SIP 2.0 Unathorized 401奇怪场景

时间:2015-05-19 17:19:03

标签: asterisk sip nat

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

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具有公共静态IP和本地类c 网络192.168.1.X,星号位于NAT后面。 某些手机​​位于同一本地网络上,而其他手机位于网站B 站点B有另一个公共静态IP和本地c类网络 192.168.2.X. 因此,网站B上的手机也是nat的背后。

奇怪的是,网站B上的某些手机可以注册,而其他手机则无法注册。 最有趣的例子是一个grandstream gxp 2100。 这款手机有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


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

您认为导致此问题的原因是什么? 提前感谢您的支持和帮助!

1 个答案:

答案 0 :(得分:1)

这是星号的正常行为

Asterisk用NEW nonce数据包回答为UNATHORIZED。之后,客户端再次使用该随机数计算md5sum。

非常喜欢你的情况客户端由于某种原因没有收到该数据包(不正确的nat设置,防火墙等)