Issues with nat rtp port forward

Hello.
I have freepbx server with configured outbound trunk provider and one sip phone in local network.
All works just great.
Then i tried to set up one more phone through the internet, external phone connection looks like:

FREEPBX --> local router --> internet --> router --> phone
FREEPBX IP is 192.168.90.150
external phone IP is 192.168.0.77
both routers got static IP addresses and configured firewalls (and external trunk works, so i assume, that firewall configured right.

All connected and phone rings, but without any audio.
I enabled rtp debug to see, what’s the problem, and found this:

  -- SIP/1007-00000cff is ringing
-- Connected line update to SIP/1009-00000cfe prevented.
-- SIP/1007-00000cff answered SIP/1009-00000cfe
  == Extension Changed 1007[ext-local] new state InUse for Notify User 1007
-- Channel SIP/1007-00000cff joined 'simple_bridge' basic-bridge <b33e0616-b9d7-4ba6-81fc-424ec5232541>
-- Channel SIP/1009-00000cfe joined 'simple_bridge' basic-bridge <b33e0616-b9d7-4ba6-81fc-424ec5232541>
   > 0x7f414c2ddce0 -- Probation passed - setting RTP source address to [default gateway]:61488
[2018-03-27 12:13:10] DEBUG[11823][C-000003fa]: res_rtp_asterisk.c:4499 ast_rtp_read: RTP NAT: Got audio from other end. Now sending to address [default gateway]:61488
   > 0x7f414c2ddce0 -- Probation passed - setting RTP source address to [default gateway]:61488
[2018-03-27 12:13:12] DEBUG[11823][C-000003fa]: res_rtp_asterisk.c:4099 ast_rtcp_read: RTCP NAT: Got RTCP from other end. Now sending to address [default gateway]:51249
localhost*CLI> rtp set debug on
RTP Debugging Enabled
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018425, ts 1629124158, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034456, ts 1629124152, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018426, ts 1629124318, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034457, ts 1629124312, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018427, ts 1629124478, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034458, ts 1629124472, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018428, ts 1629124638, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034459, ts 1629124632, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018429, ts 1629124798, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034460, ts 1629124792, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018430, ts 1629124958, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034461, ts 1629124952, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018431, ts 1629125118, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034462, ts 1629125112, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018432, ts 1629125278, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034463, ts 1629125272, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018433, ts 1629125438, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034464, ts 1629125432, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018434, ts 1629125598, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034465, ts 1629125592, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018435, ts 1629125758, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034466, ts 1629125752, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018436, ts 1629125918, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034467, ts 1629125912, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018437, ts 1629126078, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034468, ts 1629126072, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018438, ts 1629126238, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034469, ts 1629126232, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018439, ts 1629126398, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034470, ts 1629126392, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018440, ts 1629126558, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034471, ts 1629126552, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018441, ts 1629126718, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034472, ts 1629126712, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018442, ts 1629126878, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034473, ts 1629126872, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018443, ts 1629127038, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034474, ts 1629127032, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018444, ts 1629127198, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034475, ts 1629127192, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018445, ts 1629127358, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034476, ts 1629127352, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018446, ts 1629127518, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034477, ts 1629127512, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018447, ts 1629127678, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034478, ts 1629127672, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018448, ts 1629127838, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034479, ts 1629127832, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018449, ts 1629127998, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034480, ts 1629127992, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018450, ts 1629128158, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034481, ts 1629128152, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018451, ts 1629128318, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034482, ts 1629128312, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018452, ts 1629128478, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034483, ts 1629128472, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018453, ts 1629128638, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034484, ts 1629128632, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018454, ts 1629128798, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034485, ts 1629128792, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018455, ts 1629128958, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034486, ts 1629128952, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018456, ts 1629129118, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034487, ts 1629129112, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018457, ts 1629129278, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034488, ts 1629129272, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018458, ts 1629129438, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034489, ts 1629129432, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018459, ts 1629129598, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034490, ts 1629129592, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018460, ts 1629129758, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034491, ts 1629129752, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018461, ts 1629129918, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034492, ts 1629129912, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018462, ts 1629130078, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034493, ts 1629130072, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018463, ts 1629130238, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034494, ts 1629130232, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018464, ts 1629130398, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034495, ts 1629130392, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018465, ts 1629130558, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034496, ts 1629130552, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018466, ts 1629130718, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034497, ts 1629130712, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018467, ts 1629130878, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034498, ts 1629130872, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018468, ts 1629131038, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034499, ts 1629131032, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018469, ts 1629131198, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034500, ts 1629131192, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018470, ts 1629131358, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034501, ts 1629131352, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018471, ts 1629131518, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034502, ts 1629131512, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018472, ts 1629131678, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034503, ts 1629131672, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018473, ts 1629131838, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034504, ts 1629131832, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018474, ts 1629131998, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034505, ts 1629131992, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018475, ts 1629132158, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034506, ts 1629132152, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018476, ts 1629132318, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034507, ts 1629132312, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018477, ts 1629132478, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034508, ts 1629132472, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018478, ts 1629132638, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034509, ts 1629132632, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018479, ts 1629132798, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034510, ts 1629132792, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018480, ts 1629132958, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034511, ts 1629132952, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018481, ts 1629133118, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034512, ts 1629133112, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018482, ts 1629133278, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034513, ts 1629133272, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018483, ts 1629133438, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034514, ts 1629133432, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018484, ts 1629133598, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034515, ts 1629133592, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018485, ts 1629133758, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034516, ts 1629133752, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018486, ts 1629133918, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034517, ts 1629133912, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018487, ts 1629134078, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034518, ts 1629134072, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018488, ts 1629134238, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034519, ts 1629134232, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018489, ts 1629134398, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034520, ts 1629134392, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018490, ts 1629134558, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034521, ts 1629134552, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018491, ts 1629134718, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034522, ts 1629134712, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018492, ts 1629134878, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034523, ts 1629134872, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018493, ts 1629135038, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034524, ts 1629135032, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018494, ts 1629135198, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034525, ts 1629135192, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018495, ts 1629135358, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034526, ts 1629135352, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018496, ts 1629135518, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034527, ts 1629135512, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018497, ts 1629135678, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034528, ts 1629135672, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018498, ts 1629135838, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034529, ts 1629135832, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018499, ts 1629135998, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034530, ts 1629135992, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018500, ts 1629136158, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034531, ts 1629136152, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018501, ts 1629136318, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034532, ts 1629136312, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018502, ts 1629136478, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034533, ts 1629136472, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018503, ts 1629136638, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034534, ts 1629136632, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018504, ts 1629136798, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034535, ts 1629136792, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018505, ts 1629136958, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034536, ts 1629136952, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018506, ts 1629137118, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034537, ts 1629137112, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018507, ts 1629137278, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034538, ts 1629137272, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018508, ts 1629137438, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034539, ts 1629137432, len 000160)
Got  RTP packet from    [default gateway]:61488 (type 08, seq 018509, ts 1629137598, len 000160)
Sent RTP packet to      192.168.0.77:4012 (type 08, seq 034540, ts 1629137592, len 000160)
-- Channel SIP/1007-00000cff left 'simple_bridge' basic-bridge <b33e0616-b9d7-4ba6-81fc-424ec5232541>
  == Extension Changed 1007[ext-local] new state Idle for Notify User 1007
-- Channel SIP/1009-00000cfe left 'simple_bridge' basic-bridge <b33e0616-b9d7-4ba6-81fc-424ec5232541>
  == Spawn extension (macro-dial-one, s, 48) exited non-zero on 'SIP/1009-00000cfe' in macro 'dial-one'
  == Spawn extension (macro-exten-vm, s, 14) exited non-zero on 'SIP/1009-00000cfe' in macro 'exten-vm'
  == Spawn extension (from-internal, 1007, 2) exited non-zero on 'SIP/1009-00000cfe'
-- Executing [h@from-internal:1] Macro("SIP/1009-00000cfe", "hangupcall") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/1009-00000cfe", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@macro-hangupcall:3] ExecIf("SIP/1009-00000cfe", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [s@macro-hangupcall:4] Hangup("SIP/1009-00000cfe", "") in new stack
  == Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/1009-00000cfe' in macro 'hangupcall'
  == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/1009-00000cfe'
  == MixMonitor close filestream (mixed)
  == Extension Changed 1009[ext-local] new state Idle for Notify User 1009
  == End MixMonitor Recording SIP/1009-00000cfe

but at FREEPBX site i also have such subnetwork as my external phone subnetwork, so i assume, that my problem is that router sends RTP packets to wrong place.

For now i’m about to change subnetwork on external site, but it could take a while.

Could someone explain me, why RTP packet is being sent to 192.168.0.77:4012 instead of [default gateway]:61488 ?

Is NAT enabled in FreePBX? (Under SIP Settings and the Extension > Advanced)
Also, do you have 10000-20000 forwarded to your PBX?

Yes, NAT is enabled, also
Override external IP is set to external IP address.
EXTERNAL address is set to external IP address.
LOCAL networks is set to 192.168.2.0/24 and 192.168.90.0/24

You are using ChanSIP or PJSIP?

I’m using ChanSIP

On the Extension under advanced is this set to yes?

Also, take a look at these routers, make sure that the “SIP Helper” is disabled.

Yes, NAT mode set to yes on this extensions,
i also re-checked, that SIP Helper is disabled on both routers.
On the FREEPBX site i have Fortigate 50B, on external phone site i have simple tp-link router, and i read somewhere, that Fortigate have problems working with SIP or RTP traffic, have you heard something about that?

Nope, sorry not familiar with that.

Maybe there are other people here who have experience with that router.

However, remember google ia your friend :wink:

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