我已经配置了本地 Asterisk 服务器。有本地用户和一条用于外部呼叫的中继。
用户可以顺利拨打本地电话和拨打电话。但是当外部电话打到服务器时,它会响应 401 错误(1.1.1.1 代表提供商 IP,2.2.2.2 代表本地服务器的 IP)。
邀请:
<--- Received SIP request (1079 bytes) from UDP:1.1.1.1:5060 --->
INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK2b074f13;rport
Max-Forwards: 70
From: <sip:[email protected]>;tag=as5b4c0767
To: <sip:[email protected]:5060>
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]:5060
CSeq: 105 INVITE
User-Agent: VoIPVTK
Authorization: Digest username="s", realm="asterisk", algorithm=MD5, uri="sip:[email protected]", nonce="1617646804/4c072b7aa1d5799d84d11f1e857387a0", response="7e12bdf0955235437f8d49fee0fc517a", opaque="1d4bee854523cdda", qop=auth, cnonce="3c7da01c", nc=00000003
Date: Mon, 05 Apr 2021 18:20:04 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 226
v=0
o=VoIPVTK 1371915978 1371915981 IN IP4 1.1.1.1
s=VoIPVTK
c=IN IP4 1.1.1.1
t=0 0
m=audio 11250 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
回复:
[Apr 5 21:20:04] NOTICE[72898]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:[email protected]>' failed for '1.1.1.1:5060' (callid: [email protected]:5060) - Failed to authenticate
<--- Transmitting SIP response (502 bytes) to UDP:1.1.1.1:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 1.1.1.1:5060;rport=5060;received=1.1.1.1;branch=z9hG4bK2b074f13
Call-ID: [email protected]:5060
From: <sip:[email protected]>;tag=as5b4c0767
To: <sip:[email protected]>;tag=z9hG4bK2b074f13
CSeq: 105 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1617646804/4c072b7aa1d5799d84d11f1e857387a0",opaque="52b0860022fc8faa",algorithm=md5,qop="auth"
Server: Asterisk PBX 18.2.0
Content-Length: 0
提供商发送的 OPTIONS 请求也因同样的错误而失败。来自我们服务器的 OPTIONS 请求成功。
看起来提供商未经授权就发送了数据包,而服务器却需要授权。
这该如何解决?
答案1
registration/contact_user = 123456789 ;phone number or other contact info, provided by ISTP
通过添加到主干配置(向导类型)解决了该问题。
对于非巫师:
[trunk-name]
type=registration
contact_user = 123456789 ;phone number for incoming calls or other contact info, provided by ISTP
完成此操作后,我们在 ISTP 的注册信息从更改[email protected]:5060
为[email protected]:5060