Set source port for trunk configuration

Good morning guys,
I have a trunk that I want to conifgure in my Asterisk installation.

The deal with the provider is that there’s no authentication to do; but they make the thing work according to the source ip address and the port.

Now — the problem I have is that I do not find any way to say to my trunk (configured using the pjsip driver) that the source port where the communication should be happening should not be 5060 —but rather another one.

Just as reference — I have another VOIP system (Draytek Vigor 2820) that allows exactly this scenario through the “Sip Local Port”

Do you know how can I make this happen in Asterisk?

PJSIP can have multiple transports defined, each one listens on a different port. An endpoint can be configured to use a specific transport. That is how you would do such a thing.

Thanks a lot for the prompt response.

The thing is — I am not trying to change the listening port; I’m trying to change the source port in Asterisk to initiate the connection.

Just to clarify — my Asterisk server is the client that has to connect to this trunk; the trunk provided requires NO registration and that the connection is coming precisely from a particular IP Address (that’s the easy part) and a particular port (7015). That’s what I want to enforce.

Does that explain it better?

The listening port is used as the source port. It has to be listening, or else the remote side could never send responses and traffic back to Asterisk.

Ah! I thought that part was exclusively for listening incoming trunk registrations.

So if I understand correctly — it would be enough to create a new transport (pjsip.transform.conf) that can be the exact same copy of the current one but listening on my port, and then set the trunk to use that transport.

Is that correct?

Yes, that would be correct.

Thanks; I’m going to try this tomorrow morning. Hopefully that’s the last piece I’m missing to complete the thing.

So I’ve tried and I am now getting positive responses when Asterisk is sending the OPTION verb to their system.

I have two questions now:

  1. I was surprised to see that all the extensions were still logged in correctly. My original thinking was that I should have been changing the port to all the extension too (from 5060 to new_port_number). That wasn’t needed.
    Am I missing something?

  2. I can see now positive responses from the trunk to the OPTION verb, but the calls still do not seem to reach my PBX system. The log seems to be completely empty. Any advice where to look at?

Thanks again,

V.

You would need to provide the specific configuration to show what you are referring to.

If you see nothing on calls then either a firewall is blocking the traffic or upstream is not sending it to you for some reason.

Thanks again for your help.

I’ll try to open up the ports a bit tomorrow.

Here’s the config I’m using right now. Note: I’ve been collecting it from multiple files as I’ve been using FreePBX to make it easier.

[LCR]
type=aor
qualify_frequency=60
contact=sip:my.sip.server:5060

[LCR]
type=auth
auth_type=userpass
password=
username=LCR

[LCR]
type=endpoint
transport=0.0.0.0-udp
context=from-pstn
disallow=all
allow=ulaw,alaw,gsm,g726,g722
aors=LCR
language=es
t38_udptl=no
t38_udptl_ec=none
fax_detect=no
t38_udptl_nat=no
direct_media=no
dtmf_mode=auto

[LCR]
type=identify
endpoint=LCR
match=my.sip.server

[0.0.0.0-udp]
type=transport
protocol=udp
bind=0.0.0.0:customPort
external_media_address=my.wan.ip.address
external_signaling_address=my.wan.ip.address
allow_reload=no
tos=cs3
cos=3
local_net=192.168.1.0/24

Is is now working perfectly after opening the port on my firewall.

Thanks a lot for the support!