System information

Context names have a maximum length of 79 characters (80 characters
– 1 terminating null).
All of the instructions placed after a context definition are part of that context, until
the next context is defined. At the beginning of the dialplan, there are two special
contexts named [general] and [globals]. The [general] section contains a list of gen-
eral dialplan settings (which you’ll probably never have to worry about), and we will
discuss the [globals] context in the section “Global variables” on page 123. For now,
it’s just important to know that these two labels are not really contexts. Avoid the use
of [general], [default], and [globals] as context names, but otherwise name your
contexts anything you wish.
When you define a channel (which is not done in the extensions.conf file, but rather in
files such as sip.conf, iax.conf, chan_dahdi.conf, etc.), one of the required parameters
in each channel definition is context. The context is the point in the dialplan where
connections from that channel will begin. The context setting for the channel is how you
plug the channel into the dialplan. Figure 6-1 illustrates the relationship between chan-
nel configuration files and contexts in the dialplan.
Figure 6-1. Relation between channel configuration files and contexts in the dialplan
This is one of the most important concepts to understand when dealing
with channels and dialplans. Once you understand the relationship of
the context definition in a channel to the matching context in the
dialplan, you will find it much easier to troubleshoot the call flow
through an Asterisk system.
An important use of contexts (perhaps the most important use) is to provide security.
By using contexts correctly, you can give certain callers access to features (such as long-
distance calling) that aren’t made available to others. If you do not design your dialplan
carefully, you may inadvertently allow others to fraudulently use your system. Please
keep this in mind as you build your Asterisk system; there are many bots on the Internet
that were specifically written to identify and exploit poorly secured Asterisk systems.
Dialplan Syntax | 109