RTP Port Range Issues

I’m just getting started with FreePBX and am having an issue with RTP port ranges. I am operating behind a NAT firewall. I have specified the RTP port range in FreePBX to be 10001 to 20000 and mapped those same ports on UDP on the firewall to open those ports to the internet. When connecting with a SIP client or trying to connect SIP trunks, my router is showing connections on ports outside of this range. This causes there to be no audio in the call. If I then change the range and open the ports that I see it’s trying to connect to, everything works again (eg: I observe my trunk provider flowroute connecting in the 32XXX range, so I change the RTP ports to be 32000-34000 and it starts working).

I feel like I must be missing a setting - shouldn’t FreePBX negotiate the allowable RTP port range with the client so that it knows what ports to use? Or might I just need to open all UDP ports to RTP?

SIP doesn’t negotiate port number ranges. Each side says what it is prepared to accept and the other side obeys those constraints.

Asterisk will not use a port number outside of the defined range for its local port number, but the other side has free choice. Normally firewalls only restrict incoming traffic, and this won’t cause a problem, but if you try and restrict port numbers in both directions, you will have problems.

E.g. if a.a.a.a is Astersik and has port numbers 100 to 110 and b.b.b.b is the peer, source a.a.a.a:100 desitnation b.b.b.b:300 is valid, as is source b.b.b.b:65535 destination a.a.a.a:108.

Asterisk will tell the other side which port it expects at its end for the particular session, and the other end cannot change that.