Different SIP source port

Hi Guys,

Is there any way to register a trunk on a registrar with a different Source port other than 5060?
Note that its not the port on which the registrar is listening on SIP services but the source port from which the trunk/account register with the registrar.

This is typically to avoid a known issue of Asterisk when multiple registration are coming up with same IP and port with friend/peer type.

Yes. The peer must send the port number in the Contact header of the register request.

Hi David,

Do you know how this can be done in Asterisk language.
The ‘port’ parameter says the destination port of the registrar.
How can one change the source port ?

It must be done on the peer, not on Asterisk.

When a peer registers, the register request contains a Contact header. That contains both the port and the address.

SIP has no mechanism to tell a remote device what port to use at its end.

OK !..

Is there any work around of the issue when an Asterisk box sees a registration attempt from the same IP and port? It counts the latest registered end point …

I don’t believe Asterisk has such an issue, but if it has, you should search issues.asterisk.org to see its status.

I think the problems you are having are one or both of:

  • you are not sending the user you used as the registration user as the from user in incoming calls, so Asterisk has to do a peer, rather than a user match - Asterisk simply has no way of telling the two apart if you don’t do this. This is one of the rare cases where type=friend is actually a good idea. There is no SIP header that says that a request is associated with a particular registration.

  • for outgoing calls, the SIP protocol provides no way other than the destination port or the request URI to distinguish between the two registrations. I’m assuming this is a trunk, in which case you need to use the destination URI for the final destination number. (If it isn’t a trunk, maybe the device ignores the user part of the URI.)

Thanks David for the explanation,

Definitely there is something that is not making sense to me!
As you have mentioned using type=user, works great with ‘fromuser’ parameter but then there are things like:

  1. We are not registering an endpoint and hence asterisk will authenticate a call by looking at the “username” only which is highly unsecure.
  2. The callerID is replaced with “username”.

I am unable to find a way out to sort it.

Here is the situation:
Name/username Host Dyn Forcerport ACL Port Status Realtime
4142167408/s 45.33.9.9 D N 5060 Unmonitored Cached RT
7194976243/s 45.33.9.9 D N 5060 Unmonitored Cached RT

2 Trunks registered from same IP. If a call is originated from 4142167408 or 7194976243, it is always accounted as coming from 7194976243 (being the last request on asterisk registration table)
I have tried with different settings of “insecure” parameter but no luck.

Can you please comment on this situation?
Thanks alot for the discussion

Use sendrpid/trustrpid for point two.

Type=user will still check the password and you can apply address filters.

Basically, though, if you want to use different source ports you must modify the client configuration, and there is no specific field in SIP that associates an INVITE with a REGISTER.