RTP sent to the private IP although nat=yes

Until recently i had Asterisk 1.4.0; For a few Polycom remote phones working behind nats simply having

nat=yes
qualify=2000

in the phone’s defintion in sip.conf allowed the phones to properly make and receive calls. (The asterisk server isn’t natted).

My ITSP dropped support for IAX. After moving to SIP an issue with DTMF digits received via SIP from my ITSP forced me to upgrade * to 1.4.17.

Now my Polycom remote users behind nat don’t have audio.

The issue can be isolated to the fact that in this release the RTP from * is going to the [private] address in the SDP instead of using the public IP from layer3.

I have seen some discussion about similar problems, only those were for cases when both the * and the Polycom are behind NATs. Which isn’t true here.
A patch was created to address that but that solution isn’t convenient for my case.

I am wondering if there is a way to force the behavior back to what it had been in 1.4.0 to simply send the RTP to the public IP just like SIP does (yes, i know that breaks the RFC…).

See trace, SIP succeeds setting the call up but * sends the RTP to the private IP :frowning:.

Thanks for reading.

<— SIP read from 68.195.24.102:5060 —>
INVITE sip:589@gudinici:5060;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK650970deDEE0AEA7
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone
CSeq: 1 INVITE
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Contact: sip:526@192.168.3.254
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER
User-Agent: PolycomSoundPointIP-SPIP_550-UA/2.1.2.0078
Supported: 100rel,replaces
Allow-Events: talk,hold,conference
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: 275

v=0
o=- 1238445677 1238445677 IN IP4 192.168.3.254
s=Polycom IP Phone
c=IN IP4 192.168.3.254
t=0 0
m=audio 2258 RTP/AVP 9 0 8 18 101
a=sendrecv
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=rtpmap:101 telephone-event/8000

<------------->
— (14 headers 12 lines) —
Using INVITE request as basis request - 4b80d974-8ce1e0d5-cfad709a@192.168.3.254

<— Reliably Transmitting (NAT) to 68.195.24.102:5060 —>
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK650970deDEE0AEA7;received=68.195.24.102
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as47556c12
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
CSeq: 1 INVITE
User-Agent: myAsterisk
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="5e76956f"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘4b80d974-8ce1e0d5-cfad709a@192.168.3.254’ in 32000 ms (Method: INVITE)
Found user '526’
ua900*CLI>
<— SIP read from 68.195.24.102:5060 —>
ACK sip:589@gudinici:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK650970deDEE0AEA7
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as47556c12
CSeq: 1 ACK
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Contact: sip:526@192.168.3.254
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER
User-Agent: PolycomSoundPointIP-SPIP_550-UA/2.1.2.0078
Max-Forwards: 70
Content-Length: 0

<------------->
— (11 headers 0 lines) —
ua900*CLI>
<— SIP read from 68.195.24.102:5060 —>
INVITE sip:589@gudinici:5060;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK199d9921FD6B5496
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone
CSeq: 2 INVITE
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Contact: sip:526@192.168.3.254
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER
User-Agent: PolycomSoundPointIP-SPIP_550-UA/2.1.2.0078
Supported: 100rel,replaces
Allow-Events: talk,hold,conference
Proxy-Authorization: Digest username=“526”, realm=“asterisk”, nonce=“5e76956f”, uri=“sip:589@gudinici:5060;user=phone”, response=“ec56c6ee6c4d75c324fed2908189fde7”, algorithm=MD5
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: 275

v=0
o=- 1238445677 1238445677 IN IP4 192.168.3.254
s=Polycom IP Phone
c=IN IP4 192.168.3.254
t=0 0
m=audio 2258 RTP/AVP 9 0 8 18 101
a=sendrecv
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=rtpmap:101 telephone-event/8000

<------------->
— (15 headers 12 lines) —
Sending to 68.195.24.102 : 5060 (NAT)
Using INVITE request as basis request - 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Found user '526’
Found RTP audio format 9
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 101
Peer audio RTP is at port 192.168.3.254:2258
Found audio description format G722 for ID 9
Found audio description format PCMU for ID 0
Found audio description format PCMA for ID 8
Found audio description format G729 for ID 18
Found audio description format telephone-event for ID 101
Capabilities: us - 0x8000e (gsm|ulaw|alaw|h263), peer - audio=0x110c (ulaw|alaw|g729|g722)/video=0x0 (nothing), combined - 0xc (ulaw|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Peer audio RTP is at port 192.168.3.254:2258
Looking for 589 in intern (domain gudinici)
list_route: hop: sip:526@192.168.3.254

<— Transmitting (NAT) to 68.195.24.102:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK199d9921FD6B5496;received=68.195.24.102
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
CSeq: 2 INVITE
User-Agent: myAsterisk
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:589@69.141.186.33:5060
Content-Length: 0

<------------>
– Executing [589@intern:1] Answer(“SIP/526-0820ed88”, “”) in new stack
Audio is at 69.141.186.33 port 19964
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<— Reliably Transmitting (NAT) to 68.195.24.102:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK199d9921FD6B5496;received=68.195.24.102
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as175ed88c
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
CSeq: 2 INVITE
User-Agent: myAsterisk
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:589@69.141.186.33:5060
Content-Type: application/sdp
Content-Length: 264

v=0
o=root 3678 3678 IN IP4 69.141.186.33
s=session
c=IN IP4 69.141.186.33
t=0 0
m=audio 19964 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=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

<------------>
– Executing [589@intern:2] Playback(“SIP/526-0820ed88”, “/var/lib/asterisk/music/pianoConcertoK467Andante”) in new stack
Sent RTP packet to 192.168.3.254:2258 (type 00, seq 057438, ts 000160, len 000160)
– <SIP/526-0820ed88> Playing ‘/var/lib/asterisk/music/pianoConcertoK467Andante’ (language ‘en’)
Sent RTP packet to 192.168.3.254:2258 (type 00, seq 057439, ts 000320, len 000160)
Sent RTP packet to 192.168.3.254:2258 (type 00, seq 057440, ts 000480, len 000160)
ua900*CLI>
<— SIP read from 68.195.24.102:5060 —>
ACK sip:589@69.141.186.33:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK9606d8d23CEA23EB
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as175ed88c
CSeq: 2 ACK
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Contact: sip:526@192.168.3.254
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER
User-Agent: PolycomSoundPointIP-SPIP_550-UA/2.1.2.0078
Proxy-Authorization: Digest username=“526”, realm=“asterisk”, nonce=“5e76956f”, uri=“sip:589@gudinici:5060;user=phone”, response=“ec56c6ee6c4d75c324fed2908189fde7”, algorithm=MD5
Max-Forwards: 70
Content-Length: 0

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

:exclamation:
[color=red]Sent RTP packet to 192.168.3.254:2258 (type 00, seq 057441, ts 000640, len 000160)
Sent RTP packet to 192.168.3.254:2258 (type 00, seq 057442, ts 000800, len 000160)[/color]

ua900*CLI>
<— SIP read from 68.195.24.102:5060 —>
BYE sip:589@69.141.186.33:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK921917485C59E779
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as175ed88c
CSeq: 3 BYE
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
Contact: sip:526@192.168.3.254
User-Agent: PolycomSoundPointIP-SPIP_550-UA/2.1.2.0078
Proxy-Authorization: Digest username=“526”, realm=“asterisk”, nonce=“5e76956f”, uri=“sip:589@gudinici:5060;user=phone”, response=“cecf50c28f02b84c81146e9b949af130”, algorithm=MD5
Max-Forwards: 70
Content-Length: 0

<------------->
— (11 headers 0 lines) —
Sending to 68.195.24.102 : 5060 (NAT)
ua900*CLI>
<— Transmitting (NAT) to 68.195.24.102:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.3.254;branch=z9hG4bK921917485C59E779;received=68.195.24.102
From: “Direct-ua900” sip:526@gudinici;tag=C1A019D3-D298FFD0
To: sip:589@gudinici;user=phone;tag=as175ed88c
Call-ID: 4b80d974-8ce1e0d5-cfad709a@192.168.3.254
CSeq: 3 BYE
User-Agent: myAsterisk
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: sip:589@69.141.186.33:5060
Content-Length: 0

<------------>
== Spawn extension (intern, 589, 2) exited non-zero on 'SIP/526-0820ed88’
Really destroying SIP dialog ‘4b80d974-8ce1e0d5-cfad709a@192.168.3.254’ Method: BYE
RTP-stats

  • Our Receiver:
    SSRC:LI> 0
    Received packets: 0
    Lost packets: 0
    Jitter:> 0.0000
    Transit: 0.0000
    RR-count: 0
  • Our Sender:
    SSRC:LI> 858732822
    Sent packets: 95
    Lost packets: 0
    Jitter:> 0
    SR-count: 0
    RTT:CLI> 0.000000
    ua900*CLI>

You may have looked at this already, but just in case, try looking in your sip.conf file and see if you have the proper external IP settings so that the server can change the SIP headers appropriately. The entry should look something like this.

[general]
externip = 200.201.202.203
localnet=192.168.2.0/255.255.255.0
localnet=10.5.1.0/255.255.255.192

You can use something like www.dyndns.com if you have an IP address that changes from time to time.

My NAT problems were fixed doing this…

Thanks,
Perry