Asterisk send "BYE" but phone doesn't hangup

Hi,

I’m trying to set up a cisco phone that registers to asterisk from behind a nat. Calling is no problem in both directions (using symmetric RTP for nat), but if the call was started from the phone, when asterisk sends the ‘BYE’ message, the phone doesn’t hang up but responds “481 Call leg/transaction does not exist”.
Does anybody know what could be the reason?

below is the sip debug output for such a call:

[code]<— SIP read from 74.125.31.94:5060:UDP —>
INVITE sip:111@119.160.242.96:5060 SIP/2.0
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-9a9c2638
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 101 INVITE
Max-Forwards: 70
Contact: “User1” sip:108@74.125.31.94:5060
Expires: 240
User-Agent: Cisco/SPA504G-7.4.8a
Content-Length: 397
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, UPDATE
Supported: replaces
Content-Type: application/sdp

v=0
o=- 520190 520190 IN IP4 74.125.31.94
s=-
c=IN IP4 74.125.31.94
t=0 0
m=audio 16400 RTP/AVP 8 18 0 2 9 96 97 98 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729a/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:9 G722/8000
a=rtpmap:96 G726-40/8000
a=rtpmap:97 G726-24/8000
a=rtpmap:98 G726-16/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:30
a=sendrecv
<------------->
— (14 headers 18 lines) —
Sending to 74.125.31.94 : 5060 (no NAT)
Using INVITE request as basis request - 4db9a41d-d0f00504@74.125.31.94

<— Reliably Transmitting (NAT) to 74.125.31.94:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-9a9c2638;received=74.125.31.94
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96;tag=as3d562dca
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 101 INVITE
User-Agent: IP0x
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="3374f4f7"
Content-Length: 0

<— SIP read from 74.125.31.94:5060:UDP —>
ACK sip:111@119.160.242.96:5060 SIP/2.0
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-9a9c2638
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96;tag=as3d562dca
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 101 ACK
Max-Forwards: 70
Contact: “User1” sip:108@74.125.31.94:5060
User-Agent: Cisco/SPA504G-7.4.8a
Content-Length: 0

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

<— SIP read from 74.125.31.94:5060:UDP —>
INVITE sip:111@119.160.242.96:5060 SIP/2.0
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-618eb4ec
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 INVITE
Max-Forwards: 70
Proxy-Authorization: Digest username=“108”,realm=“asterisk”,nonce=“3374f4f7”,uri=“sip:111@119.160.242.96:5060”,algorithm=MD5,response="47f394ce017338e68bbdc201f70c9cd0"
Contact: “User1” sip:108@74.125.31.94:5060
Expires: 240
User-Agent: Cisco/SPA504G-7.4.8a
Content-Length: 397
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, UPDATE
Supported: replaces
Content-Type: application/sdp

v=0
o=- 520190 520190 IN IP4 74.125.31.94
s=-
c=IN IP4 74.125.31.94
t=0 0
m=audio 16400 RTP/AVP 8 18 0 2 9 96 97 98 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729a/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:9 G722/8000
a=rtpmap:96 G726-40/8000
a=rtpmap:97 G726-24/8000
a=rtpmap:98 G726-16/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:30
a=sendrecv

<— Transmitting (NAT) to 74.125.31.94:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-618eb4ec;received=74.125.31.94
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 INVITE
User-Agent: IP0x
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:111@119.160.242.96:5060
Content-Length: 0

<— Transmitting (NAT) to 74.125.31.94:5060 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-618eb4ec;received=74.125.31.94
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96;tag=as754cbece
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 INVITE
User-Agent: IP0x
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:111@119.160.242.96:5060
Content-Length: 0

<— Reliably Transmitting (NAT) to 74.125.31.94:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-618eb4ec;received=74.125.31.94
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96;tag=as754cbece
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 INVITE
User-Agent: IP0x
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:111@119.160.242.96:5060
Content-Type: application/sdp
Content-Length: 287

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

<— SIP read from 74.125.31.94:5060:UDP —>
ACK sip:111@119.160.242.96:5060 SIP/2.0
Via: SIP/2.0/UDP 74.125.31.94:5060;branch=z9hG4bK-785e1467
From: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
To: “User2” sip:111@119.160.242.96;tag=as754cbece
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 ACK
Max-Forwards: 70
Proxy-Authorization: Digest username=“108”,realm=“asterisk”,nonce=“3374f4f7”,uri=“sip:111@119.160.242.96:5060”,algorithm=MD5,response="98d694ce017337d78bbdc201f70c9cd0"
Contact: “User1” sip:108@74.125.31.94:5060
User-Agent: Cisco/SPA504G-7.4.8a
Content-Length: 0

<------------->
— (10 headers 0 lines) —
set_destination: Parsing sip:108@74.125.31.94:5060 for address/port to send to
set_destination: set destination to 74.125.31.94, port 5060
Reliably Transmitting (NAT) to 74.125.31.94:5060:
BYE sip:108@74.125.31.94:5060 SIP/2.0
Via: SIP/2.0/UDP 119.160.242.96:5060;branch=z9hG4bK6f521db2;rport
From: “User2” sip:111@119.160.242.96;tag=as754cbece
To: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 BYE
User-Agent: IP0x
Max-Forwards: 70
Content-Length: 0

<— SIP read from 74.125.31.94:5060:UDP —>
SIP/2.0 481 Call Leg/Transaction Does Not Exist
To: “User1” sip:108@119.160.242.96;tag=6003414918e929c8o0
From: “User2” sip:111@119.160.242.96;tag=as754cbece
Call-ID: 4db9a41d-d0f00504@74.125.31.94
CSeq: 102 BYE
Via: SIP/2.0/UDP 119.160.242.96:5060;branch=z9hG4bK6f521db2
Server: Cisco/SPA504G-7.4.8a
Content-Length: 0
[/code]

The call leg is being correctly and consistently applied, in that trace.

You need to look at the routers to see if they are trying to be clever.

Note that the early Cisco firmware doesn’t support NAT.

Thank You!! :smiley:
Should have asked earlier, it would have saved me some hours of frustration…

Like you said the router tried to be “clever” although I thought I had turned such functions of already…

Switching ports on the phone away from the standard 5060 solved all problems (blf also didn’t work properly).