SIP: 401 Unauthorized from My Server to SIP

Hi All,

I am trying to get my DID to work in Asterisk Version 13.12.1 this is what my SIP provider said was happening.
My Invite message on my test call from my cell phone:

INVITE sip:[email protected]:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP;branch=z9hG4bK+56dd28313993f8adc333728619d39e0f1+sip+1+b323e755
From: “CTC TELECOM” sip:[email protected]:5060;;isup-oli=62
To: sip:[email protected]
CSeq: 286513367 INVITE
Expires: 180
Content-Length: 178
Supported: resource-priority,siprec, 100rel
Contact: sip:[email protected]:5060;isup-oli=62
Content-Type: application/sdp
Allow-Events: message-summary, refer, dialog, line-seize, presence, call-info, as-feature-event, calling-name
Max-Forwards: 69
Call-ID: 0gQAAC8WAAACBAAALxYAAHUCnp9T4RXw0W+EU/hSYs8whGTTgG/[email protected]
Organization: MetaSwitch
P-Asserted-Identity: “CTC TELECOM” sip:[email protected]:5060
Accept: application/sdp, application/dtmf-relay

o=- 18962383773092 18962383773092 IN IP4
c=IN IP4
t=0 0
m=audio 28188 RTP/AVP 18 0 101
a=rtpmap:101 telephone-event/8000

The full message I am getting from your phone system:

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP;branch=z9hG4bK+56dd28313993f8adc333728619d39e0f1+sip+1+b323e755;;rport=5060
From: “CTC TELECOM” sip:[email protected]:5060;;isup-oli=62
To: sip:[email protected];tag=as54c9556d
Call-ID: 0gQAAC8WAAACBAAALxYAAHUCnp9T4RXw0W+EU/hSYs8whGTTgG/[email protected]
CSeq: 286513367 INVITE
Server: FPBX-
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="4a16d99c"
Content-Length: 0

I can place calls out

Here is my Trunk Set up

I have the Inbound route of the DID set to go to my Ext.

I don’t know what I am missing. Any hlep would be great

Ask your provider if they are using IP authentication or registration. If the former, you can lose the username and password on the inbound side. Note that you may need to set up different incoming and outgoing (peer and user) sections in your trunk if that’s the case.

1 Like

I just got an email from my provider. They stated that they can see calls going to and coming from the server now. It is IP Authentication. I can now see the calls in the asterisk -rvvv log but I now get a busy signal and it shows this.

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [[email protected]:1] Set(“SIP/ctctelcom.net1-0000001d”, “__FROM_DID=4302”) in new stack
– Executing [[email protected]:2] NoOp(“SIP/ctctelcom.net1-0000001d”, “Received an unknown call with DID set to 4302”) in new stack
– Executing [[email protected]:3] Goto(“SIP/ctctelcom.net1-0000001d”, “s,a2”) in new stack
– Goto (from-trunk,s,2)
– Executing [[email protected]:2] Answer(“SIP/ctctelcom.net1-0000001d”, “”) in new stack
– Executing [[email protected]:3] Log(“SIP/ctctelcom.net1-0000001d”, “WARNING,Friendly Scanner from”) in new stack
[2017-12-04 13:23:20] WARNING[6054][C-0000002f]: Ext. s:3 @ from-trunk: Friendly Scanner from
– Executing [[email protected]:4] Wait(“SIP/ctctelcom.net1-0000001d”, “2”) in new stack
– Executing [[email protected]:5] Playback(“SIP/ctctelcom.net1-0000001d”, “ss-noservice”) in new stack
– <SIP/ctctelcom.net1-0000001d> Playing ‘ss-noservice.ulaw’ (language ‘en’)
– Executing [[email protected]:6] SayAlpha(“SIP/ctctelcom.net1-0000001d”, “4302”) in new stack
– <SIP/ctctelcom.net1-0000001d> Playing ‘digits/4.ulaw’ (language ‘en’)
– <SIP/ctctelcom.net1-0000001d> Playing ‘digits/3.ulaw’ (language ‘en’)
– <SIP/ctctelcom.net1-0000001d> Playing ‘digits/0.ulaw’ (language ‘en’)
– <SIP/ctctelcom.net1-0000001d> Playing ‘digits/2.ulaw’ (language ‘en’)
== Spawn extension (from-trunk, s, 6) exited non-zero on ‘SIP/ctctelcom.net1-0000001d’
– Executing [[email protected]:1] Macro(“SIP/ctctelcom.net1-0000001d”, “hangupcall,”) in new stack
– Executing [[email protected]:1] GotoIf(“SIP/ctctelcom.net1-0000001d”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [[email protected]:3] ExecIf(“SIP/ctctelcom.net1-0000001d”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [[email protected]:4] Hangup(“SIP/ctctelcom.net1-0000001d”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/ctctelcom.net1-0000001d’ in macro ‘hangupcall’
== Spawn extension (from-trunk, h, 1) exited non-zero on ‘SIP/ctctelcom.net1-0000001d’

Not sure why it is doing that.

Ok, I figured it out. The Asterisk server can use what looks like any DID inbound format. My SIP provider sends just the DID4 format so All I needed to do was fix the inbound route to have the last four #'s of the DID and it worked. Thanks for all the reply and help.