[asterisk-users] configure SRTP port range?

Joshua C. Colp jcolp at digium.com
Sat Feb 23 09:19:12 CST 2019

On Sat, Feb 23, 2019, at 11:04 AM, hw wrote:


> directmedia is not explicitly enabled; I guess it's the default.
> Joshua basically says there is no way to control which ports are being 
> used for SRTP because that it is "up the endpoint".  Such endpoints, in 
> this case, are mobile phones with software like csipsimple or gs-wave 
> (or perhaps zoiper), and I see no way in these programs to define which 
> ports to use for SRTP.
> Since I have no way to define which ports endpoints use for SRTP, I 
> would have to open all UDP ports in the firewall, and I don't want to do 
> that.
> Nat is currently not involved yet.  I want to get this to work first and 
> then look into nat issues.
> > Only open a range of ports that you really use: for example is you have 
> > maximum 10 simultaneous calls, open only 40 ports (4 ports for each 
> > call, two for RTP and two for RTCP). Then change rtp.conf configuration 
> > reflect the range of ports you using.
> So how would I control which ports are being used for SRTP?  Some ports 
> being open on the firewall doesn't mean the phones will automagically 
> use them, does it?

I think there's confusion over ports. In calls there's two ports and IP addresses in play. There is the IP address and port that Asterisk listens on and sends media from. There is also the IP address and port that the endpoint listens on and sends media from. You can control the Asterisk one as mentioned using rtp.conf. Therefore the firewall rule for where Asterisk is running would be:

Any source to UDP ports X to Y (10000 to 20000 by default) allow.

What you can't do is limit the rule based on the source of media, except for circumstances where you know for sure the source.

Note that RTP ports in Asterisk aren't open all the time and only listen when a call is using it, and they also learn the source of media - blocking out other sources.

Joshua C. Colp
Digium - A Sangoma Company | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - US
Check us out at: www.digium.com & www.asterisk.org

More information about the asterisk-users mailing list