The name of the Asterisk trunk is incorrectly substituted, when entering to different DID numbers

Good day, colleagues.

There is a problem that is not very significant, but, nevertheless, it gives a headache.


FreePBX15 / Asterisk 16.9.0

6 SIP trunks are configured and in operation. Each has its own DID on which I land the call, each has its own name for both the web interface and Asterisk.

When an incoming call arrives to any of the DID numbers, I should see that the call came to the required trunk, but instead, calls to any DID come with the same trunk name, although, again, each has its own name.

An example with a combat PBX, disguised numbers and ip’s:

Name/username Host Dyn Forcerport Comedia ACL Port Status Description
hsesru-749XXXXXXXX/iwYeg4 X.X.X.X Yes Yes 5060 OK (41 ms)
ukcrit-749XXXXXXXX/PfrDWi X.X.X.X Yes Yes 5060 OK (39 ms)
ukcrpro-749XXXXXXXX/gzo7I X.X.X.X Yes Yes 5060 OK (39 ms)
ukcrru-749XXXXXXXX/mHdHrr X.X.X.X Yes Yes 5060 OK (39 ms)
ukcrsu-749XXXXXXXX/1CcrID X.X.X.X Yes Yes 5060 OK (39 ms)
vsoutru-749XXXXXXXX/aId0T X.X.X.X Yes Yes 5060 OK (40 ms)

In the process of troubleshooting, I also noticed an interesting feature: the trunk name in the Asterisk CLI will always display what is above all in the list. For example, a call came to the ukcrit-749XXXXXXXX trunk, hsesru-749XXXXXXXX will be displayed, since he is higher on the list. If you disable hsesru-749XXXXXXXX, then ukcrit-749XXXXXXXX will be displayed for all trunks and so on.

To summarize: the problem is not with DID, the problem with displaying the trunk name when calling different DIDs.

In this case, I will also be grateful to you for any advice or help in troubleshooting and solving the problem.

Best wishes.

Chan_sip does not have any way to distinguish calls from trunks registered to the same server on the same provider. pjsip has the “Send Line in Registration” option, on by default, which should do what you want.

If for some reason you must use chan_sip, there are possible workarounds. Please explain:
Why do you care (trunks billed to different departments, you want to limit the number of concurrent calls on a trunk, you need to prepare a report of usage by trunk, etc.)? Also, why do you have multiple trunks at all (can you have multiple DIDs on the same trunk with this provider)?

The DID is not provided as part of the SIP INVITE, is it in the To header? If so, you can use the trunk context from-pstn-toheader

You should only ever have a single trunk to your provider. You do not make a trunk per DID.

I am posting the registration string for each trunk separately. Unfortunately, I do not have access to a personal account or the type of one where the telecom operator will provide the client with the opportunity to customize anything.

This worries me because each number is assigned to its own department.

Multiple connecting lines each SIP trunk in my case is a separate account to which numbers are routed above me, in any case, I suppose so. If you dig SIP signaling, it becomes clear that this is most likely the case. However, it works great.

The DID is provided in the uri-user part of the To header, but it is in half-e.164 format, i.e. comes the number 7495XXXXXXX.

Because this is a logged trunk, then I send the DID in non-e.164 format, because it’s an old habit. This is substituted in the contact header in the uri-user part when registering, so the carrier sends me a call to whatever I specify in the uri-user contact header. So when the carrier sends me a call, I get this DID in the Request-Line INVITE of the request.

However, thanks for the tip, I’ll review this context tomorrow, try it out, and provide an answer.

Who said that there should always be one trunk? If, for example, on the provider’s PBX the numbers are moved from the public telephony capacity to the capacity of the virtual platform, then no one bothers the VPBX to route these numbers to the SIP accounts of the VPBX subscribers in order to provide the end service to the client in this way. As I said in the first reply to the post, I don’t know how the service is provided in this situation, since I do not have access to my personal account. I don’t know if he exists as a class at all. In Russia, SIP trunks in a small telecommunications environment can be provided separately, without VPBX, this allows engineers to manage routing on their own, but that’s all.

How something routes to your provider is not relevant.

You have 6 SIP trunks all to the same provider. The behavior you are seeing is how it is supposed to work in the scenario listed.

If you can use pjsip, that’s an easy solution.

If for some reason you are stuck with chan_sip (please explain), you could write some custom dial plan that e.g. takes the trunk name (that you put in the register string) from the SIP URI and the DID from the To header (reformatted if necessary).

IIRC, Asterisk with Chan-SIP will always match the first trunk name that matches the parameters of the inbound call. It makes processing easy and is logically simple.

If your trunks all come from the same IP address, there is no reason to have them for inbound traffic. Any of the trunks will pass the incoming call to your inbound routes, which will process according to the matched DID for your connection or drop the call into your “Any/Any” route.

For Outbound, you may require all of these trunks, assuming the phone numbers are allocated one-for-one with the ITSP. In spite of that, I think you’ll find that the outbound trunks also match the IP Address of the remote server, so I’d venture to guess that all of your calls are going out on the same trunk, just like the incoming calls appear to be.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.