# Routing of calls

**URL:** <https://forums.vitalpbx.org/t/routing-of-calls/307>\
**Category:** VitalPBX\
**Created:** [August 20, 2021, 6:23pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307 "2021-08-20T18:23:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 6:23pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/1 "2021-08-20T18:23:45Z")

</div>

Hallo,

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,

Edit:  
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

---

<div class="post-metadata">

**Author:** ![joseph](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@joseph](https://forums.vitalpbx.org/u/joseph)\
**Post date:** [August 20, 2021, 6:32pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/2 "2021-08-20T18:32:58Z")

</div>

Hi,

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.

[![](https://forums.vitalpbx.org/uploads/default/original/2X/3/3a719bd0290390943cdea8df3ae5d8bf1e0f547d.jpeg "How to setup VitalPBX Outbound Routes") ](https://www.youtube.com/watch?v=bltrGPg5Zec)

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 6:39pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/3 "2021-08-20T18:39:33Z")

</div>

Hi Joseph,

I have set it up, like this:

 ![billede](https://forums.vitalpbx.org/uploads/default/original/1X/e3eb18a574c387ec63a85a19d0e5e4ba4e91075d.png)

---

<div class="post-metadata">

**Author:** ![joseph](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@joseph](https://forums.vitalpbx.org/u/joseph)\
**Post date:** [August 20, 2021, 6:50pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/4 "2021-08-20T18:50:54Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 7:04pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/6 "2021-08-20T19:04:45Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![joseph](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@joseph](https://forums.vitalpbx.org/u/joseph)\
**Post date:** [August 20, 2021, 7:14pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/7 "2021-08-20T19:14:33Z")

</div>

You would have something like:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 7:17pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/8 "2021-08-20T19:17:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 7:22pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/9 "2021-08-20T19:22:00Z")

</div>

Sorry,  
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

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 20, 2021, 10:15pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/10 "2021-08-20T22:15:11Z")

</div>

So,  
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  
 ![billede](https://forums.vitalpbx.org/uploads/default/original/1X/dcb4215d3b2074969d398a6583d526d3c0840079.png)

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,

---

<div class="post-metadata">

**Author:** ![mo10](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mo10](https://forums.vitalpbx.org/u/mo10)\
**Post date:** [August 20, 2021, 10:59pm UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/11 "2021-08-20T22:59:44Z")

</div>

Outbound Route **1**

 ![image](https://forums.vitalpbx.org/uploads/default/original/1X/241da7f3f5709f326cc7173e826aa48702104fb2.png)

Outbound Route **2**

 ![image](https://forums.vitalpbx.org/uploads/default/original/1X/5586e4d3614c9beccd5cc6f6fc263d5afab388e1.png)

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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 7:52am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/12 "2021-08-21T07:52:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mo10](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mo10](https://forums.vitalpbx.org/u/mo10)\
**Post date:** [August 21, 2021, 7:55am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/13 "2021-08-21T07:55:06Z")

</div>

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:

 ![image](https://forums.vitalpbx.org/uploads/default/original/1X/ce0208bb21d9520a354b2a1f9e90ba7b7a3efb86.png)

Trunk B:

 ![image](https://forums.vitalpbx.org/uploads/default/original/1X/cf019af95dd45b5d41cda808206a15d5fc227862.png)

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

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 7:59am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/14 "2021-08-21T07:59:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mo10](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mo10](https://forums.vitalpbx.org/u/mo10)\
**Post date:** [August 21, 2021, 8:00am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/15 "2021-08-21T08:00:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 8:01am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/16 "2021-08-21T08:01:28Z")

</div>

this is trunk A

 ![billede](https://forums.vitalpbx.org/uploads/default/original/1X/6cc88b49dfc93849f164c26a29a0be4f3fc1310f.png)

this is trunk b

 ![billede](https://forums.vitalpbx.org/uploads/default/original/1X/21446664520269a40b82eb023900bdec70faa65a.png)

---

<div class="post-metadata">

**Author:** ![mo10](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mo10](https://forums.vitalpbx.org/u/mo10)\
**Post date:** [August 21, 2021, 8:02am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/17 "2021-08-21T08:02:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 8:03am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/18 "2021-08-21T08:03:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 8:04am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/19 "2021-08-21T08:04:33Z")

</div>

Class Of Service, looks like this:

 ![billede](https://forums.vitalpbx.org/uploads/default/original/1X/55253d5d5934d9dd8534c0a53534e62e3559d131.png)

---

<div class="post-metadata">

**Author:** ![mo10](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mo10](https://forums.vitalpbx.org/u/mo10)\
**Post date:** [August 21, 2021, 8:10am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/20 "2021-08-21T08:10:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mads\_Mortensen](https://forums.vitalpbx.org/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@Mads\_Mortensen](https://forums.vitalpbx.org/u/Mads_Mortensen)\
**Post date:** [August 21, 2021, 8:15am UTC](https://forums.vitalpbx.org/t/routing-of-calls/307/21 "2021-08-21T08:15:51Z")

</div>

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

[Next page](https://forums.vitalpbx.org/t/routing-of-calls/307.md?page=2)
