Routing of calls


If I am prefixing a call with 99 (e.g. 99 9545551234) to you a specific trunk, how to I get the system to remove the “99” before sending it, via the trunk?
i have tried with the prefix (remove prefix) but do not seem to work,

A bit more details:

We run all “normal calls” via a main trunk
All mobile calls (calls to our own mobile GW) should be route to our mobile SIP gateway,
i want to do that, by adding a prefix to the mobile number in the PBX - but the prefix must be removed, before sending the call to the mobile trunk


Can you show us how you have configured your Outbound routes? This way we can take a look into why the prefix is not being removed from the number when sending to the trunk.

Furthermore, you can see the following video, where the outbound routes are explained.

Hi Joseph,

I have set it up, like this:


The problem is that you are specifying the “prefix” on the Pattern itself. The video goes more in-depth on the fields, but what you would need to enter would be somethings like:

Prepend  |  Prefix   | Pattern
         |    99     |    95.

If the numbers start with anything other than “95”, you can express this as X. and this will analyze any number of any length. You use the Pattern as the number to be dialed through the trunk, and add prefixes (to be removed) or prepends (to be added) as you will.

I am bit confused.

If I want to call: telephone number, 12345678 via a specific trunk, lets call it “trunk B”
So if I dial 99 12345678
How do I

1) Make sure than only calls prefixed with 99 will ne routed via the trunk “b”
2) The prefix “99” is removed before call is sent out via the trunk

You would have something like:

Prepend  |  Prefix   | Pattern
         |    99     | 12345678

Prefix is always removed, and the prepend is always added. I recommend you watch the video I sent earlier. As well as the rest of the Advanced Training Playlist on the VitalPBX YouTube Channel.

Thank you,
However I watched the videos and read the wiki, and still are not able to make it work

No matter what I do, the trunk sends out the call with the prefix included.

I now see ( at least i think) the issue
It is routing via the wrong trunk, so even do I prefix the number, it is still routing via Trunk A and not trunk B

I am sorry I keep asking, but I struglling a bit to understand how it works, so I hope you can help me get clear about it

been through wiki, videos and tons of posts - But I see no where, at least I am not able to seem to understand how I can make a routing profile/ trunk setup were as the prefix is controlling the routing.

I have 2 trunks - going to 2 different IPs.
I have 2 routing profiles (1 for each trunk) - as I do not seem to be able too setup one routing profile, going to 2 different trunks.

One routing profile has no prefix.
The other one does

How the f******* to I control the routing, so calls are routed correctly?

Can anyone please give me some pointers, as I am going out of my mind, as the routing setup in Vitalpbx (right now) makes absolutely no sense to me;

Today our Routing setup looks like this, in our current PBX

all have same priority, but the prefix controls what trunk to use.

So just to avoid any misunderstanding, this is not about length of the number called (as it can be every), country code or similar.

It is, when a number is being dialed, and it is prefixed with e.g. #87## it must use a specific trunk,

Outbound Route 1


Outbound Route 2


Hovering over the name PATTERN will show you the patterns available.

Otherwise: send 100% exact examples which numbers you dial and which Trunk it should go.
+1 will be different again for example since + is a special character.

What are all your “#”? Don’t do that in Vitalpbx. Or are you really need to use the “#”? Then just try to add them to Prefix or Pattern accordingly.

1 Like

thank you very much, for that visual

But, my problem is still that one route is prefixed, that other one are not.

So all calls to trunk A is not prefixed it is ONLY calls that needs to go via trunk B that needs a prefix.
So I am still struglling to understand, how you set that up

To above example do not work, if you only have one route that needs prefix.

I i told you, give exact examples!

If you only need one Trunk to be prefixed leave the prefix off and just put “X.” in pattern in the right Trunk that should be used instead. Done.

Trunk A:

Trunk B:

You have multiple lines if you need more prefixes on the same Trurnk.

Thank you for screenshot number 2
that is EXACTLY how I have set it up (from the beginning)
BUT - it do not work!

Unless I remove trunk A - it will not use trunk B (even do I prefix it)
If only use Trunk B (and prefix it) prefix is NOT removed when call is sent to the trunk

Give exact examples which numbers you are calling. Send screenshots as well of the setup!
You can also make a SIP-Trace and link the Pastebin link here.

this is trunk A

this is trunk b

Maybe you set wrong COS (Class of service) on the extension you are trying with?

it is all kind of numbers, the numbers do not have specific prefix, they can begin beverything from 1 to 9
Therefore our own prefix “99” is very important, as that it the only way, we can make sure they are sent via the correct trunk.

Class Of Service, looks like this:


Try with a “Route Selection” on COS and define your Trunks.
How do you know its going the wrong trunk?
Did you read the siptrace yet with asterisk -r -vvvvvvvvvv ?
Might share it here via pastebin.

I can see from my voipmonitor that is using the wrong trunk,
I have not yet looked at the siptrace, as I could wrong trunk is being used