Dial Plan
From Bizfon Wiki
Contents |
Edit Dial Plan
The dial plan consists of four components:
- The preference is used to sort the dial plan entries. When the PBX searches a matching entry in the dial plan, it will take the entry with the lowest preference value. You may use the same preference value for several entries; in this case the PBX will pick one of the entries for you.
- The Trunk setting defines which trunk is used for the call. There are three modes for the trunk drop-down menu.
- The first mode simple selects one of the available trunks. In this mode, the call will be sent out through the selected trunk.
- The second mode just denies the call. This mode is used to stop processing the dial plan. This makes it easier to define exceptions of calls that should not be sent out (e.g. some 0800 numbers).
- The third mode sends a call to a registered extension. In this mode, the replacement must contain an extension number. In most cases, you can just "hard code" that extension (e.g. set it to "123"). But you can of course also use the rules for generating a replacement pattern including the \1...\9 replacement strings.
- The pattern setting is matched against the destination of the call. See below for the description of the matching algorithm.
- The replacement is used in the To-header as well as in the Request-URI. See the description below.
Simple Dial Plan
In most of the cases, you can use simple patterns.
- Literals. If you want to match a specific number (e.g. 911), just put that number there. The literal will be the first match in the expression.
- Prefixes. If you want to match a specific prefix, put that prefix there with a star behind it. For example, "9*" would match all numbers that start with a 9. The prefix will not be part of the match, only the string matched by the * will be the match of the first expression.
- Fixed patterns. If you use a "x" in a pattern, the PBX will treat it as a wildcard for 0-9. For example, 978xxxxxxx will match any number with the area code 978.
If you use the simplified expression, you don't have to specify a replacement. The PBX will automatically put a "sip:\1@\r;user=phone" as the replacement. There is also a simplified replacement. If you put a prefix in front of a star, the PBX will insert that prefix before the match. For example, "1*" will put a "1" in front of the match.
Examples:
- Pattern "91*" and replacement "1*": If the input is "919781234567@domain.com", the output will be "19781234567@domain.com"
- Pattern "978xxxxxxx" and no replacement: If the input is "9781234567@domain.com", the output will be "9781234567@domain.com"
- Pattern "911|411" and no replacement: This will match input "911@domain.com" and "411@domain.com".
- Pattern "xxxxxxx" and a replacement of "234xxxxxxx" will insert the area code of 234 to the 7 digit number and input "234xxxxxxx@domain.com"
Regular Expressions Matching
The regular expression matching algorithm is a very flexible algorithm that follows the NAPTR algorithm of RFC 2915. For an exact description, please refer to this document.
The pattern string of the dial plan is surrounded by a "^" and a "$" (to make sure that the whole string is matched". The PBX uses the username and the hostname. The port number, parameters and the scheme are not included for the comparison.
If there is a match, the PBX will generate the resulting destination from the replacement string. The string may include references to matching groups in the pattern string. These matches are referred by the group number (starting with 1). Additionally, the matching string 'r' may be used to insert the registrar name.
Technically, that is the description of the algorithms. The example in the next section will make the algorithms more understandable.
To delete a dial plan entry, just clear the pattern and the replacement and press the Edit button.
Examples
Typical dial plan
A typical example is the string ([0-9]*)@.* as pattern and sip:\1@\r;user=phone as the replacement. The pattern string has one group [0-9]*, which is referred in the replacement string as \1. That means, if the pattern is matched against the value 2121234567@test.com, it will store 2121234567 in the first group and the result will be sip:2121234567@test.com;user=phone (the user=phone indicates the recipient that the number is a telephone number).
A very simple dial plan
In many cases, you just want to route all numbers that start with a “9” to an outside trunk. This can be done easily just by using the pattern “9*”; you don’t need to fill anything into the replacement field (the PBX does that automatically).
Dial plan with prefix in front of the number
If you use a pattern like “1*” in the replacement field, the PBX will automatically put a “1” in front of the match which it found in the pattern field. In the case when you use the pattern “9*” and dial the number 92121234567, the PBX will automatically convert that into a 12121234567.
A dial plan sample for North America
If you use the PBX in the fixed-length dial pal of North America, you may use a dial plan like the one below.
The first pattern matches the emergency number and the service number explicitly and sends it to the local gateway. It is a good idea to have an entry for these important numbers, so that they don’t accidentally get routed to the wrong gateway.
The second pattern matches all international numbers and sends them to a special trunk, which is supposed to save you costs for international calls.
The third pattern deals with all domestic calls. We use the fixed-length pattern here, to that the PBX can actually tell when this number is complete.
You could add another pattern like 91978xxxxxxx and send those calls to another trunk if you have negotiated a flat rate with your local PSTN service provider.
Sending star codes on a trunk
In this case you need to fall back to the good old extended regular expressions:
The pattern matches pattern that start with a star symbol followed by any number of digits. The replacement then inserts the star again and puts the dialled number behind the star. Alternatively, you could include the star symbol in the match group of the pattern and then you would not have to put the star in the replacement.




