Asterisk Open-Source PBX System

Use one system to manage voice over IP and conventional phone lines, manage voice mail and run CGI-like applications for phone users.
The Dialplan

Before getting into the setup of Asterisk, we should have a general understanding of the dialplan. It is flexible and powerful but also can be confusing. The dialplan is used to define number translations and routing and, therefore, is the heart of Asterisk. The dialplan defines contexts, which are containers for extensions (digit patterns) that provide specific functionality. For instance, you may want to provide a context for people who are in your office or home, so that they have certain dialing privileges. You also could set up an external or guest context that allows only limited dialing capabilities, such as no long distance. Context names are enclosed by brackets ([]). The extensions associated with the context follow the name.

Each extension can have several steps (priorities) associated with it. The call flow continues sequentially unless an application returns -1, the call is terminated or the application redirects the call flow. The syntax of an extension entry looks like this:


exten => <exten>,<priority>,<application(args)>

Below are a couple of examples:

exten => 9911,1,Wait(1)
exten => 9911,2,Dial(Zap/1/${EXTEN:1})

An extension is denoted by using exten =>. In this example, 9911 is the extension; 1 and 2 are the priorities or step numbers (these need to be sequential); and Wait and Dial are the applications. Asterisk uses applications to process each step within an extension. You can get help for the different applications from the Asterisk console by typing show applications to list the supported applications and show application <application> to display the help message.

Extension matching can be done on the dialed number as well as the calling number. This allows for greater flexibility when processing calls. Patterns also can be used, and these are preceded with an underscore (_):

  • N—a single digit between 2 and 9.

  • X—a single digit between 0 and 9.

  • [12-4]—any digit within the brackets.

  • . —wild card.

For example, the extension _NXX5551212 would match any information number, regardless of area code.

Extensions can be any alphanumeric string. Some special characters are built-in:

  • s—start here when no dialed digits are received, as from an incoming call from an analog line.

  • t—used when a timeout occurs.

  • i—used for invalid dialed digits.

  • o—operator extension.

  • h—hangup extension.

Creating IAX Users

The first file we create is the iax.conf file (see Listing 2). This file controls the operation of the IAX protocol and defines users of the protocol. The protocol has two versions. The old one is IAX, and the new one is IAX2.

The first section of the configuration file is the general section, which defines parameters for the IAX protocol. Four parameters are listed, but others can be defined as well. The port parameter is the port number over which IAX will communicate. It defaults to 5036, so strictly speaking, that entry is not needed. You can use the bindaddr parameter to tell Asterisk to bind to a particular IP address—for machines with multiple Ethernet cards. A bindaddr of 0.0.0.0 attempts to bind to all IP addresses. The parameters amaflags and accountcode are used for CDRs. When they are defined in the general section, they are used as the default values. You also can define them on a per-user basis. The values that amaflags can accept are billing, documentation, omit and default. accountcode can be an arbitrary value. For this setup, I use home for users local to my LAN and external for users outside of my LAN. Several other parameters have been omitted, but most of them are performance parameters.

The remaining sections are user definitions. I have three users: brett, maria and niko. The type definition has three possible values: a peer can receive calls, a user can place calls and a friend can do both. I have defined all of them as type friend. I defined all of the hosts as being dynamic, but if any host has a static IP address, you can specify that instead. secret is the password the user must provide when connecting to this Asterisk server. Two contexts are used in this file for users: [cg1] and [cg2]. I explain these in more detail when discussing the extensions.conf file, but effectively, these contexts enable the dialing privileges for the user.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

German Book to Asterisk: "Der Weg zu VoIP Asterisk von A bis Z"

Silvio's picture

Buch Bekanntmachung: Der Weg zu VoIP Asterisk von A bis Z

For english see bellow.

Als ich Oktober 2005 angefangen habe mit Asterisk zu arbeiten, gab es nur wenig zusammenhängende Informationen zu Asterisk. Es gab bereits ein Buch zu Asterisk, jedoch wurden dort einige Themen ausgelassen. Auch im neuen Asterisk von Oreilly wird nur Asterisk besprochen, jedoch nicht auf Telefonkarten, VoIP Telefone, Zusatzprogramme eingegangen.

Der Buch Inhalt ist auf die deutschsprachigen Länder, Deutschland, Österreich, Schweiz, bezogen.

Das Buch "Der Weg zu VoIP Asterisk von A bis Z" beschreibt nicht nur Asterisk sondern auch alles Dinge,
welche mit Asterisk verwendet werden können. Hier einige Beispiele aus dem Buchinhalt.

- Einführung in Asterisk
- Benötigte Hardware für Asterisk
- Asterisk installation
-- Das erste Gespräch
-- Echo Call test
-- die sprechende Uhr

- die Konfigurationsdateien
- Sicherheit

- Anrufbeantworter
- Sprachausgabe auf deutsch wechseln
- makeln, weiterleiten
- Music on Hold
- Automatisch weiterleiten

- PSTN(POTS) integration
- ISDN integration

- SIP Telefone
- Sprachcodecs
- Asterisk Konfigurationsprogramme
- Asterisk und Billing
- Rollout in einem Unternehmen
- Alternativen zu Asterisk
- VoIP Protokolle
- ...

Das Buch ist bereits teilweise frei erhältlich im Internet verfügbar.
Die ersten 30 Seiten finden man jetzt schon unter http://www.suvi.org/theory/asterisk.html

Jede Woche, oder beim Verkauf eines Buch Exemplares, wird eine Seite freigegeben. Das Buch wird also Zeit abhängig freigegeben. Zudem unterstützt man mit dem Kauf des Buches die freie Erhältlichkeit des Buches.

Das Buch hat rund 243 Seiten und kann unter https://www.lulu.com/commerce/index.php?fBuyContent=359309 bezogen werden.

Gruss
Silvio

Book announcement: Der Weg zu VoIP Asterisk von A bis Z

First at all: The book is only aviable in the german language. The book does describe Asterisk as well as things that are usefull for Asterisk: VoIP-Telefons, Configuration Software, Billing Software, Telefonycards, ...

The book content is sutiable for the german speaking countries: Germany, Austria and Switzerland.

Parts of the book are allready free avialbe on the internet.
The first 30 pages can be found at http://www.suvi.org/theory/asterisk.html

Everyweek, and if someone buys the book, one page more will be free aviable. With the buy of the book the freedom of the book is supported.

The book has 244 pages and can be bought at https://www.lulu.com/commerce/index.php?fBuyContent=359309

Best Regards
Silvio

Asterisk Connects wtih GoogleTalk

Anonymous's picture

New project is underway to connect GoogleTalk/Jabber with Asterisk. Delivery date and details can be seen here: http://www.networkingpipeline.com/blog/archives/2006/04/asterisk_server....

Faxing with Asterisk using AsterFax

Anonymous's picture

You can also fax with Asterisk using AsterFax which is an email to Fax gateway.

And you plug it in...

Anonymous's picture

...to the Verizon rj11 jack on the wall!
Or you use the magical wireless connectivity available only in the author's town.

Very technical, very specific article. How about a followup that dumbs it down just a bit, such as, you connect the Digium PCI card to your network, this is how much upload speed you'll need per line, you find a voip carrier by looking for this service (sip...) You can/can't have branch offices with the same number and transfer calls across the city/town with call transfer...

I know someone stuck on Vonage's two line SB plan, who is looking for something cheap, where he can migrate his number to something like Broadvoice or some other service, and have one or two (or more) voice lines, plus a fax line like through Vonage. Number portability takes care of the original number, but the technical details on using Asterisk with a carrier to replace Vonage (or Broadvoice which has their own adapters like Vonage, or bring your own adapter) still isn't clear.

What exactly needs to be done to migrate from Vonage Voip to Asterisk, where I can get one voice and one fax (or actually 2 voice lines) which actually has functional call "hunting" for each voice line? Who do I call to order the service, once I have a dedicated box for Asterisk and Digium modems? Unless the cost comes in less than either Vonage for two lines, or Broadvoice or other Voip for multiple single lines, what's the point besides the geek factor? Using call forwarding on busy with multiple single lines, you get all the benefits of all the other services, without worrying about another point of failure in the hardware, a huge UPS for a computer vs. a UPS for a few phone adapters, plus the cost of electricity of running that computer 24/7 every month.

While the technical details are nice, the major part of the story, the connection explanation/possibilities as compared to something like Vonage/Broadvoice so one can fully understand what/why is missing. The technical details would be a nice addition, but I doubt that most post-purchase users are going to use this article for relying on their phone system when the mailing list for Asterisk and the abundant docs online are all available and will be utilized anyway.

Good technical explanation, but the article misses the mark. Thanks for the article anyway.

Asterisk Rapid Installation

Eran's picture

Xorcom has released version 0.9 of Debian and Asterisk auto-installer. It can turn any PC to pre-configured PBX from scratch in a few minutes, and contains lots of extra software and features. It is free and open source.
Asterisk auto-install CD

Eran Gal
Xorcom Ltd
Asterisk Solutions

Re: Asterisk Open-Source PBX System

Anonymous's picture

callerid example is wrong

Should be:

[brett]
type=friend
host=dynamic
secret=brettsecret
context=cg1
callerid="brett"

Re: Asterisk Open-Source PBX System

Anonymous's picture

good catch, although in the context of what I was doing, it wouldn't really have any affect. Technically, I should have had:

callerid="brett"

Re: Asterisk Open-Source PBX System

Anonymous's picture

Or, even more technically correct would be:

callerid="brett"

This sets the CALLERIDNAME variable to brett and the CALLERIDNUM variable to 111 (referencing the whole callerid with CALLERID) if required... (look in Readme.variables for other interesting stuff)

Andy

Re: Asterisk Open-Source PBX System

Anonymous's picture

ok, that didn't work it (it was stripped out...) should be

callerid="brett"

Perhaps you mean...

Anonymous's picture

Do you mean like this?

callerid="brett"<111>

Re: Asterisk Open-Source PBX System

Anonymous's picture

ok, I'm just about to give up on this stupid filtering!

callerid = "brett" less-than-sign 111 greater-than-sign

replace the 'less-than-sign ' with 'shift ,' and greater-than-sign 'shift .'

or look at http://www.automated.it/guidetoasterisk.htm

Andy

Re: Asterisk Open-Source PBX System

Anonymous's picture

right...I think the filtering was messing everyone up...thanks

Re: Asterisk Open-Source PBX System

Anonymous's picture

where is callerid.agi?

cant find it :(

Re: Asterisk Open-Source PBX System

Anonymous's picture

it's on my website: http://www.bschwarz.com/asterisk/

Re: Asterisk Open-Source PBX System

Anonymous's picture

callerid="brett"

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState