text
stringlengths
0
152
DIDs (Direct Inward Dialing numbers). Your carrier will send a call down the circuit
to your system, and pass the DID (or special received digits in some cases14), which
the Asterisk dialplan will interpret. In other words, you will need a dialplan context
that accepts incoming calls from your carrier, with extensions or patterns that will
correlate to your DIDs.
In order to accept a call from a VoIP circuit, you will need to handle the digits the
carrier will send you (the DID or phone number). The DNIS number and the DID do
not have to match, but typically they will. In days gone by, the carrier would usually
ask you in what format you wish to receive the digits. Nowadays, a VoIP carrier will
14 In traditional PBXs, the purpose of DIDs was to allow connection directly to an extension in the office. Many
PBXs could not support concepts such as number translation or flexible digit lengths, and thus the carrier had
to pass the extension number, rather than the number that was dialed (which was also referred to as the DNIS
number, from Directory Number Information Service). For example, the phone number 416-555-1234 might
have been mapped to extension 100, and thus the carrier would have sent the digits 100 to the PBX instead of
the DNIS of 4165551234. If you ever replace an old PBX with an Asterisk system, you may find this transla‐
tion in place, and you’ll need to obtain a list of mappings between the numbers that the caller dials and the
numbers that are sent to the PBX. It was also common to see the carrier only pass the last four digits of the
DNIS number, which the PBX then translates into an internal number. With VoIP trunks this will seldom be
the case, but be aware that it is possible.
VoIP
|
121
typically tell you what format they will send, and you are expected to accommodate.
Two common formats are: DNIS (which is essentially the digits of the DID that was
called) or E.164, which means that they’ll be including the country code with the
number.
In the dialplan, you associate the incoming circuit with a context that will know how
to handle the incoming digits. As an example, it could look something like this:
[from-pstn]
exten => 4165550100,1,Goto(sets,100,1)
exten => 4165550101,1,Goto(sets,101,1)
exten => 4165550102,1,Goto(sets,102,1)
exten => 4165550103,1,Goto(sets,103,1)
exten => 4165554321,1,Goto(main-menu,${EXTEN},1)
exten => 4165559876,1,VoiceMailMain() ; a handy back door for listening
; to voice messages
exten => i,1,Verbose(2,Incoming call to invalid number)
In the number-mapping context, you explicitly list all of the DIDs that you expect to
handle, plus an invalid handler for any DIDs that are not listed (you could send inva‐
lid numbers to reception, or to an automated attendant, or to some context that plays
an invalid prompt).
Now we’re ready to discuss how to configure trunks to carry your external traffic.
Configuring SIP Trunks
SIP is far and away the most popular of the VoIP protocols—so much so that the
terms VoIP and SIP have almost come to mean the same thing. In previous editions
of this book, we’ve looked at some of the other protocols that were popular at the time
(primarily IAX2 and H.323), but for this edition there’s no real reason anymore to
discuss anything but SIP. The channel drivers for those older protocols are still avail‐
able in Asterisk, but they’re no longer supported.
The SIP protocol is peer-to-peer and does not really have a formal trunk specifica‐
tion. This means that whether you are connecting a single phone to your server or
connecting two servers together, the SIP connections will be similar. Having said that,
there are some differences in the style of how these resources can be configured, and
there will definitely be a difference in how your dialplan handles routing across
trunks.
Connecting an Asterisk system to a SIP provider
It is quite common to use the same ITSP carrier for termination and origination, but
be aware that the two processes are unrelated to each other. If calls going in one
direction pass your testing, that doesn’t mean calls in the other direction are OK. If
you change configuration, test routing both in and out, every time.
122
|
Chapter 7: Outside Connectivity
Many carriers will provide sample configurations for Asterisk. Unfortunately, these
documents generally refer to the older chan_sip driver, which has been deprecated.
Digium has designed a PJSIP wizard that is intended to greatly simplify carrier con‐
figuration. You can still configure ITSP trunks using the exact same methods we’ve
shown before for configuring other endpoints (creating records in ps_endpoint,
ps_aors, ps_auths, and so forth), but rather than hash over all that again, we are
going to take a look at the wizard, since it consolidates several components into a sin‐
gle configuration file. We have found that since user endpoints change often, and car‐
rier endpoints seldom do, it’s often useful to configure carriers in a configuration file
rather than in the database.
Before any config can be created, however, it’s important to determine how the carrier
will interact with your system. There are two fundamental models we have seen:
Password-based authentication, including registration15
This is common in smaller carriers focused on the small-business market. This is