Authentication problem

Hello,

I have two peers registered in my asterisk server. They are in different context. I have a cisco mediagateway too. sip.conf looks like that:

[9960]
host=dynamic
type=friend
context=test1
t38pt_udptl = yes
dtmfmode=auto
username=9960
secret=pass1
canreinvite=yes
disallow=all
allow=g729,alaw

[9961]
host=dynamic
type=friend
context=test2
t38pt_udptl = yes
dtmfmode=auto
username=9961
secret=pass2
disallow=all
allow=g729,alaw
qualify=yes
canreinvite=yes

[cisco]
host=192.168.119.225
disallow=all
insecure=port,invite
type=friend
context=remote
t38pt_udptl = yes ; Default false
reinvite=yes
dtmf=auto
allow=g729
allow=alaw
qualify=yes

My extensions.conf:

[remote]
exten => _996X,1,Dial(SIP/${EXTEN},60,rt)

[test-99]
exten => _996X,1,Dial(SIP/${EXTEN},60,Tr)

[test1]
exten => _0X.,1, Dial(SIP/194.181.119.225/${EXTEN},60)
include => test-99

[test2]
exten => _0X.,1, Dial(SIP/194.181.119.225/${EXTEN},60)
include => test-99

Problem is: Peer1 can’t to reach Peer2.

obelix*CLI> exit
obelix:/data/asterisk-1.4.4# asterisk -r
Asterisk 1.4.4, Copyright © 1999 - 2006 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 1.4.4 currently running on obelix (pid = 7969)
– Remote UNIX connection
Verbosity is at least 3
obelix*CLI>

<------------->
obelix*CLI>
<— SIP read from 192.168.165.10:5060 —>
INVITE sip:09961@192.168.119.251:5060;user=phone SIP/2.0
Allow:INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,REFER
Via:SIP/2.0/UDP 192.168.165.10:5060;rport;branch=z9hG4bK144ead080e30ab08
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone
Call-ID:EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq:67 INVITE
Contact:sip:9960@192.168.165.10:5060
Expires:90
Max-Forwards:70
Supported:replaces
User-Agent:137 12-37-3612753
Content-Type:application/sdp
Content-Length:239

v=0
o=9960 1798967630 1798967630 IN IP4 192.168.165.10
s=Session SDP
c=IN IP4 192.168.165.10
t=0 0
m=audio 9000 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=rtpmap:101 telephone-event/8000/1
a=fmtp:101 0-15

<------------->
— (14 headers 10 lines) —
Sending to 192.168.165.10 : 5060 (NAT)
Using INVITE request as basis request - EA1A-B61B-466917725344294FA62F-035@SipHost

<— Reliably Transmitting (no NAT) to 192.168.165.10:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.165.10:5060;branch=z9hG4bK144ead080e30ab08;received=192.168.165.10;rport=5060
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone;tag=as4a95f4a8
Call-ID: EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq: 67 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="2333700f"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘EA1A-B61B-466917725344294FA62F-035@SipHost’ in 32000 ms (Method: INVITE)
Found user '9960’
obelix*CLI>
<— SIP read from 192.168.165.10:5060 —>
ACK sip:09961@192.168.119.251:5060;user=phone SIP/2.0
Via:SIP/2.0/UDP 192.168.165.10:5060;rport;branch=z9hG4bK144ead080e30ab08
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone;tag=as4a95f4a8
Call-ID:EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq:67 ACK
Max-Forwards:70
Content-Length:0

<------------->
— (8 headers 0 lines) —
obelix*CLI>
<— SIP read from 192.168.165.10:5060 —>
INVITE sip:09961@192.168.119.251:5060;user=phone SIP/2.0
Allow:INVITE,ACK,OPTIONS,BYE,CANCEL,INFO,PRACK,REFER
Via:SIP/2.0/UDP 192.168.165.10:5060;rport;branch=z9hG4bK6641fec6f67f2ca3
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone
Call-ID:EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq:68 INVITE
Contact:sip:9960@192.168.165.10:5060
Expires:90
Max-Forwards:70
Proxy-Authorization:Digest username=“9960”,realm=“asterisk”,nonce=“2333700f”,uri=“sip:09961@192.168.119.251:5060;user=phone”,response=“8b9223459a126c1cdd5dc840eebdf377”,algorithm=MD5
Supported:replaces
User-Agent:137 12-37-3612753
Content-Type:application/sdp
Content-Length:239

v=0
o=9960 1798967630 1798967630 IN IP4 192.168.165.10
s=Session SDP
c=IN IP4 192.168.165.10
t=0 0
m=audio 9000 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=rtpmap:101 telephone-event/8000/1
a=fmtp:101 0-15

<------------->
— (15 headers 10 lines) —
Sending to 192.168.165.10 : 5060 (NAT)
Using INVITE request as basis request - EA1A-B61B-466917725344294FA62F-035@SipHost
Found user '9960’
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 101
[Jun 24 11:18:09] DEBUG[8004]: chan_sip.c:4903 process_sdp: Peer doesn’t provide T.38 UDPTL
Peer audio RTP is at port 192.168.165.10:9000
Found description format PCMA for ID 8
Found description format G729 for ID 18
Found description format telephone-event for ID 101
Capabilities: us - 0x108 (alaw|g729), peer - audio=0x108 (alaw|g729)/video=0x0 (nothing), combined - 0x108 (alaw|g729)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Peer audio RTP is at port 192.168.165.10:9000
Looking for 09961 in test1 (domain 192.168.119.251)
list_route: hop: sip:9960@192.168.165.10:5060

<— Transmitting (no NAT) to 192.168.165.10:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.165.10:5060;branch=z9hG4bK6641fec6f67f2ca3;received=192.168.165.10;rport=5060
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone
Call-ID: EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq: 68 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:09961@192.168.119.251
Content-Length: 0

<------------>
– Executing [09961@test1:1] Dial(“SIP/9960-081e88f8”, “SIP/192.168.119.225/09961|60”) in new stack
Audio is at 192.168.119.251 port 17848
Adding codec 0x100 (g729) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 192.168.119.225:5060:
INVITE sip:09961@192.168.119.225 SIP/2.0
Via: SIP/2.0/UDP 192.168.119.251:5060;branch=z9hG4bK46c0e869;rport
From: “9960” sip:9960@192.168.119.251;tag=as3f11331c
To: sip:09961@192.168.119.225
Contact: sip:9960@192.168.119.251
Call-ID: 5c02557c0e9fd03a7b60975352153aa4@192.168.119.251
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 70
Date: Tue, 24 Jun 2008 09:18:09 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Type: application/sdp
Content-Length: 264

v=0
o=root 7969 7969 IN IP4 192.168.119.251
s=session
c=IN IP4 192.168.119.251
t=0 0
m=audio 17848 RTP/AVP 18 8 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv


-- Called 192.168.119.225/09961

obelix*CLI>
<— SIP read from 192.168.119.225:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.119.251:5060;branch=z9hG4bK46c0e869;rport
From: “9960” sip:9960@192.168.119.251;tag=as3f11331c
To: sip:09961@192.168.119.225;tag=FFA1A5E4-196C
Date: Tue, 24 Jun 2008 09:19:20 GMT
Call-ID: 5c02557c0e9fd03a7b60975352153aa4@192.168.119.251
Server: Cisco-SIPGateway/IOS-12.x
CSeq: 102 INVITE
Allow-Events: telephone-event
Content-Length: 0

<------------->
— (10 headers 0 lines) —
obelix*CLI>
<— SIP read from 192.168.119.225:55275 —>
INVITE sip:9961@192.168.119.251:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.119.225:5060;branch=z9hG4bKBDB94677
Remote-Party-ID: “xxxxx” sip:9960@192.168.119.225;party=calling;screen=yes;privacy=off
From: “xxxxx” sip:9960@192.168.119.225;tag=FFA1A6CC-19C4
To: sip:9961@192.168.119.251
Date: Tue, 24 Jun 2008 09:19:20 GMT
Call-ID: 7619C664-410511DD-810F9444-EDFCF770@192.168.119.225
Supported: 100rel,timer,resource-priority,replaces
Min-SE: 1800
Cisco-Guid: 1981320572-1090851293-3040280589-3989561264
User-Agent: Cisco-SIPGateway/IOS-12.x
Accept-Language: pl
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER
CSeq: 101 INVITE
Max-Forwards: 70
Timestamp: 1214299160
Contact: sip:9960@192.168.119.225:5060
Expires: 180
Allow-Events: telephone-event
Content-Type: application/sdp
Content-Disposition: session;handling=required
Content-Length: 291

v=0
o=CiscoSystemsSIP-GW-UserAgent 4961 9190 IN IP4 192.168.119.225
s=SIP Call
c=IN IP4 192.168.119.225
t=0 0
m=audio 19244 RTP/AVP 18 8 101
c=IN IP4 192.168.119.225
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

<------------->
— (22 headers 12 lines) —
Sending to 192.168.119.225 : 5060 (no NAT)
Using INVITE request as basis request - 7619C664-410511DD-810F9444-EDFCF770@192.168.119.225
obelix*CLI>
<— Reliably Transmitting (no NAT) to 192.168.119.225:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.119.225:5060;branch=z9hG4bKBDB94677;received=192.168.119.225
From: “xxxxx” sip:9960@192.168.119.225;tag=FFA1A6CC-19C4
To: sip:9961@192.168.119.251;tag=as53d71013
Call-ID: 7619C664-410511DD-810F9444-EDFCF770@192.168.119.225
CSeq: 101 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="7459ea43"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘7619C664-410511DD-810F9444-EDFCF770@192.168.119.225’ in 32000 ms (Method: INVITE)
Found user '9960’
obelix*CLI>
<— SIP read from 192.168.119.225:5060 —>
ACK sip:9961@192.168.119.251:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.119.225:5060;branch=z9hG4bKBDB94677
From: “xxxxx” sip:9960@192.168.119.225;tag=FFA1A6CC-19C4
To: sip:9961@192.168.119.251;tag=as53d71013
Date: Tue, 24 Jun 2008 09:19:20 GMT
Call-ID: 7619C664-410511DD-810F9444-EDFCF770@192.168.119.225
Max-Forwards: 70
CSeq: 101 ACK
Allow-Events: telephone-event
Content-Length: 0

<------------->
— (10 headers 0 lines) —
obelix*CLI>
<— SIP read from 192.168.119.225:5060 —>
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 192.168.119.251:5060;branch=z9hG4bK46c0e869;rport
From: “9960” sip:9960@192.168.119.251;tag=as3f11331c
To: sip:09961@192.168.119.225;tag=FFA1A5E4-196C
Date: Tue, 24 Jun 2008 09:19:20 GMT
Call-ID: 5c02557c0e9fd03a7b60975352153aa4@192.168.119.251
Server: Cisco-SIPGateway/IOS-12.x
CSeq: 102 INVITE
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER
Allow-Events: telephone-event
Contact: sip:09961@192.168.119.225:5060
Content-Type: application/sdp
Content-Disposition: session;handling=required
Content-Length: 279

v=0
o=CiscoSystemsSIP-GW-UserAgent 9583 1563 IN IP4 192.168.119.225
s=SIP Call
c=IN IP4 192.168.119.225
t=0 0
m=audio 17004 RTP/AVP 18 101
c=IN IP4 192.168.119.225
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20

<------------->
— (14 headers 12 lines) —
Found RTP audio format 18
Found RTP audio format 101
[Jun 24 11:18:09] DEBUG[8004]: chan_sip.c:4903 process_sdp: Peer doesn’t provide T.38 UDPTL
Peer audio RTP is at port 192.168.119.225:17004
Found description format G729 for ID 18
Found description format telephone-event for ID 101
Capabilities: us - 0x108 (alaw|g729), peer - audio=0x100 (g729)/video=0x0 (nothing), combined - 0x100 (g729)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Peer audio RTP is at port 192.168.119.225:17004
– Call on SIP/192.168.119.225-0821ed08 left from hold
– SIP/192.168.119.225-0821ed08 is making progress passing it to SIP/9960-081e88f8
Audio is at 192.168.119.251 port 13524
Adding codec 0x100 (g729) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
obelix*CLI>
<— Transmitting (no NAT) to 192.168.165.10:5060 —>
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 192.168.165.10:5060;branch=z9hG4bK6641fec6f67f2ca3;received=192.168.165.10;rport=5060
From: “9960” sip:9960@192.168.119.251;tag=4621d0a5-691772
To: sip:09961@192.168.119.251:5060;user=phone;tag=as25919f62
Call-ID: EA1A-B61B-466917725344294FA62F-035@SipHost
CSeq: 68 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:09961@192.168.119.251
Content-Type: application/sdp
Content-Length: 264

v=0
o=root 7969 7969 IN IP4 192.168.119.251
s=session
c=IN IP4 192.168.119.251
t=0 0
m=audio 13524 RTP/AVP 18 8 101
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

<------------>
Really destroying SIP dialog ‘65A5A3C1-410511DD-80F09444-EDFCF770@192.168.119.225’ Method: ACK
obelix*CLI> exit
obelix:/data/asterisk-1.4.4#

I hear information: There is no such number. I suppose that problem is second Proxy Authentication Required message. Normally cisco gateway doesn’t make authentication. Unfortunetly connection must be routed via cisco gateway. How to resolve this problem?