Authorizing to service provider

Hi there,

I am quite new to Asterisk, setting up my first system. I am trying to make a PBX on our network with asterisk on an Ubuntu18 vm.
Internal calling and inbound calls go just fine.
However, when attempting to make an outbound call I first get a 100 trying and then a 403 forbidden.

My configuration is basically the sample config from https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples (no.2)

<--- Transmitting SIP request (901 bytes) to UDP:[myprovider]:5060 --->
INVITE sip:[mobilephone]@sip.myprovider.com:5060 SIP/2.0
Via: SIP/2.0/UDP [myip]:5060;rport;branch=z9hG4bKPjTCmUWug.r6T.8eq.0d4NuM4QyegnESSy
From: "[deskphone]" <sip:[localnumber]@192.168.1.3>;tag=jHA.w0JCu.Lvs42HI7HRxs6nuZKvBZX3
To: <sip:[mobilephone]@sip.myprovider.com>
Contact: <sip:asterisk@[myip]:5060>
Call-ID: ctrsg83gzndDSt9le.4dmtoHVXeABVfW
CSeq: 1121 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 14.7.8
Content-Type: application/sdp
Content-Length:   233

v=0
o=- 861016884 861016884 IN IP4 192.168.1.3
s=Asterisk
c=IN IP4 [myip]
t=0 0
m=audio 28794 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<--- Received SIP response (323 bytes) from UDP:[myprovider]:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP [myip]:5060;received=[myip];branch=z9hG4bKPjTCmUWug.r6T.8eq.0d4NuM4QyegnESSy;rport=5060
From: "deskphone" <sip:[localnumber]@192.168.1.3>;tag=jHA.w0JCu.Lvs42HI7HRxs6nuZKvBZX3
To: <sip:[mobilephone]@sip.myprovider.com>
Call-ID: ctrsg83gzndDSt9le.4dmtoHVXeABVfW
CSeq: 1121 INVITE


<--- Received SIP response (354 bytes) from UDP:[myprovider]:5060 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP [myip]:5060;received=[myip];branch=z9hG4bKPjTCmUWug.r6T.8eq.0d4NuM4QyegnESSy;rport=5060
From: "deskphone" <sip:[localnumber]@192.168.1.3>;tag=jHA.w0JCu.Lvs42HI7HRxs6nuZKvBZX3
To: <sip:[mobilephone]@sip.myprovider.com>;tag=aprqngfrt-t9ns203000126
Call-ID: ctrsg83gzndDSt9le.4dmtoHVXeABVfW
CSeq: 1121 INVITE

Provider need to tell you what are you missing or sending wrong in your INVITE request

You haven’t even got to trying to authenticate. The provider has rejected you without even challenging for authentication.

Is [localnumber] your account name with the provider, as some will identify you by your From: header user part.

1 Like

Inspired by David I took a look at the register packages:
the FROM header authenticates with [localnumber]@sip.myprovider.com, but the INVITE is sent with [localnumber]@192.168.1.3 (ip of my pbx).
How would I modify the domain in from? I am using asterisk 14.7.8, I am already using CALLERID(num) for the user part.

<— Transmitting SIP request (541 bytes) to UDP:[providerip]:5060 —>
REGISTER sip:sip.myprovider.com:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.3:5060;rport;branch=z9hG4bKPjNXIeoAGva1VdTPMcRU.0xdZp5ckoOHvv
From: sip:[localnumber]@sip.myprovider.com;tag=ZVZfNL1sSCmy0ruebCbeMw1Qz8PIuqvs
To: sip:[localnumber]@sip.myprovider.com
Call-ID: uqmq54p272rQtfPIJOHjXpMfnK49vr8h
CSeq: 37115 REGISTER
Contact: sip:s@192.168.1.3:5060
Expires: 3600
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk PBX 14.7.8
Content-Length: 0

<— Received SIP response (467 bytes) from UDP:[providerip]:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.3:5060;received=[myip];branch=z9hG4bKPjNXIeoAGva1VdTPMcRU.0xdZp5ckoOHvv;rport=5060
From: sip:[localnumber]@sip.myprovider.com;tag=ZVZfNL1sSCmy0ruebCbeMw1Qz8PIuqvs
To: sip:[localnumber]@sip.myprovider.com;tag=9424e3d07702fd5bd45752fe654f1120.73cb
Call-ID: uqmq54p272rQtfPIJOHjXpMfnK49vr8h
CSeq: 37115 REGISTER
WWW-Authenticate: Digest realm=“myprovider.com”, nonce="[redacted]"
Content-Length: 0

<— Transmitting SIP request (722 bytes) to UDP:[providerip]:5060 —>
REGISTER sip:sip.myprovider.com:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.3:5060;rport;branch=z9hG4bKPjNYve9ZAW8GrVEgEfZgXRWGI6Guu53jzl
From: sip:[localnumber]@sip.myprovider.com;tag=ZVZfNL1sSCmy0ruebCbeMw1Qz8PIuqvs
To: sip:[localnumber]@sip.myprovider.com
Call-ID: uqmq54p272rQtfPIJOHjXpMfnK49vr8h
CSeq: 37116 REGISTER
Contact: sip:s@192.168.1.3:5060
Expires: 3600
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk PBX 14.7.8
Authorization: Digest username="[localnumber]", realm=“myprovider.com”, nonce="[redacted]", uri=“sip:sip.myprovider.com:5060”, response="[redacted]"
Content-Length: 0

<— Received SIP response (418 bytes) from UDP:[providerip]:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.3:5060;received=[myip];branch=z9hG4bKPjNYve9ZAW8GrVEgEfZgXRWGI6Guu53jzl;rport=5060
From: sip:[localnumber]@sip.myprovider.com;tag=ZVZfNL1sSCmy0ruebCbeMw1Qz8PIuqvs
To: sip:[localnumber]@sip.myprovider.com;tag=9424e3d07702fd5bd45752fe654f1120.d196
Call-ID: uqmq54p272rQtfPIJOHjXpMfnK49vr8h
CSeq: 37116 REGISTER
Contact: sip:s@192.168.1.3:5060;expires=120
Content-Length: 0

Sorry, I only know the answer to that for chan_sip.

@david551 I see you use chan_sip and dont give a try to pjsip, any particular reason that you can share,

There are historical reasons which I have gone into in a private message. The reasons don’t have any bearing on pjsip’s suitability for ordinary users, especially when compared with the official chan_sip.

1 Like

Thanks I 'm reading the message