text
stringlengths
0
152
context to be dialable.
When we include other contexts within our current context, we have to be mindful of
the order in which we are including them. Asterisk will first try to match the dialed
extension in the current context. If unsuccessful, it will then try the first included
context (including any contexts included in that context), and then continue to the
other included contexts in the order in which they were included.
We will discuss the include directive more in Chapter 7.
Conclusion
And there you have it—a basic but functional dialplan. There is still much we have
not covered, but you’ve got all of the fundamentals. In the following chapters, we’ll
continue to build on this foundation.
If parts of this dialplan don’t make sense, you may want to go back and reread a sec‐
tion or two before continuing on to the next chapter. It’s imperative that you under‐
stand these principles and how to apply them, as the next chapters build on this
information.
106
|
Chapter 6: Dialplan Basics
CHAPTER 7
Outside Connectivity
You cannot always control what goes on outside. But you can always control what goes on
inside.
—Wayne Dyer
In the previous chapters, we have covered a lot of important information that is
essential to a working Asterisk system. However, we have yet to discuss something
that is vital to any useful PBX: namely, connecting it to the outside world. In this
chapter we will discuss outside connectivity.
The groundbreaking architecture of Asterisk was significant due in large part to the
fact that it treats all channel types as equal. This is in contrast to a traditional PBX,
where trunks (which connect to the outside world) and extensions (which connect to
users and resources) are logically separated. The fact that the Asterisk dialplan treats
all channels in a similar manner means that in an Asterisk system you can accom‐
plish very easily things that are much more difficult (or impossible) to achieve on a
traditional PBX.
This flexibility does come with a price, however. Since the system does not inherently
know the difference between an internal resource (such as a telephone set) and an
external resource (such as a telco circuit), it is up to you to ensure that your dialplan
handles each type of resource appropriately.
The Basics of Trunking
The purpose of trunking is to provide a shared connection between two entities. Trees
have trunks, and everything that passes between the roots and the leaves happens
through the trunk. Railroads use the term “trunk” to refer to a major line that con‐
nects feeder lines together.
107
In telecommunications, trunking connects two systems together. Carriers use trunks
to connect their networks to each other. In a PBX, the circuits that connect the PBX
to the outside world are (from the perspective of the PBX) usually referred to as
trunks (although the carriers themselves do not generally consider these to be
trunks). From a technical perspective, the definition of a trunk is not as clear as it
used to be (PBX trunks used totally different technology from station circuits, but
now both are usually SIP), but as a concept, trunks are still important. With SIP,
everything is technically peer-to-peer, so from a technology perspective there isn’t
really such a thing as a trunk anymore (or perhaps it’s more accurate to say that
everything is a trunk). From a functional perspective it is still useful to be able to dif‐
ferentiate between VoIP resources that connect to the outside world (trunks, lines,
circuits, etc.) and VoIP resources that connect to user endpoints (stations, sets, exten‐
sions, handsets, telephones, etc.).
In an Asterisk PBX, you might have trunks that go to your VoIP provider for in-
country long-distance calls, trunks for your overseas calls, and trunks that connect
your various offices together. These trunks might actually run across the same net‐
work connection, but in your dialplan you could treat them quite differently. You can
even have a trunk in Asterisk that simply loops back in on itself (which is usually
some kludgy hack that solves some namespace or CDR problem that wasn’t getting
solved any other way).
Fundamental Dialplan for Outside Connectivity
In a traditional PBX, external lines are generally accessed by way of an access code
that must be dialed before the number.1 It is common to use the digit 9 for this
purpose.
In Asterisk, it is similarly possible to assign 9 for routing of external calls, but since
the Asterisk dialplan is so much more intelligent, it is not really necessary to force
your users to dial 9 before placing a call. Typically, you will have an extension range
for your system (say, 100–199), and a feature code range (*00 to *99). Anything out‐
side those ranges that matches the dialing pattern for your country or region can be
treated as an external call.
If you have one carrier providing all of your external routing, you can handle your
external dialing through a few simple pattern matches. The example in this section is
valid for the North American Numbering Plan (NANP). If your country is not within
the NANP (which serves Canada, the US, and many Caribbean countries), you will
need a different pattern match.