Asterisk is probably the most popular open source VOIP PBX solution.
Recently the number of Asterisk
users has been increasing dramatically. FreeSwitch also grows in
popularity and is used in pretty large deployments.
Asterisk isthe open source IP PBX developed by
Mark
Spencer. Provides voicemail, conferencing, interactive voice modules
and call distribution among its basic features. There are several
important open source projects based on Asterisk. Among them
FreePBX Web GUI for Asterisk
Trixbox. Trixbox is pretty
polished Linux distribution based on CentOS (current version uses
CentOS 5.3) which comes with Asterisk and several additional software
packages creating a PBX appliance. Among additional applications:
FreePBX (Web GUI),
Flash Operator Panel,
Sugar CRM (Contact Management),
MySQL (database server)
A2biling (calling card platform)
AsteriskNow. Less polished then Trixbox. Generally uses the
same components.
AsteriskNow LiveCD. Still not convinced or do not have an
extra PC to try Asterisk? No problem! With “AsteriskNow LiveCD” you
can run Asterisk without formatting or loosing your files and operating
system currently installed in your PC. Just boot your PC with the “AsteriskNow
LiveCD” and Asterisk will run with no installation tasks needed.
Several sites such as
voip-info.org provides
configuration guides, tutorials, forums and some interesting pieces
of source codes which you can implement in your Asterisk server at no cost.
Site http://www.nerdvittles.com/
provides step by step tutorials and a list or very interesting list of 100
projects for beginners and advanced users.
Before starting, you will need to install some dependencies required to build the Asterisk server. You can install all of them
using the following command:
Once all the packages are installed, you will need to install DAHDI to communicate Asterisk with analog and digital telephones.
First, download the latest version of DAHDI to the /opt directory:
cd /opt
git clone -b next git://git.asterisk.org/dahdi/linux dahdi-linux
Next, change the directory to the downloaded directory and compile it using the following command:
cd dahdi-linux
make
make install
Next, download the DAHDI tools with the following command:
cd /opt
git clone -b next git://git.asterisk.org/dahdi/tools dahdi-tools
Once the download is completed, configure and install it with the following command:
cd dahdi-tools
autoreconf -i
./configure
make install
make install-config
dahdi_genconf modules
Next, download the LibPRI to communicate Asterisk with ISDN connections.
git clone https://gerrit.asterisk.org/libpri libpri
cd libpri
Next, install it using the following command:
make
make install
Once all the necessary tools are installed, you can proceed to install Asterisk.
Install Asterisk
By default, the Asterisk package is not included in the Ubuntu 20.04 default repository. So you will need to download and compile
it from the source. You can download it from the Git Hub using the following command:
Next, you will need to select the modules that you want to install with Asterisk. You can select it using the following command:
make menuselect
You can use the Arrow key to navigate and Enter key to select the modules.
Select and enables the Addons as shown below:
Next, enable the Core sound modules:
Next,
enable the additional MOH packages:
Next,
enable the Extra Sound Packages:
Now, click on the Save and Exit button.
Next, build the Asterisk using the following command:
make -j2
Next, Asterisk and its modules using the following command:
make install
You should get the following output:
+---- Asterisk Installation Complete -------+
+ +
+ YOU MUST READ THE SECURITY DOCUMENT +
+ +
+ Asterisk has successfully been installed. +
+ If you would like to install the sample +
+ configuration files (overwriting any +
+ existing config files), run: +
+ +
+ For generic reference documentation: +
+ make samples +
+ +
+ For a sample basic PBX: +
+ make basic-pbx +
+ +
+ +
+----------------- or ---------------------+
+ +
+ You can go ahead and install the asterisk +
+ program documentation now or later run: +
+ +
+ make progdocs +
+ +
+ **Note** This requires that you have +
+ doxygen installed on your local system +
+-------------------------------------------+
You can also install the documentation and basic PBX config files with the following command:
make samples
make basic-pbx
Next, install the Asterisk init script with the following command:
make config
Next, update the shared libraries using the following command:
ldconfig
Create Asterisk User
It is always recommended to run Asterisk as a standalone user for security reasons.
First, create a new Asterisk user with the following command:
At this point, Asterisk is installed and configured. Now, you can start the Asterisk service using the following command:
systemctl start asterisk
You can also enable the Asterisk service to start at system reboot with the following command:
systemctl enable asterisk
To check the status of the Asterisk service, run the following command:
systemctl status asterisk
You should get the following output:
â -- asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/init.d/asterisk; generated)
Active: active (running) since Sun 2021-05-16 12:24:29 UTC; 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 60668 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
Tasks: 46 (limit: 4691)
Memory: 34.7M
CGroup: /system.slice/asterisk.service
â""â"€60685 /usr/sbin/asterisk -U asterisk -G asterisk
May 16 12:24:29 ubuntu2004 systemd[1]: Starting LSB: Asterisk PBX...
May 16 12:24:29 ubuntu2004 asterisk[60668]: * Starting Asterisk PBX: asterisk
May 16 12:24:29 ubuntu2004 asterisk[60668]: ...done.
May 16 12:24:29 ubuntu2004 systemd[1]: Started LSB: Asterisk PBX.
Now, connect to the Asterisk command line utility with the following command:
asterisk -vvvr
Once connected, you should get the following output:
Asterisk GIT-18-78d7862463, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk GIT-18-78d7862463 currently running on ubuntu2004 (pid = 60685)
ubuntu2004*CLI>
Congratulations! You have successfully installed and configured Asterisk server on Ubuntu 20.04 VPS.
Of course, you don't have to install and set up Asterisk if you use one of our
Managed VPS Hosting services, in which case you can
simply ask our expert Linux admins to install Asterisk on Ubuntu 20.04, for you. They are available 24Ã -- 7 and will take care of
your request immediately. If you're looking to find something else, such as
how to install Magento
or Elasticsearch on
Ubuntu 20.04, check out our blog.
If you liked this post on how to install Asterisk on Ubuntu 20.04, please share it with your friends on the social networks using
the buttons on the left or simply leave a reply below. Thanks.
How to configure an Asterisk dialplan for intra-office calling
Learn how to configure Asterisk to let two softphones call each other.
Posted January 21, 2020
|
by
Anthony Critelli
Image
"Telephone - Amalgamated Wireless of Australasia, 300 CBT, circa 1940"
is licensed under
CC
BY 4.0
In the
previous article
, you learned how to
configure the PJSIP channel driver to connect a simple softphone client with your Asterisk
installation. However, your phones still can't call each other, and you haven't given them numerical
"extensions" yet. Connecting channels together in Asterisk is the work of the dialplan. In this
article, you'll learn the basics of the dialplan: What it is, how it's configured, and how to use it
to connect phones together.
As a reminder, this is the setup we're configuring:
The Asterisk
dialplan
is responsible for routing calls, so it is often referred to as the
heart of an Asterisk system. The dialplan is written in a special scripting language, and it is
extremely powerful. You might think of phone systems as simply accepting and connecting calls, but
Asterisk is capable of much more. With the dialplan, you can design rich, voice-driven applications.
For example, you could create the following call flow for a small business:
An external call comes into Asterisk from a standard telephone number.
An
Interactive Voice Response (IVR)
system might ask the user to enter basic
information, such as their account number.
Asterisk accepts the user's input. The IVR looks up their account and presents them with
information (e.g., information about outstanding invoices).
Optionally, the user can be routed to a
queue
of available customer service
representatives. When the employee receives the customer's call, the system provides them with all
of the customer's details and saves the caller some time.
While there are other programming interfaces for interacting with Asterisk, the dialplan is the
most basic, and understanding it is fundamental to understanding how Asterisk handles calls. According
to
Asterisk the
Definitive Guide
, there are four fundamental components to the Asterisk dialplan:
Contexts:
A
context
is a logical section in the dialplan. Contexts
contain one or more
extensions
.
Extensions:
An
extension
is simply a grouping of steps used to handle
a particular call. Unlike many traditional phone systems, extensions don't have to be numerical and
they aren't tied to a single device. You could have an extension called "mainIVR" if you wanted.
Priorities:
A
priority
is a step in an extension. Priorities handle
ordering, and they can also have labels attached to them so that a call can jump between priorities
as needed.
Applications:
Applications are a lot like functions in traditional programming
languages. They tell Asterisk
what
to do with a call. For example, you might have an
internal extension of *86. When *86 is dialed, you might have Asterisk play a message of the day
using the
Playback application
.
If you're new to Asterisk, this breakdown probably sounds complicated. While Asterisk dialplans
certainly can be complex, a simple phone system only requires a simple dialplan. Let's take a look at
the dialplan needed to support your intra-office calling scenario. The dialplan is configured in
/etc/asterisk/extensions.conf
:
The snippet above is all that is necessary to allow your two phones to call each other. Let's step
through each part of this dialplan:
office-phones
is the context. This context contains two extensions.
1001
and
1002
are the extensions. Notice how this setup decouples the
numbers from the phones themselves. While these numbers are currently hardcoded to dial Alice's and
Bob's phones, they could just as easily be used for more complex routing (e.g., automatically roll
over to an overnight line during certain hours).
The
1
after the extension is the priority. Remember, a priority is just a step in
extension handling. The first priority is always
1
. In this example, each extension
only has a single priority.
Dial
is the application. The
Dial
application
is used to ring a remote device. Dialing occurs via SIP or other signaling
protocols (if you need a refresher on VoIP protocols, head over to our [first article]).
[Note: Don't forget to add the link.]
To recap:
When a call comes into the
office-phones
context, Asterisk
tries matching that call to an extension. When extension 1001 is dialed, the first step (priority)
tells Asterisk to dial the PJSIP endpoint for Alice's phone. When extension 1002 is dialed, the same
thing happens for Bob's phone.
This is great so far, but how exactly does a call make its way
into
the dialplan? The
answer lies in the PJSIP endpoint configuration from the previous article:
Notice that the context for each phone is set to
office-phones
. This setting tells
Asterisk that any calls coming from the
alice-softphone
or
bob-softphone
endpoints should enter the dialplan in the
office-phones
context. When Bob dials a number
(say, 9000) from his softphone, Asterisk looks in the
office-phones
context for the
matching extension 9000. In the sample dialplan above, this call will fail because there is no
matching extension.
You don't have to configure all of your phones to enter the dialplan in the same context. In fact,
you'll likely find good reasons to specifically put phones in other contexts. Consider a business that
wants to only allow certain people to make international calls, while everyone else is restricted to
local calls. You might have two extensions: One to allow unrestricted calling, and one that only
allows calls to numbers that start with the local area code. Those with international calling
privileges would be placed in the
international
context, while everyone else would be
placed in the
local-only
context.
That was a lot of theory. Let's get back to the command line and test out the changes that we made
to the dialplan. First, you must non-disruptively
reload
the dialplan to enact the
changes you made in the config file:
Next, you can inspect the dialplan directly from the Asterisk CLI to ensure that your changes are
present:
asterisk-1*CLI> dialplan show office-phones
[ Context 'office-phones' created by 'pbx_config' ]
'1001' => 1. Dial(PJSIP/alice-softphone) [extensions.conf:3]
'1002' => 1. Dial(PJSIP/bob-softphone) [extensions.conf:5]
-= 2 extensions (2 priorities) in 1 context. =-
Notice that Asterisk includes the exact file name and line number where an extension and its
priority can be found. This information is useful when troubleshooting behavior in your phone system.
With the dialplan reloaded and your changes clearly in place, you should be able to place a test
call from Linphone (or whatever SIP endpoint you're using). First, launch the Asterisk CLI with extra
verbosity using
asterisk -rvvv
:
[root@asterisk-1 asterisk]# asterisk -rvvv
Asterisk 16.6.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 16.6.1 currently running on asterisk-1 (pid = 4138)
Next, place a call from Alice's phone to extension 1002. Assuming that you registered an additional
softphone (or physical phone) for Bob, the extension should show as
ringing
:
Image
The Asterisk CLI also prints informational messages about the call's progression since it was set
to verbose mode. You can see the inbound call being handled by the dialplan and handed off to the
PJSIP channel driver to dial Bob's softphone. Eventually, once Bob answers, Asterisk bridges the audio
for the call together so that both parties can hear each other:
== Setting global variable 'SIPDOMAIN' to 'asterisk-1.acritelli.com'
-- Executing [1002@office-phones:1] Dial("PJSIP/alice-softphone-00000008", "PJSIP/bob-softphone") in new stack
-- Called PJSIP/bob-softphone
-- PJSIP/bob-softphone-00000009 is ringing
-- PJSIP/bob-softphone-00000009 is ringing
-- PJSIP/bob-softphone-00000009 answered PJSIP/alice-softphone-00000008
-- Channel PJSIP/bob-softphone-00000009 joined 'simple_bridge' basic-bridge <edd9402c-6df0-4fff-a81e-57826dadc652>
-- Channel PJSIP/alice-softphone-00000008 joined 'simple_bridge' basic-bridge <edd9402c-6df0-4fff-a81e-57826dadc652>
-- Channel PJSIP/bob-softphone-00000009 left 'native_rtp' basic-bridge <edd9402c-6df0-4fff-a81e-57826dadc652>
-- Channel PJSIP/alice-softphone-00000008 left 'native_rtp' basic-bridge <edd9402c-6df0-4fff-a81e-57826dadc652>
== Spawn extension (office-phones, 1002, 1) exited non-zero on 'PJSIP/alice-softphone-00000008'
asterisk-1*CLI>
You have now created enough Asterisk configuration to allow both of your phones to call each other.
Congratulations!
Adding another extension
You've now seen basic dialplan configuration that allows two phones to call each other. I also
mentioned a few times that Asterisk decouples the concept of a physical phone from an extension
because an extension is simply a set of instructions in the dialplan. Let's add another simple
extension to the dialplan to see exactly what I mean:
[office-phones]
exten => 1001,1,Dial(PJSIP/alice-softphone)
exten => 1002,1,Dial(PJSIP/bob-softphone)
exten => 9000,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()
The above configuration adds an additional extension (9000) to the dialplan. When this extension is
dialed, Asterisk:
Answers the call.
Plays a
hello-world
file. This is a sound file included with Asterisk. By default,
Asterisk searches for sounds in
/usr/lib/asterisk/sounds/
.
Hangs up the call.
Notice the use of the
same => n
syntax. This is a common and helpful bit of syntactic
sugar in the dialplan. Remember that each extension has one or more
priorities
, or steps,
associated with it. The
same => n
syntax saves you some typing and tells Asterisk that
this step is just the next priority for the same extension. The above configuration could also be
written as:
With your new configuration in place, reload the dialplan and try dialing extension 9000 to see
what happens. Again, the key concept to understand is that you have created an extension that has no
physical device associated with it. Asterisk fully decouples the concept of devices and extensions.
Wrapping up
In this article, you learned about the Asterisk dialplan and wrote enough dialplan configuration to
enable two phones to call each other. The Asterisk dialplan is extremely powerful, allowing you to
build rich communications applications. I strongly recommend that you check out the official
Asterisk dialplan
documentation
and the fifth edition of
Asterisk: The Definitive Guide
to help you better
understand everything that the dialplan has to offer.
In the [next article], you'll work on connecting your phone system to an external provider to
enable inbound and outbound calling.
[Note: Don't forget to add the link.]
Topics:
Networking
VOIP
Anthony Critelli
Anthony Critelli is a Linux systems engineer with interests in automation, containerization,
tracing, and performance. He started his professional career as a network engineer and
eventually made the switch to the Linux systems side of IT. He holds a B.S. and an M.S.
More about me
a
p
d
v
EoA
b
QCFY
y
YNDC
U
P
dtacP
a
aDju
e
UuZ
s
mhNd
s
IC
l
w
e
cAOm
r
x
ss
A
rfap
G
NkAPl
Which tools are used for monitoring the
network traffic and issue in an enterprise network?
You can use any
number of
tools to monitor
your company's network. Some of
these tools specialize in just one thing. Wireshark, for example,
records and analyzes data traffic.
Co...
(Continue Reading)
You dismissed this ad.
The feedback you provide will help us show you more relevant content in the future.
Undo
Answer Wiki
6 Answers
Terry Lambert
,
Did kernel and Bluetooth stack work on the iPhone, cell
modems on Chromebooks
Answered Mar 28, 2019
·
Author has
11.7k
answers and
33.3m
answer views
Yes.
A landline
is an analog telephony line, and is usually called a POTS (
Plain
Old Telephone Service
) line.
You can put
an analog telephony card into a PC that has slots for cards.
This is
pretty much how you build your own PBX using
Asterisk
.
You can also
use digital telephony cards to provide connectivity for VOIP
handsets within your office.
Typically
these handsets are what are known as "IP Phones".
If you want
to do this with a laptop, you can do it with a USB dongle.
You can
still find USB interfaces "voice modems", such as the US
Robotics USR5637 56K USB Controller Dial-Up External Fax Mo...
A
landline is an analog telephony line, and is usually called
a POTS (
Plain Old Telephone Service
) line.
You can
put an analog telephony card into a PC that has slots for
cards.
This is
pretty much how you build your own PBX using
Asterisk
.
You can
also use digital telephony cards to provide connectivity for
VOIP handsets within your office.
Typically
these handsets are what are known as "IP Phones".
If you
want to do this with a laptop, you can do it with a USB
dongle.
You can
still find USB interfaces "voice modems", such as the US
Robotics USR5637 56K USB Controller Dial-Up External Fax
Modem with Voice available for sale at various locations.
There are
also cheaper versions, but they are a crap shoot as to
whether they're going to work very well or not. The Conexant
ones, which are used in the Imported520 products are about
1/6th the price of the US Robotics, and tend to have good
reviews. I've never personally use one.
4.9k views
·
View 4 Upvoters
·
View Sharers
·
Answer requested by
Alberto Bucciante
Related Questions
More
Answers Below
Dean Rubine
Former Faculty at Carnegie
Mellon School Of Computer
Science
1991-1994
Studied at Carnegie Mellon
University
Graduated
1991
Lives in New Hampshire
4.5m content views
224.9k
this month
Top
Writer
2018
Active in
4 Spaces
Dean Rubine
Former Faculty at Carnegie
Mellon School Of Computer
Science
1991-1994
Studied at Carnegie Mellon
University
Graduated
1991
Lives in New Hampshire
4.5m content views
224.9k
this month
Top
Writer
2018
Active
in 4 Spaces
Dean Rubine
,
former Faculty at Carnegie Mellon School Of Computer Science
(1991-1994)
Answered Mar 27, 2019
·
Author has
4k
answers
and
4.5m
answer views
You
certainly used to be able to back in the nineties. Back then
computers usually came with RJ11 jacks to plug them into the
phone network so you could access dialup services, even dialup
internet. Some of the modems evolved into general phone
devices, supporting two way voice audio as well as data.
I actually
won a computer in 1993; it was an ASUS with Windows 3.11 if I
recall, which was subtitled "Windows for Multimedia" or some
such. It had a telephone app (we called them programs back
then) that let you use the computer as a speakerphone and
answering machine. I think it used the then n...
You
certainly used to be able to back in the nineties. Back then
computers usually came with RJ11 jacks to plug them into the
phone network so you could access dialup services, even
dialup internet. Some of the modems evolved into general
phone devices, supporting two way voice audio as well as
data.
I
actually won a computer in 1993; it was an ASUS with Windows
3.11 if I recall, which was subtitled "Windows for
Multimedia" or some such. It had a telephone app (we called
them programs back then) that let you use the computer as a
speakerphone and answering machine. I think it used the then
new TAPI API to control it.
The prize
computer has this very goofy feature where it would actually
boot up when the phone rang, presumably to fire up the
answering machine and take a message. But it took a good
fraction of a minute to boot; any caller had long hung up.
These
days if you want to use your computer as a phone it's
generally a VOIP thing like Skype, going out over the
internet to some server which can access the regular phone
network. But some offices have VOIP with a local PBX
connected to shared local POTS (Plain Old Telephone Service)
lines right in the office.
You need
to find the right device to let you do it these days. You
can probably find a TAPI modem with USB on one end and RJ11
on the other and some software to make it work. I haven't
tried it for 25 years so I won't try to be more specific.
2.6k views
You've
described what a Reverse ATA is and does, approximately. I've
seen this question here on Quora before. Such devices used to
exist. You could put together a solution that does this today,
at a little cost and some effort.
You're
better off ditching your landline and using Skype or a VoIP
service.
If it's for
an elderly person or someone with hearing loss ot a disability,
get a seniors phone or a seniors video phone.
1.2k views
·
Answer requested by
Alberto Bucciante
Chris Summers
,
Worked in cellphone sales and service for 5 years, computer
also for 15 years.
Answered May 24, 2019
·
Author has
7.9k
answers
and
5m
answer views
PCs use to
come with a 56k modem that did just that. You could still do
that either by getting a card for a tower or by a USB adapter.
There are several programs out there that will also work with
this set to use the line as your telephone and you could use a
headset with a mic to use the computer as your telephone too.
You would need to look on a site like Newegg or tigerdirect for
the cards or adapters.
1.3k views
·
Answer requested by
Alberto Bucciante
Studied at Universidad De León
Lives in Bristol, UK
Alberto Bucciante
Related Questions
More
Answers Below
It used to
be called CTI (Computer Telephony Integration) and you could do
things like get your PC to dial numbers from a database, or
automatically recognise incoming calls and display the contact
record for the caller.
There was a
software standard called TAPI (Telephony Application
Programmers Interface) that standardised the software/hardware
interaction, although it suffered from quite bad fragmentation
in different manufacturers.
This kind of
technology has largely been replaced or superseded by VOIP, so
it may be tricky to find hardware or software that still talks
...
It used
to be called CTI (Computer Telephony Integration) and you
could do things like get your PC to dial numbers from a
database, or automatically recognise incoming calls and
display the contact record for the caller.
There was
a software standard called TAPI (Telephony Application
Programmers Interface) that standardised the
software/hardware interaction, although it suffered from
quite bad fragmentation in different manufacturers.
This kind
of technology has largely been replaced or superseded by
VOIP, so it may be tricky to find hardware or software that
still talks to good old fashioned landlines now.
However, if
you're open to suggestions, I'd recommend small landline
extension devices that connect directly to phone. They come
with a simple but functional headset with mic. You just need to
connect t...
However,
if you're open to suggestions, I'd recommend small landline
extension devices that connect directly to phone. They come
with a simple but functional headset with mic. You just need
to connect the small dialpad unit to the handset slot of
your phone, plug the headset into the dialpad unit and
you're done. This setup is not prone to software crashes,
incompatibilities or performance issues yet they allow you
to make and answer phone calls easily while leaving your
hands free.
Been more
than 20 years since I've used one so I'm not sure about the
availability.
Learn how to set up Asterisk so your softphones can receive incoming calls from outside and make outgoing
calls outside your organization as well.
Posted January 23, 2020
|
by
Anthony Critelli
Image
"Telephone Pole"
by
Fried
Dough
is licensed under
CC
PDM 1.0
In two previous articles, you learned how to configure
two SIP phones
and the
Asterisk dialplan
to enable the phones to
call each other. Having two phones that can call each other is great, but most organizations want to
connect their phone system to the
public switched
telephone network (PSTN)
to allow for inbound and outbound calling to others outside of the
organization. In this article, you will learn some background about how to connect to the PSTN and you
will see the Asterisk configuration needed for this connectivity.
Note:
I've mentioned
it several times throughout this series, but it is especially important for this article to understand
how to secure your phone system. Connecting to a telephony provider can open you up to all sorts of
issues, such as toll fraud, if you aren't careful about controlling who can connect to your phone system
(e.g., via firewall rules). Be sure to read the
README-SERIOUSLY.bestpractices.md
documentation that comes with the Asterisk source code and understand every piece of configuration that
you add to Asterisk.
Connecting to the PSTN
Obtaining a telephone number and connecting your phone system to the PSTN might sound like a difficult
task, but it's actually pretty easy. Larger organizations may choose to use a local telecommunications
provider or their local Internet company, but there are also a variety of online providers available
(e.g.,
Twilio
and
VoIP.ms
, among many others). I will be using VoIP.ms for
the phone numbers in this article.
No matter who you choose, the process is fairly straightforward. You will buy a phone number (often
called a direct inward dial, or DID), and you'll configure your phone system to connect with the
provider's phone system via SIP. This setup is often referred to as a
SIP trunk
. The process of
configuring your phone system to work with your chosen provider can vary, so it's always best to consult
the provider's documentation or work with their voice engineers if you run into trouble.
Let's take a look at the general best practices for configuring your phone service. These are not
comprehensive, but they should provide a base of sound advice when working with your provider:
Obtain the provider's endpoint IP (or IPs) and heavily restrict SIP and RTP communication to only
those IP addresses. Some providers also support only allowing your account to connect from a specified
list of IPs.
Ensure that your SIP connection minimally uses a username and password for security. If your
provider supports mutual TLS authentication, investigate that option as well.
Don't sign up for features that you do not need. If you won't be placing international calls, then
don't sign up for international calling. Doing this lessens your attack surface if your phone system
is ever breached. Toll fraud can be costly. You can avoid the risk of expensive international calls by
opting out of international calling.
Investigate the fraud detection and prevention options that your provider has available. Some
providers can immediately alert you if they detect any suspicious phone calls being placed from your
account.
PJSIP configuration
The first step in configuring PSTN connectivity is to define the SIP configuration necessary for
Asterisk to communicate with the IP telephony provider. This information will vary a bit by provider, but
many of them provide information about the parameters that you need (VoIP.ms actually provides
Asterisk-specific instructions
):
Image
In my case, the configuration in
/etc/asterisk/pjsip.conf
looks like this:
Most of this configuration probably
looks
familiar
, but this configuration does introduce two new PJSIP section types: a
registration
and an
identify
. The
registration
section tells Asterisk to explicitly register
with the upstream voice provider's server. The
identify
section tells Asterisk that SIP
traffic coming from
newyork1.voip.ms
should match the
voipms
endpoint.
After reloading PJSIP, I can see that my local Asterisk server successfully registered with the
provider's SIP infrastructure. Note that issues during this stage of the process are fairly common, and
you may need to work with your provider to understand what "they see" so that you can effectively
troubleshoot:
Next, Asterisk has to be told what to do with incoming and outgoing calls. Incoming and outgoing calls
in Asterisk aren't fancy, they are just extensions in the dialplan like any other extension. I will
discuss incoming calls first. Like any programming language, it's important to understand what your goals
are before you start writing code. In my case, I wanted a dialplan that would:
Answer an inbound call from the DID that I purchased from my provider.
Allow the user to enter an extension (one for Alice, two for Bob).
Call the appropriate user once the extension was dialed.
Notice that in the above PJSIP configuration, I am using the
inbound-calls
context for
calls from my SIP provider. Here's what that context looks like in
/etc/asterisk/extensions.conf
:
[inbound-calls]
exten => 1234567890,1,Answer()
same => n,Playback(hello)
same => n,WaitExten(30)
same => n,Hangup()
exten => 1,1,Answer()
same => n,Dial(PJSIP/alice-softphone)
exten => 2,1,Answer()
same => n,Dial(PJSIP/bob-softphone)
Notice that I replaced my real DID with the fake 1234567890 for privacy reasons. You will want to use
your real DID if you are following along. Also, notice that my phone number follows a United States
numbering convention (a three-digit area code followed by a seven-digit number).
Let's step through this contents of this configuration together:
When my DID is called, Asterisk matches the 1234567890 extension. It answers the call.
Asterisk then plays a built-in "hello" message. In a real environment, you might want to record
your own prompts for Asterisk to use.
Asterisk then calls the
WaitExten
application
with a value of 30. This value tells Asterisk to wait up to 30 seconds for the user to
enter an extension.
Assuming the user enters an extension of "1" or "2", the dialplan will jump to that extension.
Notice that the "1" extension will call Alice's softphone, and the "2" extension will call Bob's
softphone.
Once the above configuration is in place, you can reload the dialplan and place a test call to your
PSTN phone number. You should hear Asterisk say "hello," and you should be able to dial one of the
extensions and have the phone on the other end ring.
Outbound dialplan configuration
Being able to place inbound calls is great, but most businesses expect outbound calling functionality
as well. Luckily, this is fairly easy to configure.
First, recall from the previous article about intra-office calling that outbound calls for Alice and
Bob's phones enter the dialplan in the
office-phones
context. Therefore, we need a way to
match all outbound calls in this context and send them to the upstream provider.
Until now, you've seen extensions configured as exact matches. Extension 1001 matches and dials Alice,
extension 1002 matches and dials Bob, and the extension for your inbound DID matches and allows the
caller to input a selection. It would obviously be impractical to match every single possible outbound
number that a user might dial. Thankfully, Asterisk provides a way to perform
pattern matching.
To provide outbound calling for American numbers -- e.g., (123) 456-7890 -- my
office-phones
context looks like this:
[office-phones]
exten => 1001,1,Dial(PJSIP/alice-softphone)
exten => 1002,1,Dial(PJSIP/bob-softphone)
exten => 9000,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()
exten => _XXXXXXXXXX,1,Set(CALLERID(all)="Anthony Critelli <1234567890>")
same => n,Dial(PJSIP/${EXTEN}@voipms)
If you already took a look at the Asterisk wiki's linked pattern matching documentation, this syntax
will look familiar. The outbound extension matches
_XXXXXXXXXX
, which is a fancy way of
saying: "Match a sequence of 10 digits." The underscore indicates that this character is the beginning of
a pattern match, similar to the use of the forward-slash (/) in many programming languages to indicate
the use of a regular expression. Therefore, this extension will match any 10-digit extension that I send
to it, such as standard 10-digit US phone numbers. A more complete example would also account for country
codes, local calling, and other considerations. That is an exercise left up to the reader.
The first priority in this extension sets the
CALLERID
to a string of my choosing. You
should replace the name and number with your own name and DID. This practice also introduces another
concept in the Asterisk dialplan: The use of variables. In the configuration above, both
CALLERID
and
EXTEN
are variables that you have available to manipulate.
The second, and final, priority in the extension simply sends the call to the upstream provider via
the PJSIP channel driver. This syntax is pretty straightforward, and it looks a lot like the dialplan
that you already wrote to allow two phones to call each other.
With this configuration in place, you can reload your dialplan and try placing a test outbound call
from Alice or Bob's phone. Assuming that everything went well, your call should succeed.
Wrapping up
If you've stuck with me from
the
beginning
, then you have successfully implemented a basic phone system using the open source Asterisk
PBX. You've come a long way. From understanding VoIP and Asterisk basics to installing and configuring
Asterisk from scratch, you should now have an idea of how to configure a simple phone system. Minimally,
I hope this series has sparked your interest in learning more about telephony and Asterisk.
If you want to continue your VoIP and Asterisk journey, then I recommend that you check out these
resources:
Videos from
AstriCon
, the Asterisk Users Conference, may help to spark some ideas about telephony projects.
The
Wireshark
packet analysis tool has a
trove of utilities
for analyzing
phone calls. These include call ladders, traffic analysis, and even media playback.
Finally, if you are interested in understanding the fundamental protocols that support VoIP
networks, you should review the
IETF RFCs
for a
technical deep-dive. There are tons of VoIP-related RFCs, but the SIP, SDP, and RTP/RTCP RFCs are good
starting points.
Digium's point of view is a very dangerous one. The thing is
that Asterisk is pretty crappy software (pieces mysteriously break
than start working again in the next release, it's happened to me
a few times) but the third party service
and software ecosystem around it are better than anything else.
Digium has to realize this and do anything to keep third party
developers and maintainers happy. If not, they won't stand a chance
in future competition from big brands above as well as from smaller
projects such as freeswitch below.
xxx:
Quick comment: this isn't just a "Digium thing" in the way upgrades
work; this is typically how software development goes in all organizations.
Major version number changes mean API changes. That's just how the
world works. If you couldn't change an API, then you wouldn't be
able to grow and expand the feature set in the software, or sometimes
even fix bugs, or increase reliability and scalability.
I have not heard about any fixed date or time frame for EOL'ing
Asterisk 1.4. Since a lot of people are still running 1.2, I would
imagine 1.4 will be with us for a long time yet (certainly more
than a year).
The 1.6 branch has come out, is in beta mode, and I'm not sure
what all the hubbub is about in third party incompatibilities. All
major version upgrades are going to have things change in them that
you couldn't otherwise do, and thus third party applications are
going to need to keep pace - and it's not like you HAVE to run 1.6
in production (in fact, you shouldn't… it's not even out of beta
yet).
In addition, the 1.6 branch is going to use a different release
methodology, which is really the main reason a 1.6 beta is even
out in the first place. This does not indicate 1.4 is going EOL
anytime soon. Digium's Business Edition C.1.x software was only
released around January, and I doubt there is any rush to deprecate
that piece of work.
You're probably going to have 1.4 and 1.6 in lockstep for quite
some time. The difference between 1.4 and 1.6 is quite a bit less
than the difference between 1.2 and 1.4. The reason for 1.6 is that
since you CAN'T just release software every year and EOL the existing
software, then that means you have to wait 2+ years before you can
even start using the new features. Some people can't wait that long,
so you have two paths available to you now. 1.6 will allow new features
to go in at each minor version release (this means 1.6.x, where
'x' is the minor version, and 6 is the major version - this is significant).
So now we have two different methodologies.
A branch that only receives bug fixes and security fixes (1.4),
and a branch that receives bug fixes, security fixes, and is allowed
to implement new features (this follows the same time of release
strategy as the Linux kernel - this is not a new concept). Digium
has now also started using release candidates before creating a
new release (as per the communities request), so you have the ability
to test for any bugs that may have been introduced before the full
released is put out for public consumption.
If you need to run 1.4, then go ahead, nothing is going to stop
you from doing that, and it's not going away anytime soon. If you
need the latest and greatest, or there is some new feature you absolutely
must run in production, then you can run a 1.6 machine (when it
stabilizes and comes out of beta and release candidate status) with
just the feature you absolutely need in a stripped down version,
or after extensive testing, then you could put it into production.
I personally think Digium is doing the "Right Thing(tm)" here
and giving us choice, and isn't that what this is all about?
stavros:
Despite the extra work it creates, I'm with Digium on this. It's
often impossible to add flexibility or improve performance whilst
maintaining API compatibility. The reason for the majority of API
changes is to address short-sighted decisions in the original design;
backwards compatibilty enforces perpetuation of the poor choice
and a clean break must be made at some point. The re-plumbing work
to which Jared refers is long overdue and, as he intimates, is necessary
to provide the enterprise-grade platform for which you are all clamouring.
Whilst a simple upgrade tool for syntax in extensions.{conf|ael}
might save a few folks a few minutes, I don't think that's where
the bulk of this problem lies. We'd all love to have tool to automatically
fix all the AGI/AMI code out there, written in PHP, Perl, C, etc,
but it's impossible to do algorithmically. That said, I believe
it would be possible to add a compatibility shim to PHPAGI, for
instance, to allow most if not all existing PHP AGI scripts to run
without modification.
The suggestion that Digium are responsible for fixing everyone
else's code is simply ludicrous. As Jared explained, many of the
devs can't legally touch much of the code that will need to be fixed.
Even if they could I doubt they'd want to; fixing code with which
you're not familiar is fraught with difficulties. It's even less
appealing when you consider that much AGI code is crufty nonsense
written by amateurs. The logical conclusion of this argument is
that Microsoft must be similarly charged with fixing every third-party
application broken by a service pack, and the Linux/glibc folks
must cease scheduled development and spend the rest of eternity
fixing all the userspace regressions just assigned to them by downstream!
I'm not sure how you reached your conclusion that Digium have
their head in the sand based on Jared's response. You had the opportunity
to shape the development of the areas of v1.6 which displease you.
I'm afraid it was you with your head in the sand, ignorant of all
the work happening in public view for all to see, discuss and even
influence. If Digium's track-record with Asterisk v1.2 is anything
to go by, you've a long time yet before v1.4 will be unmaintained.
There's plenty of time to adapt and to test before you need
to look at using v1.6 in production.
Please stop criticising the Asterisk devs for doing necessary
work. You may not see it, but they do have our best interests
in mind. The benefits of a more maintainable, better architected
and more consistent Asterisk codebase far outweigh any short-term
heartache during the transition.
[WM: There's a significant difference in saying that "Digium
[is] responsible for fixing everyone else's code" and saying that
"Digium has responsibility for not breaking everyone else's code."
If you reread the article, I think you'll find that I suggested
the latter. As for a conversion utility saving a few folks a few
minutes, I've spent the better part of six months cleaning up the
carnage in dozens of applications that was directly caused by the
needless syntax obsolescence imposed in Asterisk 1.4. And for what?
I provided a good example in the article that broke virtually every
dialplan. Suggesting that such changes were necessary to "improve
the engine" is pure B.S. Funny you'd mention Microsoft. I wrote
a shareware database management system (WAMPUM)
in 1985 for DOS that still runs just fine under Windows XP and Vista.
In fact, I regularly hear from folks that still are using
it… almost two decades later! Maybe that's the reason Microsoft
is still around while Lotus 1-2-3 (that owned 95% of the spreadsheet
market at one point) is now just a blip in the history books.
If you recall, Lotus developers came up with the brilliant
idea to change much of 1-2-3's spreadsheet syntax. It gave everyone
the perfect opportunity to switch to Excel.]
If you have a need to have multiple PBX systems running and you want
them all to make and receive calls, you will run into a major problem
with that because of NAT issues and port forwarding limitations. In
this article, I will explain how to use a
trixbox CE system as a front-end gateway that will manage
the trunks to the SIP providers and forward calls to the different PBX
systems as well as allow the PBX systems to dial out through the trixbox
CE system.
Besides testing different PBX platforms like I do, why
might you want to do a setup like this? There are several reasons I
can think of:
Single VoIP provider to service multiple companies at a single
location each with their own PBX system
Setting up separate PBX systems for different departments
Having a single media gateway that serves multiple locations
(over a VPN)
Test systems for development
Temporary setup during migration from one system to another.
While this is only showing a SIP provider to multiple PBX's, the
concept can also be applied to a SIP trunk coming into the gateway and
then a PRI connection to a legacy PBX that doesn't support SIP trunks,
thus allowing a non-IP PBX system to use VoIP trunks.
We won't go into the setup of the actual SIP trunk into the trixbox
CE (FreePBX) system as that is dependant upon the provider and should
be pretty straightforward. What we will need to do is create trunks
from the other PBX systems into the trixbox CE box in order to route
calls
Dot5Hosting:
Home and commercial users can tap a VoIP system into Dot5Hosting, as
this company's servers are linked to the Internet via fiber-optic connections
that span more than seven diverse backbones and well-known providers
such as Congent, So net and Time Warner. Their systems include a high
power UPS generator electrical backup, closed circuit monitoring and
redundant air-conditioning systems. But that's not the only redundancy
they boast - they utilize Dell and IBM servers which run Dual Intel
Xeon processors with 2GB of DDR-RAM and SCSI hard drives with RAID-1
redundancy. Current packages start at $3.95 per month.
We provide VoIP service to business customers and do so with asterisk,
we have load balanced dell servers with P4 2.8Ghz HT processors and
during peak usage each node is handling around 100-120 concurrent calls
with almost no load.
so as others have said, you don't need much in the way of hardware,
figure 30Mhz of CPU per call.
For many businesses, open source VoIP programs and apps offer a great
way to save thousands of dollars every year in telephony costs. Better
yet, open source programs are fully customizable to a business' specific
needs, making them a popular solution that often just can't be beat.
This popularity hasn't just helped business, but has also driven many
open source programs to the forefront of their industry. In fact, it
has
been speculated that open source VoIP solutions could surpass the
popularity of the ubiquitous desktop solution Linux. Here are a few
of the open source programs and developers out there that have had loads
of success as VoIP and open source solutions for it become more and
more common in businesses around the world.
The Last but not LeastTechnology is dominated by
two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt.
Ph.D
FAIR USE NOTICEThis site contains
copyrighted material the use of which has not always been specifically
authorized by the copyright owner. We are making such material available
to advance understanding of computer science, IT technology, economic, scientific, and social
issues. We believe this constitutes a 'fair use' of any such
copyrighted material as provided by section 107 of the US Copyright Law according to which
such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free)
site written by people for whom English is not a native language. Grammar and spelling errors should
be expected. The site contain some broken links as it develops like a living tree...
You can use PayPal to to buy a cup of coffee for authors
of this site
Disclaimer:
The statements, views and opinions presented on this web page are those of the author (or
referenced source) and are
not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society.We do not warrant the correctness
of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be
tracked by Google please disable Javascript for this site. This site is perfectly usable without
Javascript.