Let’s write a helpful forum thread for people confounded by port settings.
Where to start?
When I am working in the Asterisk SIP Settings menu, I am specifying the ports that I am listening on. Those are the ports where people connect to me.
When I am working in Trunks and see a “port” field, that refers to the port the SIP provider is listening on. USUALLY I leave this blank or default. The SIP provider will tell me if he is using an alternate port, or it will be part of a SRV record so that I don’t even have to worry about it.
If I have both chan_sip and pjsip enabled, then they are listening on different ports on my PBX. (Look in the Asterisk SIP Settings module) For my phones and any SIP providers that connect directly to me without using registration, I need to know which port they should connect to and I need to tell them that. The typical way to tell someone else how to connect to me on a certain port is to specify it as IPADDRESS:PORT, for example:
If my phones have a “SIP Port” field in their configuration, it almost never means “the port for connecting to the PBX.” You normally specify IP:port for connecting to the PBX as mentioned just above.
My RTP range (Asterisk default 10000-20000) is the range of ports where I (PBX) am listening for incoming audio packets. You (SIP provider, phones) can use any range you want and it does not matter to me. I will send audio packets to you on the ports you tell me in our SIP handshake (SDP), and you will send audio packets to me on the ports where I am listening.
Use only PJSIP and disable chan_sip (in Advanced Settings - SIP channel driver). It will reduce opportunities for confusion.
Use the default ports until you really understand how ports work. This is not SIP, it’s networking. @dicko is going to come along and say to change the ports so that ne’er-do-wells don’t scan your PBX, as he often does. His advice is good but don’t go making changes to your port settings until you full understand this networking feature.
Please add to this and make corrections. Let’s develop a solid thread.