FreePBX PJSIP RTP Issues with NAT endpoints

Hello,

I am currently running:
PBX Firmware: 10.13.66-12
Asterisk 13.9.1

I have the PBX in a data center behind NAT. I have a soft phone in my house behind NAT as well.
The extensions registers appropriately but RTP packets are being sent to the wrong IP . The same setup with the chan-sip driver works perfectly. Issue is only happening on pjsip
Here are the traces from the PBX:
<— Transmitting SIP response (948 bytes) to UDP:205.178.30.162:55060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.20.162:55060;rport=55060;received=205.178.30.162;branch=z9hG4bK-524287-1—f7a5271d80a5801a
Call-ID: 79961NjEwYjRiMGMzNGQwZjc4MmM1ZDAyMDA2OWQ1YzQ3NmY
From: “Levi Test” sip:[email protected];tag=be37784f
To: sip:*[email protected];tag=p0yUVCaw91gNVHxUBe.0Iu3RW5T51Q6Z
CSeq: 2 INVITE
Server: FPBX-13.0.131(13.9.1)
Contact: sip:74.119.152.5:55060
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
P-Asserted-Identity: “Dial Voicemail” sip:*[email protected]
Content-Type: application/sdp
Content-Length: 276

v=0
o=- 1023031690 3 IN IP4 172.20.50.25
s=Asterisk
c=IN IP4 172.20.50.25
t=0 0
m=audio 11166 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Received SIP request (442 bytes) from UDP:205.178.30.162:55060 —>
ACK sip:74.119.152.5:55060 SIP/2.0
Via: SIP/2.0/UDP 192.168.20.162:55060;branch=z9hG4bK-524287-1—04892311eee55c6f;rport
Max-Forwards: 70
Contact: sip:[email protected]:55060
To: sip:*[email protected];tag=p0yUVCaw91gNVHxUBe.0Iu3RW5T51Q6Z
From: “Levi Test” sip:[email protected];tag=be37784f
Call-ID: 79961NjEwYjRiMGMzNGQwZjc4MmM1ZDAyMDA2OWQ1YzQ3NmY
CSeq: 2 ACK
User-Agent: X-Lite release 4.9.3 stamp 79961
Content-Length: 0

Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004093, ts 000160, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004094, ts 000320, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004095, ts 000480, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004096, ts 000640, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004097, ts 000800, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004098, ts 000960, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004099, ts 001120, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004100, ts 001280, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004101, ts 001440, len 000160)
Sent RTP packet to 192.168.20.162:19428 (type 00, seq 004102, ts 001600, len 000160)

As you can see from this the packets are being set to the private IP of my Softphone on the remote network, instead of the public ip.
Researching online did not reveal much info
The following document describes a similar issues that got resolved by an Asterisk Update but I am already running on latest form FreePBX
http://asteriskfaqs.org/2016/03/02/asterisk-users/rtp-nat-question-pjsip.html

Here is my networking Set Up
PBX Local IP : 172.20.50.25
PBX Wan IP: 74.119.152.5

Sofphone Private : 192.168.20.162
Public DHCP from Comcast : 205.178.30.162 at time of test

Also

RTP Symmetric YES
Rewrite Contact YES
Force rport YES

Any help would be appreciated

This worked in an older version of Asterisk. It stopped working once updates where applied.

Please check Advanced Settings–>General SIP Settings and under NAT settings section, “External Address”.
and then run “Detect Network Settings”

It has been done and also checked and my pjsip.transoporst conf has this in it

[0.0.0.0-udp]
type=transport
protocol=udp
bind=0.0.0.0:55060
external_media_address=74.119.152.5
external_signaling_address=74.119.152.5
allow_reload=yes
local_net=172.20.50.0/24

Hello, this is an old topic but somehow it still exists as an issue. FreePBX 13 latest update. Were you able to find a work around?
Thanks

Amazing. I am seeing exactly the same issue here.

The FreePBX server is behind NAT and so are the remote handsets.
external_media and signalling addresses are set to the public IP on the NAT firewall, RTP Symmetric, Rewrite Contact and Force Rport are all set on the extensions but an RTP debug shows that RTP packets are being sent to the internal LAN IP of the remote handset, rather than the public IP.

This issue is only affecting PJSIP extensions - no problem with chan_sip

Does anyone have any ideas on a fix for this please?

Are you receiving audio from the remote extension? If not, confirm that in Asterisk SIP Settings, External Address and Local Networks are correctly set.

If audio is coming in, confirm that Symmetric RTP for the extension is set to Yes…

If no luck, turn on pjsip logger, paste the Asterisk log for a failing call at https://pastebin.freepbx.org and post the link here.

Thank you for your reply Stewart1.

I had a brainwave earlier this morning before seeing your reply. (You are definitely correct asking about “Local Networks” though).

A quick overview of the overall scenario again - hoping that this helps others in future:

This FreePBX server is behind NAT at a datacentre, it’s IP is “10.111.15.1/24”.
Phones connect to this system via two methods:

  1. “Locally” from a 192.168.0.0/16 network. (No NAT involved at all).
  2. Across the Internet, where the phones themselves are behind NAT routers. (So NAT at the FreePBX server and NAT at the endpoints)

The locally attached phones are in the 192.168.0.0/16 network, so my FreePBX configuration was simple - “Under SIP Settings” (The General SIP settings tab):
“192.168.0.0/255.255.255.0” under “Local Networks”
My server’s external address in “External Address”.

Really straight forward…BUT the local IP address on the FreePBX server itself is 10.111.15.1/24 so considering that no phones connect to it from the 10.111.15.0/24 network, I didn’t list it as a “local_net” - which interestingly enough turned out to be the cause of the problem for the PJSIP-based phones.

In summary, it seems that NAT detection and NAT features (chan_pjsip’s “rtp_symmetric”, “rewrite_contact” etc. endpoint parameters), seemed to be ignored for the Internet-based endpoints until I listed the FreePBX server’s own local network as a ‘local_net’ (despite no phones actually being present in that ‘local’ network).

As always - a super simple fix.

As a side note: In this instance, I should have trusted FreePBX’s “Detect Network Settings”, which actually listed “10.111.15.0/255.255.255.0” as a local network, but I had removed manually. :slight_smile:

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.