Narrowing down media port range


As I understand, the communication between SIP phone and Asterisk server is as follows:

  1. Upon initial communication, the SIP phone sends a media port range to Asterisk.
  2. Asterisk picks two random ports out of this range and initiates audio conversion on these ports.

I noticed that Cisco SIP phones have a default media port range of 16384 to 32766. Why can’t I just narrow it down to two ports? For example:

SIP phone 1 - 16384-16385
SIP phone 2 - 16386-16387
and so on…

In our case, the phones are behind NAT. With the above setup, all I would need to do is define a simple port range forwarding on the router.

UDP port 16384-16385 ==> Forward to the IP of SIP phone 1
UDP port 16386-16387 ==> Forward to the IP of SIP phone 2

Does anyone see a problem with this?

Thank you in advance for your help.


The SIP phone (normally at least) sends the exact port on which it expects to receive RTP and the correspondent (e.g. Asterisk, does the same).

yes, most phones generally only have a single RTP port defined. Asterisk, on the other hand, has a range of ports defined in rtp.conf. The default is 10000-20000. Unless you plan on having 5000+ concurrent calls with a high churn rate, you can probably bring that down substantially :smile:

Thank you all for your help.

If SIP phone is dictating the RTP port number to use, how do the port numbers in rtp.conf come into play? Is it when Asterisk itself acts as a SIP client?

Also, does the SIP phone send two RTP ports or just one? If it is just one, I can narrow down the range further.

Appreciate your help.


RTP and SDP don’t distinguish between client and server. Each party is responsible for their own inbound port numbers.

Thank you for your help, David. I thik I am still a bit lost.

If I understand you right:

Asterisk tells SIP phone:-- Please talk to me on port 10231 (a port randomly chosen between 10000 and 20000)

SIP phone tells Asterisk:-- Sure. You can talk to me on part 13400 (a port randomly chosen between media_start and media_end of the phone).

So now the SIP phone opens a connection to Asterisk on port 13400 and Asterisk opens another connection to the phone on port 10231.

Essentially, the SIP phone opens two connection to Asterisk - port 5060 (SIP) and port 13400. Asterisk opens up one connection to SIP phone - port 10231.

Is this right?

Appreciate your help.


You have the first part right, but I think you are a bit confused about UDP. UDP doesn’t really open up ‘connections’. UDP is a non reliable transport mechanism (unlike TCP). Messages are more or less just sent to an IP:Port and if the other side accepts the message it may or may not respond.

In a VoIP call utilizing SIP protocol there are always two ports on each side. The signalling (SIP) port which is used to set up and tear down the call, and the media port which is used to transmit the RTP stream.

I would highly suggest reading some SIP tutorials to get a better understanding of the protocol and how everything comes together.