System information
such as a PRI circuit, you will normally be able to order DID numbers to be delivered
with that circuit.
In order to accept a call from a circuit you are using for origination, you will normally
need to handle the passing of the phone number that was called. This is because PSTN
trunks can typically handle more than one phone number, and thus the carrier needs
to identify which number was called so that your Asterisk system will know how to
route the call. The number that was dialed is commonly referred to as the Dialed Num-
ber Identification Service (DNIS) number. The DNIS number and the DID do not have
to match,
‖
but typically they will. If you are ordering a circuit from the carrier, you will
want to ask that they send the DNIS (if they don’t understand that, you may want to
consider another carrier).
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]
; This is the context that would be listed in the config file
; for the circuit (i.e. chan_dahdi.conf)
exten => _X.,1,Verbose(2,Incoming call to ${EXTEN})
same => n,Goto(number-mapping,${EXTEN},1)
[number-mapping]
; This context is not strictly required, but will make it easier
; to keep track of your DIDs in a single location in your dialplan.
; From here you can pass the call to another part of the dialplan
; where the actual dialplan work will take place.
exten => 4165551234,1,Dial(SIP/0000FFFF0001)
exten => 4165554321,1,Goto(autoattendant-context,start,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 invalid
numbers to reception, or to an automated attendant, or to some context that plays an
invalid prompt).
‖ 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 as the DID digits, rather than the number that was dialed (the DNIS
number). 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 translation 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 is
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.
146 | Chapter 7: Outside Connectivity