text
stringlengths
0
152
some sort of PSTN interfaces), in practice you’re more likely to use an Internet
Telephony Service Provider (ITSP, also sometimes called a VoIP carrier) to terminate
your phone calls. ITSPs typically have a massive investment in infrastructure, and
you’d be hard-pressed to do better without spending a ton of money. ITSPs have
made termination inexpensive, so it’s tough to make a business case for doing it
yourself.
If you really need to connect your Asterisk system directly to the PSTN, you’ll need
the following:
• Appropriate circuit(s) from a PSTN telco (analog, BRI, PRI, SS7, MFC/R2, etc.)
• Suitable hardware to connect to that circuit (FXO, BRI, T1, E1, etc.)
• Echo cancellation (hardware or software)
• The skills necessary to properly configure your equipment for the carrier you’re
dealing with (there are many flavors of each of these circuit types, and this can be
difficult to get right even for those who know the technology well)13
Beyond that, you will often have to handle a far more complex routing logic, which
takes into consideration things like geography, corporate policy, cost, available resour‐
ces, and so forth.
13 Trust us, Jim Van Meggelen worked with this stuff for many years before getting into VoIP.
VoIP
|
119
In order to send your calls to an ITSP, your dialplan needs to look something like this:
; NANP-based systems
[to-pstn] ; Yes, we're going through an ITSP, but the PSTN is our destination
exten => _1NXXNXXXXXX.,1,Dial(${TOLL}/${EXTEN}) ; Country code plus phone number
; Add a '1' and send
exten => _NXXNXXXXXX.,1,Dial(${LOCAL}/1${EXTEN}) ; Country code plus phone number
; Strip off the '011' and send
exten => _011X.,1,Dial(${TOLL}/${EXTEN:3}) ; Country code plus phone number
; Emergency dialing
exten => 911,1,Dial(${LOCAL}/911) ; Defining this will require info from your carrier
; Most of the rest of the world
[to-pstn]
; Strip off NDD prefix, add country code, and send
exten => _0X.,1,Dial(${TOLL}/<add your country code here>${EXTEN:1})
; Strip off IDD prefix and send
exten => _00X,1,Dial(${LOCAL}/${EXTEN:2}) ; Country code plus phone number
; Emergency dialing (and other services)
exten => 11X,1,Dial(${LOCAL}/${EXTEN}) ; Defining this will require info from your carrier
Given that most PSTN circuits will allow you to dial any number,
anywhere in the world, and given that you will be expected to pay
for all incurred charges, we cannot stress enough the importance of
security on any gateway machine that is providing PSTN termina‐
tion. Criminals put a lot of effort into cracking phone systems
(especially poorly secured Asterisk systems), and if you do not pay
careful attention to all aspects of security, you will be the victim of
toll fraud. It’s only a matter of time.
Do not allow any unsecured VoIP connections into any context that
contains PSTN termination.
Termination will tend to be more complex than we’ve outlined here—even if you’re
using an ITSP as your carrier—but the basic concept is fairly straightforward: match a
pattern that your users might dial, prepare it for the carrier by removing or adding
necessary digits, and send the call out the appropriate PJSIP endpoint (trunk). We’ve
only discussed the dialplan here; in a later section we’ll discuss how to configure the
SIP trunks to carry this traffic.
PSTN origination
You might also want to be able to accept calls from the PSTN into your VoIP network.
The process of doing this is commonly referred to as origination. This simply means
that the call originated in the PSTN (Figure 7-5).
120
|
Chapter 7: Outside Connectivity
Figure 7-5. PSTN origination
In order to provide origination, a phone number is required.
In the good old days, when VoIP and Asterisk were new, it was quite common for
people to handle the circuit connection to the PSTN themselves, using analog or digi‐
tal trunks provided by the local phone company. For the most part this type of con‐
nection is now handled by ITSPs, and you simply need to connect your system to
your VoIP carrier across a SIP trunk.
Phone numbers—when used for the purpose of origination—are commonly called