System information
Calls from the VoIP network will arrive in the dialplan in whatever context you assigned
to the incoming SIP channels, and the dialplan will relay the calls out through the PSTN
interface. At its very simplest, a portion of a dialplan that supports termination could
look like this:
[from-voip-network]
exten => _X.,1,Verbose(2, Call from VoIP network to ${EXTEN})
same => n,Dial(DAHDI/g0/${EXTEN})
In reality, though, you will often have to handle a more complex routing plan that takes
into consideration things like geography, corporate policy, cost, available resources,
and so forth.
Given that most PSTN circuits will allow you to dial any number, any-
where 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 termination. 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.
PSTN Origination
Obviously, if you want to pass calls from your VoIP network to the PSTN, 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.
In order to provide origination, a phone number is required. You will therefore need
to obtain a circuit from your local phone company, which you will connect to your
Asterisk system. Depending on where you are in the world, there are several different
types of circuits that could provide this functionality, from a basic analog POTS line to
a carrier-grade SS7 circuit.
Phone numbers as used for the purpose of origination are commonly
called direct inward dialing numbers (DIDs). This is not strictly the case
in all situations (for example, the phone number on a traditional analog
line would not be considered a DID), but the term is useful enough that
it has caught on. Historically, a DID referred to a phone number asso-
ciated with a trunk connected to customer premise equipment (CPE).
Since phone numbers are controlled by the traditional telecom industry, you will need
to obtain the number either from a carrier directly, or from one of the many companies
that purchase numbers in bulk and resell them in smaller blocks. If you obtain a circuit
VoIP | 145