# RTP issue, Reverse Proxy using firewalld and OpenVPN

**URL:** <https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127>\
**Category:** Networking\
**Tags:** firewall, configuration\
**Created:** [May 20, 2021, 6:35pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127 "2021-05-20T18:35:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 20, 2021, 6:35pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/1 "2021-05-20T18:35:02Z")

</div>

I am trying to connect my softphone to a remote freepbx installation on a raspberry pi. The raspberry pi is using an OpenVPN client to connect to my cloud server. My cloud server has a static public IP and I use firewalld to forward the required ports to RPi. I have set up port forwarding for UDP ports 5060, 5160, 10000-20000 on my cloud server using firewalld. I am able to connect to the cloud server IP with Zoiper and login with my EXT, but after establishing a call, there is no audio (both ways) and the call disconnects after 30s because of RTP failure.  
I have played with various NAT setting in “General SIP Settings”, “chan\_pjsip” and “chan\_sip”, but I can’t make it work.

Here is how the net looks like:

My PC(Zoiper): 192.168.1.2[Private, DHCP]  
===\>===  
My Modem: 192.168.1.1[Private, Static], 9.8.7.6[Public, Dynamic]  
===\>===  
Cloud Server: 1.2.3.4[Public, Static], 10.8.0.1[Private, OpenVPN]  
===\>===  
Remote Site Modem: 192.168.1.1[Private, Static], 5.6.7.8[Public, Dynamic]  
===\>===  
Rpi Freepbx: 192.168.1.2[Private, DHCP], 10.8.0.4[Private, OpenVPN]

==============================  
Zoiper connects directly to 1.2.3.4:5060[chan\_pjsip] or 1.2.3.4:5160[chan\_sip] without any problem.  
RPi connects to cloud server using OpenVPN as I said. When I check my local udp traffic on my PC, i see that zoiper tries to send RTP packets to 10.8.0.4!!! which is the private ip lease from the openvpn server.

Freepbx’s “External Address” is set to 1.2.3.4  
“Local Networks” are: 0.0.0.0/1, 10.8.0.0/24, 128.0.0.0/1, 192.168.1.0/24

There is a masquerade rule in firewalld =\> “firewall-cmd --add-masquerade --permanent”  
Forwarded ports:  
firewall-cmd --zone=public --add-port=5060/udp --permanent  
firewall-cmd --add-forward-port=port=5060:proto=udp:toport=5060:toaddr=10.8.0.4 --permanent  
firewall-cmd --zone=public --add-port=5160/udp --permanent  
firewall-cmd --add-forward-port=port=5160:proto=udp:toport=5160:toaddr=10.8.0.4 --permanent  
firewall-cmd --zone=public --add-port=10000-20000/udp --permanent  
firewall-cmd --add-rich-rule ‘rule family=“ipv4” forward-port port=“10000-20000” protocol=“udp” to-port=“10000-20000” to-addr=“10.8.0.4”’ --permanent

A softphone connected directly to RPi works flawlessly with bidirectional audio.

What am I missing here?

---

<div class="post-metadata">

**Author:** ![Stewart1](https://community.freepbx.org/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Stewart1](https://community.freepbx.org/u/Stewart1)\
**Post date:** [May 20, 2021, 11:03pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/2 "2021-05-20T23:03:53Z")

</div>

Just guessing here (because I’m not sure of how the firewalld (iptables) rules behave:  
For the Zoiper pjsip extension, set RTP Symmetric to Yes.  
Set Local Networks to only 192.168.1.0/24, Submit, Apply Config, then restart Asterisk and test.  
If no luck, at the Asterisk command prompt, type  
`pjsip set logger on`  
make a failing test call, paste the log for the call at [pastebin.freepbx.org](http://pastebin.freepbx.org) and post the link here. If you are too new to the forum to permit links, just post the 8 hex characters after /view/ .

However, please explain all the constraints that led you to do something so convoluted and complex.

For example, why can’t you do one of these?

1. Run an OpenVPN client on the PC with Zoiper, set client-to-client in the VPN server, have Zoiper register to 10.8.0.4

2. Run the PBX on the cloud server.

3. Have Zoiper connect directly to the Pi’s public address, using a dynamic DNS name and forwarding SIP and RTP ports as needed.

Also, what trunks do you have on the Pi? If SIP, are they routed through the VPN and cloud server? If so, why?

---

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 21, 2021, 3:56pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/3 "2021-05-21T15:56:54Z")

</div>

RTP Symmetric is set to YES, local net to only 192.168.1.0/24, the problem still exists  
Here is the pjsip log hex code f8c62d61  
[pastebin.freepbx.org/view/f8c62d61](http://pastebin.freepbx.org/view/f8c62d61)  
I have changed the IPs and Numbers to match my net diagram described above

to answer your questions:

1. client to client openvpn works fine with audio and everything
2. I want to use my existing webserver, so I am port forwarding the required ports
3. The Pi is behind a CGNAT, dynamicDNS is not going to help, thats why I am using a reverse proxy with openvpn and firewalld

I am using a 3g dongle on the Raspberry Pi.

---

<div class="post-metadata">

**Author:** ![Stewart1](https://community.freepbx.org/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Stewart1](https://community.freepbx.org/u/Stewart1)\
**Post date:** [May 21, 2021, 4:22pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/4 "2021-05-21T16:22:20Z")

</div>

Lines 221 and 224 show that Asterisk properly substituted the public IP in the signaling, but line 240 shows that it did not for the media.

Possibly a pjsip bug or limitation (it ‘knows’ that 10.8.0.1 is local), or a FreePBX bug generating the config.

Please post the contents of /etc/asterisk/pjsip.transports.conf .  
If you have anything in pjsip.transports\_custom.conf or psjip.transports\_custom\_post.conf, post the contents and explain why you did it.

---

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 21, 2021, 4:45pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/5 "2021-05-21T16:45:17Z")

</div>

# /etc/asterisk/pjsip.transports.conf

[0.0.0.0-udp]  
type=transport  
protocol=udp  
bind=0.0.0.0:5060  
external\_media\_address=1.2.3.4  
external\_signaling\_address=1.2.3.4  
allow\_reload=no  
tos=cs3  
cos=3  
local\_net=192.168.1.0/24

/etc/asterisk/pjsip.transports\_custom.conf and /etc/asterisk/psjip.transports\_custom\_post.conf are empty

---

<div class="post-metadata">

**Author:** ![Stewart1](https://community.freepbx.org/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Stewart1](https://community.freepbx.org/u/Stewart1)\
**Post date:** [May 21, 2021, 4:53pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/6 "2021-05-21T16:53:20Z")

</div>

pjsip.transports.conf looks correct. Try rebooting the Pi, just in case something failed to update. If it still fails, I think this is a pjsip bug, which you may want to report. Possibly, chan\_sip will work better in this case.

---

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 21, 2021, 4:58pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/7 "2021-05-21T16:58:47Z")

</div>

chan\_sip has the same issue, my pc tries to connect to 10.8.0.4 for rtp which is a dead end!  
tested it with “sip set debug on” and its returning 10.8.0.4 to the client softphone

---

<div class="post-metadata">

**Author:** ![Stewart1](https://community.freepbx.org/letter_avatar_proxy/v4/letter/s/bc79bd/32.png) [@Stewart1](https://community.freepbx.org/u/Stewart1)\
**Post date:** [May 21, 2021, 5:08pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/8 "2021-05-21T17:08:16Z")

</div>

> [@morty71](#):
>
> chan\_sip has the same issue …

Wow. It seems unlikely that both drivers would have the same bug, unless it was plagiarized (I doubt that).

Possibly, there is something funny about the incoming INVITE that triggers this problem. Could you paste another log that starts with the received INVITE from the trunk?

Do outbound calls have this trouble?

---

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 21, 2021, 5:35pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/9 "2021-05-21T17:35:10Z")

</div>

Yeah, outbound calls have the same issue.

Here is the outbound call log with the INVITE packet: eca67f45  
[pastebin.freepbx.org/view/eca67f45](http://pastebin.freepbx.org/view/eca67f45)

---

<div class="post-metadata">

**Author:** ![morty71](https://community.freepbx.org/user_avatar/community.freepbx.org/morty71/32/21298_2.png) [@morty71](https://community.freepbx.org/u/morty71)\
**Post date:** [May 25, 2021, 7:26pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/10 "2021-05-25T19:26:56Z")

</div>

I have created an issue in both Freepbx Jira and Asterisk Jira. The guys at freepbx are trying to test the mentioned scenario and said that If media IP is not changing, then it could be an asterisk bug.

---

<div class="post-metadata">

**Author:** ![system](https://community.freepbx.org/uploads/default/original/3X/f/7/f7056d57e04fdbf71c6ad967e1ced351317f5c3f.png) [@system](https://community.freepbx.org/u/system)\
**Post date:** [June 24, 2021, 7:27pm UTC](https://community.freepbx.org/t/rtp-issue-reverse-proxy-using-firewalld-and-openvpn/74127/11 "2021-06-24T19:27:00Z")

</div>

Closed on June 24, 2021, 7:27pm UTC

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