Dial patterns are a central element in the configuration of FreePBX or Asterisk telephone systems. They are used to precisely define how dialed telephone numbers should be handled before they are forwarded via a trunk. They determine not only which numbers are allowed, but also how these numbers are adapted or rewritten—for example, by automatically adding a country code or removing a pre-dialed digit.
Think of dial patterns as a kind of "filter" or "set of rules" that examines each dialed number and then decides what can be done with it. For example, when a user dials a number, the system first checks whether that number matches a defined dial pattern. If so, the call is forwarded via the appropriate route or trunk. If not, the call is blocked or receives an error message.
The use of dial patterns is extremely versatile. In practice, they are often used to control which number ranges can be dialed – for example, national landline numbers, mobile numbers, emergency numbers, or international destinations. This can prevent employees from calling expensive premium numbers or from making unwanted international calls.
Another purpose is to transform or supplement phone numbers before they are sent outward. A typical example: A user dials a mobile number without a country code—for example, 01761234567
. The system can automatically add the international dialing code +49 to this number, so that it arrives at the provider as +491761234567
.
Dial patterns also make it possible to route different call destinations over different lines – for example, to save costs or use alternative providers. For example, all international calls could be routed over a cheaper SIP trunk, while domestic calls would be routed over the default provider.
In addition to control and convenience, dial patterns also contribute to security, as they allow you to specifically restrict access to certain phone numbers. Last but not least, they simplify users' everyday lives because they don't always have to dial full international formats—the system automatically fills in what's missing.
A dial pattern essentially consists of three to four components that together determine whether and how a dialed number should be processed. The most important part is the so-called match pattern – the actual number pattern that describes which number sequences are permitted. Wildcards can be used to respond flexibly to different number sequences. For example, an X
represents any digit between 0 and 9, while a Z
only allows the digits 1 to 9. Such wildcards can be used to represent, for example, all mobile phone numbers, all special numbers, or specific area codes.
Prefix and Prepend are two additional fields that determine how dialed digits are handled:
0
to get an outside line—the system deletes this 0
and only sends the actual number out.Optionally, you can specify a CallerID field to apply dial patterns only to specific internal subscribers or groups. For example, you can configure it so that only certain extensions are allowed to make international calls.
In FreePBX and Asterisk, dial patterns are used to define which phone numbers are allowed and how they are processed. Wildcards are used to make patterns flexible. Here are the most important characters and fields, explained in simple terms:
X
3XX
allows all numbers from 300
to 399
.Z
0
.ZXX
matches 123
, 987
, but not 023
.N
0
or 1
.NXX
allows 200
, 345
, but not 012
.[ ]
(Number set)[1237-9]
steht für die Ziffern 1, 2, 3, 7, 8 und 9.[1237-9]
represents the digits 1, 2, 3, 7, 8, and 9..
(Point)0Z.
allows all numbers that begin with a 0
followed by 1–9 and then contain further digits—for example, 0301234567
.Match Pattern
01[5-7]X.
allows all mobile numbers beginning with 015
, 016
, or 017
.Prefix
901761234567
, und der Prefix ist 9
, dann wird die 9
entfernt – und die weitergeleitete Nummer ist 01761234567
.901761234567
and the prefix is 9
, the 9
is removed, and the forwarded number is 01761234567
.Prepend
+49
is set as the prepend and a user dials 1761234567
, it becomes +491761234567
.When a number is dialed, the system compares it as follows:
Dialing number = Prefix
+ Match Pattern
Actual forwarded number = Prepend
+ (Match Pattern
without prefix)
An example:
+49
0
1[5-7]X.
01761234567
0
is removed, the pattern matches 1761234567
,+49
is prefixed+491761234567
This mechanism makes dial patterns a very powerful tool. They ensure that calls only go to authorized and technically correct destinations—regardless of how the user originally enters the number.