Direct call to extension without inbound route

Hi all,

My company uses FreePBX/Asterisk as its main phone system (Elastix distribution). We recently changed of SIP trunk provider and something doesn’t behave like before since the switch from one trunk to the other.
All the employees have a dedicated line number, accessible from external calls and which targets their personal phone extension, the last 4 digits. Each extension is configured in FreePBX to have the right SIP alias defined but no inboud DID is set, nor dedicated inbound route. With our first trunk provider, the SIP alias value was used to “inbound route” calls to the right extension from external calls. When the SIP alias value was emptied, the server terminated the call immediately. With the current provider and the same extension configuration, an external call never reaches the extension (call terminated with an error message), except if I create an inbound route.

I honestly don’t want to manage and maintain one inbound route per extension.
As a temporary solution, I have added an inbound route with DID number _17595XXXX with an arbitrary extension destination. Then I have manually edited the file “extensions_additional.conf” to insert the ${EXTEN:-4} instruction:

Now it works as expected, but each time I modify something from the FreePBX GUI I get all the “inbound calls” broken!

What is the proper way to do what I want? How can I explain that the two trunks don’t behave the same? With the first provider we had a router installed in-house (no access to the configuration) that we don’t have with the current provider. Is it a clue?
(Please, don’t suggest me to build an IVR because that’s not what I want.)

Here is the original trunk configuration:


And the new one:


Thanks for your precious help.

There is a big warning at the top of that file saying 'Do not edit this file, if you want to make changes, edit extensions_custom.conf".

You should be adding your dialplan to extensions_custom.conf.

You also don’t have a context= line in your trunk configuration, that’s required. So, add context=from-sip-provider to your trunk, and then add this to your extensions_custom.conf:

exten => _17595XXXX,1,Goto(from-did-direct,${EXTEN:-4},1)

@xrobau, you saved me a lot of time!

I’m not an IPBX guru so I’m not familiar with contexts yet. In any case, I apparently can’t use a dedicated context because if I do so, all my existing inbound routes are broken! So I kept [ext-did-0002] for now.

The system works correctly now but I have one last problem: even non-existing extensions are “reachable” by the corresponding DID. This may not be expected, particularly if I want an extension to be “private only”. I would prefer to be able to set if the extension should be reachable by a DID or not.
Do you have any idea on how to use the “SIP alias” as the DID? If empty, the extension won’t be reachable from an external call.

Thanks again :wink:

The SIP alias is not used for routing calls. One of the settings that you can find in each extension is the inbound did, if you set there the did number for each extension then freepbx creates also an inbound route for you. You can also use the bulk dids or bulk extensions module to configure the inboud routes in case that you have too many extensions.

1 Like

if you set there the did number for each extension then freepbx creates also an inbound route for you

In fact that’s what I don’t want to do, like I said in the topic title. This involves too much maintainance if I need to change something for a whole batch of DIDs.

I know that the SIP alias is not designed to route inbound calls but with my old SIP provider and configuration, I was able to route inbound calls to the right extension based on the SIP alias: as soon as I removed the SIP alias of an extension, the call failed. Problem: I can’t explain what are the differences between the old and the new configuration. Is this from the trunk config?

Any idea on how to solve my problem?

If that’s your problem, then there’s no way around it. You can’t say ‘I want to limit the list of extensions people can call into’ in one breath, and then in another breath say

“a whole batch of DIDs” is kinda of what the bulk import module is for. Having recently used it for a " whole batch of DIDs" I can say it work pretty good.

And as far a “reachable DID’s” . If it doesn’t exist in your system, I don’t see how they are “reachable” other than at some point asterisk will try and contact it. Though I haven’t tried it, I imagine something like “The number you have dialed is not in service” will be played to the caller. Additionally, if you don’t actually own the phone number (full 10 digits), it won’t be getting routed to the PBX from PSTN, so Asterisk will never go looking for it. Maybe I’m missing something, but I don’t see any issue.

What Type of FXO device are you using

I know this is old discussion but I wanted to properly close the topic.

I chose to move all “private” extensions to a “private” range, i.e. in which there is no DID in service thus no external call to those extensions is possible. I am satisfied with that configuration and I use inbound routes only for specific features.

Even if I didn’t find an explanation to the original behavior (routing based on SIP alias) your help solved my problem. Thank you all!

I have probably spoken too fast because I have just found the relation between SIP aliases and Inbound routes. If a SIP alias is defined for an extension, the following instruction is automatically written in “extensions_additional.conf”:

exten => THE_SIP_ALIAS,1,Goto(from-internal,THE_EXTENSION,1)

I don’t know if this is Elastix specific or if it exists in the FreePBX core. So every extension with a SIP alias defined should be callable from the trunk.

I didn’t receive external calls based on the SIP aliases because my SIP alias formatting was wrong (it included the initial ‘0’ whereas my provider doesn’t transmit it). After having set the right format to the SIP aliases, every external call is routed to the right extensions. And if no SIP alias is defined, the extension is not reachable from the outside world.

Wow, finally got it! :grin: