# Route

**Routes** define what **[Trunk Group](https://public.intellasoft.net/books/cli/page/trunk-groups)** to use when a certain **Pattern** is dialed.

# Adding a Route

1\) Enter the CLI's configuration mode

2\) Enter a name for the new **Route**. You will then be prompted to enter the minimum options needed to create the new route.

```
vbox-nathan(config)# route      ### use tab to get an available list of routes if you are unsure
ld11_reg local    ld10     ld11     intl     ld10_reg emerg
vbox-nathan(config)# route A_Route
!! Notice: Editing new item: A_Route
!! Notice: Minimum requirements needed for insert:
!!   pattern                    ### see next step
!!   trunk_group
!!   desc
vbox-nathan(config-route A_Route)# desc "Local and Long Distance Numbers +9"
vbox-nathan(config-route A_Route)# trunk_group  ### use tab to get a list of the trunks you have made 
pbx-sip-t1 default
vbox-nathan(config-route A_Route)# trunk_group pbx-sip-t1
```

3\) Next enter a **Pattern** for the route. The **Pattern** represents the combination of numbers that the **Trunk Group** will use when making a call. In many cases, there will be multiple **routes** to define multiple types of **patterns**. Below is an example of what default **Routes** look like on a freshly installed system.

```
--------------------------------------------------------------------------------------------------------------------------------------
|  Route     |  Desc.                               |  Trunk Group  |  Pattern       |  Replace  |  Remove  |  Prepend  |  Postpend  |
--------------------------------------------------------------------------------------------------------------------------------------
|  ld11_reg  |  Long Distance 11 Digit without a 9  |  pbx-sip-t1   |  1XXXXXXXXXX   |           |          |           |            |
|  intl      |  International                       |  pbx-sip-t1   |  9011X.        |           |  +1      |           |            |
|  ld11      |  Long Distance 11 Digit              |  pbx-sip-t1   |  91NXXXXXXXXX  |           |  +1      |           |            |
|  emerg     |  Emergency                           |  pbx-sip-t1   |  9911          |           |  +1      |           |            |
|  ld10      |  Long Distance 10 Digit              |  pbx-sip-t1   | 9NXXXXXXXXX    |           |  +1      |  1        |            |
|  local     |  Local 7 Digit                       |  pbx-sip-t1   |  9XXXXXXX      |           |  +1      |           |            |
|  ld10_reg  |  Long Distance 11 Digit without a 9  |  pbx-sip-t1   |  XXXXXXXXXX    |           |          |  1        |            |
--------------------------------------------------------------------------------------------------------------------------------------
```

<div class="columnLayout single" data-layout="single" id="bkmrk--1"><div class="cell normal" data-type="normal"><div class="innerCell"><div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl"><div><div class="syntaxhighlighter sh-confluence nogutter  java" id="bkmrk----------------------1"></div></div></div></div></div></div></div>**Pattern**

As you can see above **patterns** are not limited to just numbers only, but rather can include specific characters to broaden or narrow down the range of types of calls that the routes will take. You are able to use the following characters to help further define a route that is to be taken:

<div class="columnLayout single" data-layout="single" id="bkmrk-x-matches-any-digit-"><div class="cell normal" data-type="normal"><div class="innerCell">- <span style="color: rgb(46,47,48);">`<strong>X</strong>` matches any digit from 0-9</span>
- <span style="color: rgb(46,47,48);">`<strong>Z</strong>` matches any digit from 1-9</span>
- <span style="color: rgb(46,47,48);">`<strong>N</strong>` matches any digit from 2-9</span>
- <span style="color: rgb(46,47,48);">`<strong>[1237-9]</strong>` matches any digit or letter in the brackets </span>(in this example, 1,2,3,7,8,9)
- `<strong>.</strong>` wildcard, matches one or more characters
- `<strong>!</strong>` wildcard, matches zero or more characters immediately
- `<strong>[a-z]</strong>` matches any lowercase letter (not frequently used/recommended)
- `<strong>[A-Z]</strong>` matches any UPPER case letter (not frequently used/recommended)

</div></div></div>**Replace** (processed first)

The replace function will replace a **pattern** of numbers completely with the defined number included in the replace function.

<div class="columnLayout single" data-layout="single" id="bkmrk-example%3A-a-number-of"><div class="cell normal" data-type="normal"><div class="innerCell">- Example: The number 518-268-3769 matches the **pattern** of a **route** with a replace function set to 5000. Instead of using the 518 number it uses the 5000 number instead plus any of the other functions listed thereafter (such as remove, prepend or postpend)

</div></div></div>**Remove** (processed second)

The remove function will remove numbers from the **beginning or end** of a **pattern** depending on how it is configured. For example, a `+1`, will remove the first digit from a number pattern, whereas `-3` would remove the last 3 from a pattern.

<div class="columnLayout single" data-layout="single" id="bkmrk-example-1%3A-a-number-"><div class="cell normal" data-type="normal"><div class="innerCell">- Example 1: If the number "518-268-3769" matches the pattern of a **Route** with a **remove** of "+1", it will remove the first number ("5") leaving "18-268-3769" (just an example, obviously this is an invalid number unless it were an internal extension).
- Example 2: If the same number as above matches the Pattern of a **Route** with a **remove** of "-3". It will remove the last numbers in the sequence leaving the number "5182683" to be dialed (again just an example).

</div></div></div>**Prepend** (processed third)

Prepend will add a specific string of numbers depending on what numbers are defined. In the default **routes** above, many of the numbers are prepended with a 1 to make them valid long-distance phone numbers that can be used on the PSTN (public switched telephone network).

<div class="columnLayout single" data-layout="single" id="bkmrk-example-1%3A-a-number--1"><div class="cell normal" data-type="normal"><div class="innerCell">- Example 1: The number "518-268-3769" matches a **route** with a prepend of 1, so it will add the number 1 in front, making the actual number used by the **trunk handler** "1-518-268-3769".
- Example 2: The number "268-3769" matches a **route** with a prepend of 518, so it will add the numbers "518" in front of the original number so the actual number being used by the **trunk handler** would be 518-268-3769.

</div></div></div>**Postpend** (processed last)

Postpend is the exact opposite of prepend, instead of adding numbers to the **beginning** of a **pattern**, it will add numbers to an **end** of a pattern.

<div class="columnLayout single" data-layout="single" id="bkmrk-example%3A-a-number-of-1"><div class="cell normal" data-type="normal"><div class="innerCell">- Example: The number "518-268" matches a **route** with a postpend of "3769", it will add the number "3769" to the end of the original number making the actual number dialed out to the **trunk handler** "518-268-3769".

</div></div></div>By using a mix of the above settings, you can dial in highly specific **routes** meant to send specific calls to certain places. In the example below, we are going to use this route as a means of calling a long-distance number when someone is using a 9 dial-out number.

```
vbox-nathan(config-route A_Route)# pattern 9NXXXXXXXXX
vbox-nathan(config-route A_Route)# mangle_remove +1
vbox-nathan(config-route A_Route)# mangle_prepend 1
```

<div class="columnLayout single" data-layout="single" id="bkmrk--2"><div class="cell normal" data-type="normal"><div class="innerCell"><div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl"><div><div class="syntaxhighlighter sh-confluence nogutter  java" id="bkmrk-vbox-nathan%28config-r-1"></div></div></div></div></div></div></div>4\) Lastly use the **show** command to ensure your settings have been saved.

```
vbox-nathan(config-route A_Route)# show
! Generating running-config
!!
 
! -------------- Routes ----------------
route A_Route
  callerid passthrough
  desc "Local and Long Distance Numbers +9"
  mangle_prepend 1
  mangle_remove +1
  pattern 9NXXXXXXXXX
  record inherit
  trunk_group pbx-sip-t1
  exit
 
exit
```

<div class="columnLayout single" data-layout="single" id="bkmrk--3"><div class="cell normal" data-type="normal"><div class="innerCell"><div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code" style="border-width: 1px;"><div class="codeContent panelContent pdl"><div><div class="syntaxhighlighter sh-confluence nogutter  java" id="bkmrk-vbox-nathan%28config-r-3"></div></div></div></div></div></div></div># Route Settings Description

You can also use the "**?**" key to view the description while in the CLI. \* indicates a required setting.

<table border="1" class="confluenceTable tablesorter tablesorter-default" id="bkmrk-%21-comments-callerid-" role="grid" style="border-collapse: collapse; border-style: solid;"><thead><tr role="row"><td class="confluenceTd">Setting  
</td><td class="confluenceTd">Comments</td></tr></thead><tbody><tr role="row"><td class="confluenceTd">callerid</td><td class="confluenceTd">Callerid option for when this route is utilized.</td></tr><tr role="row"><td class="confluenceTd">desc</td><td class="confluenceTd">(\*) Non-functional description of this route.</td></tr><tr role="row"><td class="confluenceTd">do</td><td class="confluenceTd">To run exec commands in config mode

</td></tr><tr role="row"><td class="confluenceTd">exit</td><td class="confluenceTd">Exit from this level (with notification of incomplete config)

</td></tr><tr role="row"><td class="confluenceTd">mangle\_postpend</td><td class="confluenceTd">Number Mangle: Add digits to the end of the dialed destination. This option is processed third.</td></tr><tr role="row"><td class="confluenceTd">mangle\_prepend</td><td class="confluenceTd">Number Mangle: Add digits to the beginning of the dialed destination. This option is processed second.

</td></tr><tr role="row"><td class="confluenceTd">mangle\_remove</td><td class="confluenceTd">Number Mangle: Remove digits from the dialed destination. This option is processed first.</td></tr><tr role="row"><td class="confluenceTd">mange\_replace</td><td class="confluenceTd">Number Mangle: Replace the dialed destination with this. (Enabling this option will override all other number-mangling options)</td></tr><tr role="row"><td class="confluenceTd">no</td><td class="confluenceTd">Clear settings

</td></tr><tr role="row"><td class="confluenceTd">override\_callerid\_name</td><td class="confluenceTd">Callerid name to force, if this route is utilized.</td></tr><tr role="row"><td class="confluenceTd">override\_callerid\_number</td><td class="confluenceTd">Callerid number to force, if this route is utilized.

</td></tr><tr role="row"><td class="confluenceTd">pattern</td><td class="confluenceTd">(\*) Pattern to match dialed destination against that will activate this route.</td></tr><tr role="row"><td class="confluenceTd">record</td><td class="confluenceTd">Call recording option for when this route is utilized.</td></tr><tr role="row"><td class="confluenceTd">show</td><td class="confluenceTd">Show the running-config for the current item

</td></tr><tr role="row"><td class="confluenceTd">trunk\_group </td><td class="confluenceTd">(\*) The trunk group that this route will use to dial out.</td></tr></tbody></table>