Cannot register to trunk

Hi all, hope someone can help me fix this problem with my home installation.
I have a nas with asterisk installed and fully working, the only problem is with this trunk that indeed is an ISP provided router with a voip pbx onboard, i sniffed the login data.
If i put that login in a softphone like “linphone” on my mac i can connect to the ISP pbx and everything works fine. If i use the same login data in my asterisk installation (so i wanna join my configured asterisk with the isp router and use that as a trunk for all my phone) i’m get this annoying problem:
i can pair asterisk with the isp box (bellow the sip.conf that i’m using) but i cannot place an outgoing call. BUT if i leave linphone running on my Mac (with the same login data) everything is working (more bellow the sip debug with and without the linphone software running).

sip_peer.conf

[peer-locale] type = peer username = utente fromuser = utente secret = password host = 192.168.99.254 port = 5065 context = context-incoming-peer qualify = yes

sip.conf

[general]
context=default-incoming-call-context
allowoverlap=yes
allowtransfer=yes
realm=asterisk
bindaddr=0.0.0.0
srvlookup=yes
maxexpiry=3600
minexpiry=60
defaultexpiry=300
qualifyfreq=55
disallow=all
allow=ulaw
allow=alaw
dtmfmode=rfc2833
alwaysauthreject = yes
t1min=100
timert1=500
timerb=16000
rtptimeout=600
rtpkeepalive=30
useragent=PBX
localnet=192.168.99.0/16
permit=192.168.99.0/255.255.255.0
externrefresh=120
directmedia=no    (also tried yes but nothing changes)
sipdebug=yes[/code]


in sip_registration.conf
[code]utente:password@192.168.99.254:5065/utente[/code]


in linphone the config is the simples:
[code]user: same user as in the sip.conf etc..
password: idem
host: 192.168.99.254:5065
registration duration: 3600 sec
maximum trasmission unit: 1300[/code]


this is the sip_debug with linphone opened, so the out calling is working fine:

[code]<------------>
-- Executing [mio_cellulare@context-user-559582:1] Dial("SIP/559582-00000000", "SIP/mio_cellulare@peer-39numero_fisso_su_ISP_sip_ISP_local,60,r") in new stack
== Using SIP RTP CoS mark 5
Audio is at 8344
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.99.254:5065:
INVITE sip:mio_cellulare@192.168.99.254:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK3915ae6d;rport
Max-Forwards: 70
From: "andrea" <sip:**05@192.168.99.254>;tag=as5b2e8a44
To: <sip:mio_cellulare@192.168.99.254:5065>
Contact: <sip:**05@192.168.99.1:5060>
Call-ID: 4fff549724f6f37737e63c580af1905b@192.168.99.254
CSeq: 102 INVITE
User-Agent: PBX
Date: Mon, 15 Jun 2015 13:05:48 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 273

v=0
o=root 802688309 802688309 IN IP4 192.168.99.1
s=Asterisk PBX 1.8.13.1~dfsg1-3+deb7u3
c=IN IP4 192.168.99.1
t=0 0
m=audio 8344 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

---
-- Called SIP/mio_cellulare@peer-39numero_fisso_su_ISP_sip_ISP_local

<--- Transmitting (NAT) to 192.168.99.3:5065 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.99.3:5065;branch=z9hG4bK.lOSEQEZEi;received=192.168.99.3;rport=5065
From: <sip:559582@192.168.99.1>;tag=waqn7iU6k
To: sip:mio_cellulare@192.168.99.1;tag=as138e8fcf
Call-ID: RVskoXw1Om
CSeq: 21 INVITE
Server: PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: <sip:mio_cellulare@192.168.99.1:5060>
Content-Length: 0


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

<--- SIP read from UDP:192.168.99.254:5065 --->
SIP/2.0 100 Trying
From: "andrea"<sip:**05@192.168.99.254;user=phone>;tag=as5b2e8a44
To: <sip:mio_cellulare@192.168.99.254:5065;user=phone>
Call-ID: 4fff549724f6f37737e63c580af1905b@192.168.99.254
CSeq: 102 INVITE
Via: SIP/2.0/UDP 192.168.99.1:5060;rport=5060;branch=z9hG4bK3915ae6d
Contact: <sip:mio_cellulare@192.168.99.254:5065;user=phone>
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---

<--- SIP read from UDP:192.168.99.254:5065 --->
SIP/2.0 407 Proxy Authentication Required
From: "andrea"<sip:**05@192.168.99.254;user=phone>;tag=as5b2e8a44
To: <sip:mio_cellulare@192.168.99.254:5065;user=phone>;tag=1baedb8-7f000001-13e2-50029-800f7-3a325dc0-800f7
Call-ID: 4fff549724f6f37737e63c580af1905b@192.168.99.254
CSeq: 102 INVITE
Proxy-Authenticate: Digest realm="modemISP.homenet.ISPitalia.it",nonce="557ee9ccc8089536604ea98c4f668974015593b3",algorithm=MD5,qop="auth"
Via: SIP/2.0/UDP 192.168.99.1:5060;rport=5060;branch=z9hG4bK3915ae6d
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---
set_destination: Parsing <sip:mio_cellulare@192.168.99.254:5065> for address/port to send to
set_destination: set destination to 192.168.99.254:5065
Transmitting (NAT) to 192.168.99.254:5065:
ACK sip:mio_cellulare@192.168.99.254:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK3915ae6d;rport
Max-Forwards: 70
From: "andrea" <sip:**05@192.168.99.254>;tag=as5b2e8a44
To: <sip:mio_cellulare@192.168.99.254:5065>;tag=1baedb8-7f000001-13e2-50029-800f7-3a325dc0-800f7
Contact: <sip:**05@192.168.99.1:5060>
Call-ID: 4fff549724f6f37737e63c580af1905b@192.168.99.254
CSeq: 102 ACK
User-Agent: PBX
Content-Length: 0


---
Audio is at 8344
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.99.254:5065:
INVITE sip:mio_cellulare@192.168.99.254:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK521e6c1a;rport
Max-Forwards: 70
From: "andrea" <sip:**05@192.168.99.254>;tag=as5b2e8a44
To: <sip:mio_cellulare@192.168.99.254:5065>
Contact: <sip:**05@192.168.99.1:5060>
Call-ID: 4fff549724f6f37737e63c580af1905b@192.168.99.254
CSeq: 103 INVITE
User-Agent: PBX
Proxy-Authorization: Digest username="**05", realm="modemISP.homenet.ISPitalia.it", algorithm=MD5, uri="sip:mio_cellulare@192.168.99.254:5065", nonce="557ee9ccc8089536604ea98c4f668974015593b3", response="46ea2105d3f94a7fdbd0553d7a297159", qop=auth, cnonce="120298e1", nc=00000001
Date: Mon, 15 Jun 2015 13:05:48 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 273

v=0
o=root 802688309 802688310 IN IP4 192.168.99.1
s=Asterisk PBX 1.8.13.1~dfsg1-3+deb7u3
c=IN IP4 192.168.99.1
t=0 0
m=audio 8344 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

And this is without linphone, as you can see in the response from 192.168.99.254 (the ISP router) there isn’t the realm string:

[code]<------------>
– Executing [mio_cellulare@context-user-559582:1] Dial(“SIP/559582-00000002”, “SIP/mio_cellulare@peer-39numero_fisso_su_ISP_sip_ISP_local,60,r”) in new stack
== Using SIP RTP CoS mark 5
Audio is at 8230
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.99.254:5065:
INVITE sip:mio_cellulare@192.168.99.254:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK41253612;rport
Max-Forwards: 70
From: “andrea” sip:**05@192.168.99.254;tag=as0a4c9a78
To: sip:mio_cellulare@192.168.99.254:5065
Contact: sip:**05@192.168.99.1:5060
Call-ID: 39b8d3571a860dbf48d71aeb22673bd7@192.168.99.254
CSeq: 102 INVITE
User-Agent: PBX
Date: Mon, 15 Jun 2015 16:16:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 273

v=0
o=root 407789844 407789844 IN IP4 192.168.99.1
s=Asterisk PBX 1.8.13.1~dfsg1-3+deb7u3
c=IN IP4 192.168.99.1
t=0 0
m=audio 8230 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv


– Called SIP/mio_cellulare@peer-39numero_fisso_su_ISP_sip_ISP_local

<— Transmitting (NAT) to 192.168.99.3:5065 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.99.3:5065;branch=z9hG4bK.G~AQsvgDz;received=192.168.99.3;rport=5065
From: sip:559582@192.168.99.1;tag=fjmDY14yn
To: sip:mio_cellulare@192.168.99.1;tag=as12901ce2
Call-ID: D5s6NAw8B6
CSeq: 21 INVITE
Server: PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: sip:mio_cellulare@192.168.99.1:5060
Content-Length: 0

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

<— SIP read from UDP:192.168.99.254:5065 —>
SIP/2.0 100 Trying
From: "andrea"sip:**05@192.168.99.254;user=phone;tag=as0a4c9a78
To: sip:mio_cellulare@192.168.99.254:5065;user=phone
Call-ID: 39b8d3571a860dbf48d71aeb22673bd7@192.168.99.254
CSeq: 102 INVITE
Via: SIP/2.0/UDP 192.168.99.1:5060;rport=5060;branch=z9hG4bK41253612
Contact: sip:mio_cellulare@192.168.99.254:5065;user=phone
Content-Length: 0

<------------->
— (8 headers 0 lines) —

<— SIP read from UDP:192.168.99.254:5065 —>
SIP/2.0 403 Forbidden
From: "andrea"sip:**05@192.168.99.254;user=phone;tag=as0a4c9a78
To: sip:mio_cellulare@192.168.99.254:5065;user=phone;tag=1ba8c38-7f000001-13e2-50029-82dbe-6fd38c99-82dbe
Call-ID: 39b8d3571a860dbf48d71aeb22673bd7@192.168.99.254
CSeq: 102 INVITE
Via: SIP/2.0/UDP 192.168.99.1:5060;rport=5060;branch=z9hG4bK41253612
Content-Length: 0

<------------->
— (7 headers 0 lines) —
set_destination: Parsing sip:mio_cellulare@192.168.99.254:5065 for address/port to send to
set_destination: set destination to 192.168.99.254:5065
Transmitting (NAT) to 192.168.99.254:5065:
ACK sip:mio_cellulare@192.168.99.254:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK41253612;rport
Max-Forwards: 70
From: “andrea” sip:**05@192.168.99.254;tag=as0a4c9a78
To: sip:mio_cellulare@192.168.99.254:5065;tag=1ba8c38-7f000001-13e2-50029-82dbe-6fd38c99-82dbe
Contact: sip:**05@192.168.99.1:5060
Call-ID: 39b8d3571a860dbf48d71aeb22673bd7@192.168.99.254
CSeq: 102 ACK
User-Agent: PBX
Content-Length: 0


[Jun 15 18:16:50] WARNING[9190]: chan_sip.c:20366 handle_response_invite: Received response: “Forbidden” from '“andrea” sip:**05@192.168.99.254;tag=as0a4c9a78’
Scheduling destruction of SIP dialog ‘39b8d3571a860dbf48d71aeb22673bd7@192.168.99.254’ in 6400 ms (Method: INVITE)
== Everyone is busy/congested at this time (1:0/1/0)
– Auto fallthrough, channel ‘SIP/559582-00000002’ status is ‘CONGESTION’[/code]

and this is what i get if I try to register to 192.168.99.254 (i also wan’t receive calls from this router).
As you can see seems that i cannot login to the proxy, the realm string appear this time. Keep in mind that i can do that with the simple linphone software!

[quote]— (8 headers 0 lines) —
Responding to challenge, registration to domain/host name 192.168.99.254
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to 192.168.99.254:5065:
REGISTER sip:192.168.99.254 SIP/2.0
Via: SIP/2.0/UDP 192.168.99.1:5060;branch=z9hG4bK6e90bc51;rport
Max-Forwards: 70
From: sip:**05@192.168.99.254;tag=as764a5ffa
To: sip:**05@192.168.99.254
Call-ID: 0ee6580a4c6de48e476eefd53e83be40@127.0.1.1
CSeq: 177 REGISTER
User-Agent: PBX
Authorization: Digest username="**05", realm=“modemISP.homenet.ISPitalia.it”, algorithm=MD5, uri=“sip:192.168.99.254”, nonce=“557f39e14594bf81f62ccf73e7fef7be8d54a045”, response=“a95fd6506f881d9e66c72b4ec346a685”, qop=auth, cnonce=“3399ee59”, nc=00000001
Expires: 300
Contact: sip:**05@192.168.99.1:5060
Content-Length: 0


<— SIP read from UDP:192.168.99.254:5065 —>
SIP/2.0 401 Unauthorized
From: sip:**05@192.168.99.254;user=phone;tag=as764a5ffa
To: sip:**05@192.168.99.254;user=phone;tag=1ba9fb8-7f000001-13e2-50029-8510d-4038f39a-8510d
Call-ID: 0ee6580a4c6de48e476eefd53e83be40@127.0.1.1
CSeq: 177 REGISTER
WWW-Authenticate: Digest realm=“modemISP.homenet.ISPitalia.it”,nonce=“557f39e1a3f63c02bb4b24d995ae2c3da2d71938”,algorithm=MD5,qop="auth"
Via: SIP/2.0/UDP 192.168.99.1:5060;rport=5060;branch=z9hG4bK6e90bc51
Content-Length: 0

<------------->
— (8 headers 0 lines) —
[Jun 15 20:47:29] NOTICE[31077]: chan_sip.c:20715 handle_response_register: Failed to authenticate on REGISTER to ‘**05@192.168.99.254’ (Tries 3)
Really destroying SIP dialog ‘0ee6580a4c6de48e476eefd53e83be40@127.0.1.1’ Method: REGISTER[/quote]

Thanks in advance for helping!

fixed this problem by updating to the latest version, sorry!