Tải bản đầy đủ (.pdf) (845 trang)

asterisk the definitive guide, 4th edition

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (16.36 MB, 845 trang )

www.it-ebooks.info
www.it-ebooks.info
Russell Bryant, Leif Madsen, and Jim Van Meggelen
FOURTH EDITION
Asterisk™: The Definitive Guide
www.it-ebooks.info
Asterisk™: The Definitive Guide, Fourth Edition
by Russell Bryant, Leif Madsen, and Jim Van Meggelen
Copyright © 2013 Russell Bryant, Leif Madsen, and Jim Van Meggelen. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (). For more information, contact our corporate/
institutional sales department: 800-998-9938 or
Editors: Mike Loukides and Nathan Jepson
Production Editor: Kristen Borg
Copyeditor: Becca Freed
Proofreader: Kiel Van Horn
Indexer: Fred Brown
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Rebecca Demarest
May 2013:
Fourth Edition
Revision History for the Fourth Edition:
2013-05-07: First release
See for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. Asterisk: The Definitive Guide, the image of a starfish, and related trade dress are trademarks of
O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as


trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
ISBN: 978-1-449-33242-6
[LSI]
www.it-ebooks.info
Table of Contents
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
1.
A Telephony Revolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Asterisk and VoIP: Bridging the Gap Between Traditional and Network
Telephony 2
The Zapata Telephony Project 2
Massive Change Requires Flexible Technology 3
Asterisk: The Hacker’s PBX 4
Asterisk: The Professional’s PBX 5
The Asterisk Community 5
The Asterisk Mailing Lists 6
Asterisk Wiki Sites 7
The IRC Channels 7
Asterisk User Groups 7
The Asterisk Documentation Project 8
The Business Case 8
Conclusion 8
2.
Asterisk Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Modules 10

Applications 12
Bridging Modules 15
Call Detail Recording Modules 16
Channel Event Logging Modules 17
Channel Drivers 17
Codec Translators 18
Format Interpreters 19
Dialplan Functions 20
iii
www.it-ebooks.info
PBX Modules 22
Resource Modules 22
Add-on Modules 26
Test Modules 27
File Structure 27
Configuration Files 27
Modules 27
The Resource Library 28
The Spool 28
Logging 28
The Dialplan 28
Hardware 29
Asterisk Versioning 29
Previous Release Methodologies 30
The Current Release Methodology 31
Simplifying the Version Numbers 32
Conclusion 33
3. Installing Asterisk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Installation Cheat Sheet 37
Distribution Installation 41

RHEL Server 41
Ubuntu Server 45
Software Dependencies 49
Downloading What You Need 50
Getting the Source via Subversion 51
Getting the Source via wget 51
How to Install It 52
DAHDI 52
LibPRI 54
Asterisk 55
Setting File Permissions 56
Base Configuration 56
Initial Configuration 56
make menuselect 64
Updating Asterisk 70
Common Issues 72
-bash: wget: command not found 73
configure: error: no acceptable C compiler found in $PATH 73
make: gcc: command not found 73
configure: error: C++ preprocessor “/lib/cpp” fails sanity check 73
iv | Table of Contents
www.it-ebooks.info
configure: error: *** Please install GNU make. It is required to build
Asterisk! 73
configure: *** XML documentation will not be available because the
‘libxml2’ development package is missing. 74
configure: error: *** termcap support not found 74
You do not appear to have the sources for the 2.6.18-164.6.1.el5 kernel
installed. 74
E: Unable to lock the administration directory (/var/lib/dpkg/), are you

root? 74
Upgrading Asterisk 74
Conclusion 76
4. Initial Configuration Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
asterisk.conf 77
The [directories] Section 77
The [options] Section 78
The [files] Section 82
The [compat] Section 82
modules.conf 83
The [modules] Section 84
indications.conf 84
musiconhold.conf 86
Converting Music to a Format That Works Best with Asterisk 87
Default musiconhold.conf file 89
Additional Configuration Files 91
Conclusion 91
5.
User Device Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Telephone Naming Concepts 94
Hardphones, Softphones, and ATAs 96
Configuring Asterisk 98
How Channel Configuration Files Work with the Dialplan 99
sip.conf 101
iax.conf 107
Modifying Your Channel Configuration Files for Your Environment 112
Digium Phones with Asterisk 113
Loading Your New Channel Configurations 113
The Asterisk CLI 113
Testing to Ensure Your Devices Have Registered 114

Analog Phones 115
A Basic Dialplan to Test Your Devices 118
Under the Hood: Your First Call 119
Table of Contents | v
www.it-ebooks.info
Conclusion 120
6. Dialplan Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Dialplan Syntax 121
Contexts 122
Extensions 124
Priorities 125
Applications 127
The Answer(), Playback(), and Hangup() Applications 128
A Simple Dialplan 129
Hello World 129
Building an Interactive Dialplan 131
The Goto(), Background(), and WaitExten() Applications 131
Handling Invalid Entries and Timeouts 133
Using the Dial() Application 134
Using Variables 137
Pattern Matching 140
Includes 145
Conclusion 145
7.
Outside Connectivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
The Basics of Trunking 147
Fundamental Dialplan for Outside Connectivity 148
PSTN Circuits 150
Traditional PSTN Trunks 150
Installing PSTN Trunks 152

VoIP 161
Coping with Network Address Translation 161
PSTN Termination 170
PSTN Origination 171
VoIP to VoIP 173
Configuring VoIP Trunks 173
Emergency Dialing 181
Conclusion 183
8.
Voicemail. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Comedian Mail 185
The [general] Section 186
The [zonemessages] Section 195
The Contexts Section 196
An Initial voicemail.conf File 200
Standard Voicemail KeyMap 201
vi | Table of Contents
www.it-ebooks.info
Dialplan Integration 201
The V
oiceMail() Dialplan Application 201
The VoiceMailMain() Dialplan Application 204
Creating a Dial-by-Name Directory 205
Using a Jitterbuffer 205
Storage Backends 206
Linux Filesystem 206
ODBC 207
IMAP 207
Using Asterisk as a Standalone Voicemail Server 208
Integrating Asterisk into a SIP Environment as a Standalone

Voicemail Server 208
SMDI (Simplified Message Desk Interface) 212
Database Integration 213
Conclusion 213
9. Internationalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Devices External to the Asterisk Ser
ver 217
PSTN Connectivity, DAHDI, Digium Cards, and Analog Phones 219
DAHDI Drivers 221
Asterisk 224
Caller ID 224
Language and/or Accent of Prompts 225
Time/Date Stamps and Pronunciation 226
Conclusion—Easy Reference Cheat Sheet 228
10. Deeper into the Dialplan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Expressions and V
ariable Manipulation 231
Basic Expressions 231
Operators 232
Dialplan Functions 234
Syntax 235
Examples of Dialplan Functions 235
Conditional Branching 236
The GotoIf() Application 236
Time-Based Conditional Branching with GotoIfTime() 240
Macros 242
Defining Macros 243
Calling Macros from the Dialplan 244
Using Arguments in Macros 245
GoSub 246

Defining Subroutines 246
Table of Contents | vii
www.it-ebooks.info
Calling Subroutines from the Dialplan 247
Using Arguments in Subroutines 248
Returning from a Subroutine 249
Local Channels 250
Using the Asterisk Database (AstDB) 253
Storing Data in the AstDB 254
Retrieving Data from the AstDB 254
Deleting Data from the AstDB 254
Using the AstDB in the Dialplan 255
Creating a Hot-Desking Application with AstDB 256
Handy Asterisk Features 261
Zapateller() 261
Call Parking 261
Conferencing with MeetMe() 263
Conferencing with ConfBridge() 264
Conclusion 266
11. Parking, Paging, and Conferencing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
features.conf 267
The [general] section 268
The [featuremap] Section 271
The [applicationmap] Section 272
Application Map Grouping 275
Parking Lots 276
Overhead and “Underchin” Paging (a.k.a. Public Address) 277
Places to Send Your Pages 278
Zone Paging 284
Advanced Conferencing 284

The [general] Section 285
Options for User Profiles 285
Options for Bridge Profiles 287
ConfBridge Menu Options 289
Enabling a PIN 290
Waiting for the Marked User to Join 292
Using ConfBridge() Menus 293
Enabling Videoconferencing 296
Conclusion 298
12.
Internet Call Routing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
DNS and SIP URIs 300
The SIP URI 300
SRV Records 301
viii | Table of Contents
www.it-ebooks.info
Accepting Calls to Your System 302
Dialing SIP URIs from Asterisk 309
ENUM and E.164 310
E.164 and the ITU 310
ENUM 311
Asterisk and ENUM 312
ISN, ITAD, and freenum.org 313
Got ISN? 314
ITAD Subscriber Numbers (ISNs) 315
Management of Internet Numbering 315
IP Telephony Administrative Domains (ITADs) 316
Create a DNS Entry for Your ITAD 317
Testing Your ITAD 318
Using ISNs in Your Asterisk System 318

Security and Identity 320
Toll Fraud 321
Spam over Internet Telephony (SPIT) 322
Distributed Denial of Service Attacks 323
Phishing 323
Security Is an Ongoing Process 323
Conclusion 323
13.
Automatic Call Distribution (ACD) Queues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Creating a Simple ACD Queue 326
Queue Members 331
Controlling Queue Members via the CLI 331
Defining Queue Members in the queues.conf File 333
Controlling Queue Members with Dialplan Logic 333
Automatically Logging Into and Out of Multiple Queues 335
An Introduction to Device State 339
The queues.conf File 341
The agents.conf File 349
Advanced Queues 351
Priority Queue (Queue Weighting) 351
Queue Member Priority 353
Changing Penalties Dynamically (queuerules.conf) 354
Announcement Control 356
Overflow 361
Using Local Channels 363
Queue Statistics: The queue_log File 367
Table of Contents | ix
www.it-ebooks.info
Conclusion 370
14. Device States. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

Device States 371
Checking Device States 372
Extension States 373
Hints 374
Checking Extension States 375
SIP Presence 376
Asterisk Configuration 376
Using Custom Device States 378
An Example 378
Distributed Device States 380
Using Corosync 380
Using XMPP 385
Shared Line Appearances 389
Installing the SLA Applications 389
Configuration Overview 390
Key System Example with Analog Trunks 390
Key System Example with SIP Trunks 394
Alternate Key System Example with SIP Trunks 396
Shared Extension Example 399
Additional Configuration 401
Limitations 402
Creating a Callback Service 403
Conclusion 405
15.
The Automated Attendant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
An Auto Attendant Is Not an IVR 407
Designing Your Auto Attendant 408
The Greeting 409
The Main Menu 410
Timeout 411

Invalid 411
Dial by Extension 412
Building Your Auto Attendant 412
Recording Prompts 412
The Dialplan 414
Delivering Incoming Calls to the Auto Attendant 416
IVR 416
x | Table of Contents
www.it-ebooks.info
Conclusion 416
16. Relational Database Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Installing and Configuring PostgreSQL and MySQL 418
Installing PostgreSQL for RHEL 418
Installing PostgreSQL for Ubuntu 418
Installing MySQL for RHEL 419
Installing MySQL for Ubuntu 419
Configuring PostgreSQL 419
Configuring MySQL 421
Installing and Configuring ODBC 422
Configuring ODBC for PostgreSQL 424
Configuring ODBC for MySQL 425
Configuring ODBC for Microsoft SQL 426
Validating the ODBC Connector 427
Compiling the ODBC Modules for Asterisk 428
Configuring res_odbc to Allow Asterisk to Connect Through ODBC 428
Managing Databases 429
Troubleshooting Database Issues 430
SQL Injection 430
Powering Your Dialplan with func_odbc 431
A Gentle Introduction to func_odbc 432

Getting Funky with func_odbc: Hot-Desking 433
Using Realtime 449
Static Realtime 450
Dynamic Realtime 453
Storing Call Detail Records (CDR) 458
ODBC Voicemail Message Storage 463
Compiling the app_voicemail Module to Support ODBC Storage 464
Creating the Large Object Type for PostgreSQL 465
ODBC Voicemail Storage Table Layout 467
Configuring voicemail.conf for ODBC Storage 468
Testing ODBC Voice Message Storage 469
Database Integration of ACD Queues 473
Storing queues.conf in a Database 473
Storing Dialplan Parameters for a Queue in a Database 476
Writing queue_log to Database 477
Conclusion 478
17.
Interactive Voice Response. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
What Is IVR? 479
Components of an IVR 480
Table of Contents | xi
www.it-ebooks.info
IVR Design Considerations 482
Asterisk Modules for Building IVRs 483
CURL 483
func_odbc 483
AGI 483
AMI 483
A Simple IVR Using CURL 483
Installing the cURL Module 484

The Dialplan 484
A Prompt-Recording Application 484
Speech Recognition and Text-to-Speech 486
Text-to-Speech 486
Speech Recognition 486
Conclusion 487
18. External Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Calendar Integration 490
Compiling Calendaring Support into Asterisk 490
Configuring Calendar Support for Asterisk 492
Triggering Calendar Reminders to Your Phone 494
Controlling Calls Based on Calendar Information 499
Writing Call Information to a Calendar 501
Additional Features 503
Voicemail IMAP Integration 503
Compiling IMAP Voicemail Support into Asterisk 504
Using XMPP (Jabber) with Asterisk 511
Compiling XMPP Support into Asterisk 512
Jabber Dialplan Commands 512
chan_motif 518
Out-of-Band Messaging (Messaging Infrastructure) 522
xmpp.conf Configuration 522
sip.conf Configuration 523
Dialplan Configuration 524
LDAP Integration 525
Configuring OpenLDAP 526
Compiling LDAP Support into Asterisk 528
Configuring Asterisk for LDAP Support 529
Text-to-Speech Utilities 531
Festival 531

Cepstral 534
xii | Table of Contents
www.it-ebooks.info
Conclusion 534
19. Fax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
What Is a Fax? 535
Ways to Handle Faxes in Asterisk 535
spandsp 536
Obtaining spandsp 536
Compiling and Installing spandsp 537
Adding the spandsp Library to Your libpath 537
Recompiling Asterisk with spandsp Support 537
Disabling spandsp (Should You Want to Test Digium Fax) 538
Digium Fax For Asterisk 538
Obtaining Digium FFA 538
Disabling Digium FFA (Should You Want to Test spandsp) 539
Incoming Fax Handling 539
Fax to TIFF 540
Fax to Email 541
Fax Detection 542
Using T.38 543
Outgoing Fax Handling 544
Transmitting a Fax from Asterisk 544
File Format for Faxing 545
An Experiment in Email to Fax 546
Fax Pass-Through 549
Using Fax Buffers in chan_dahdi.conf 549
T.38 Gateway 550
Conclusion 551
20.

Asterisk Manager Interface (AMI). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Quick Start 553
AMI over TCP 554
AMI over HTTP 555
Configuration 556
manager.conf 556
http.conf 561
Protocol Overview 562
Message Encoding 563
AMI over HTTP 564
Call Files 569
Example Usage 571
Originating a Call 571
Redirecting a Call 573
Table of Contents | xiii
www.it-ebooks.info
Originating a Call Using Python and StarPy 574
Development Frameworks 579
CSTA 580
Interesting Applications 580
Flash Operator Panel 580
Conclusion 581
21.
Asterisk Gateway Interface (AGI). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Quick Start 583
AGI Variants 585
Process-Based AGI 585
DeadAGI Is Dead 586
FastAGI—AGI over TCP 586
Async AGI—AMI-Controlled AGI 587

AGI Communication Overview 588
Setting Up an AGI Session 588
Commands and Responses 590
Ending an AGI Session 594
Example: Account Database Access 596
Development Frameworks 599
Conclusion 599
22.
Clustering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Traditional PBXs 602
Hybrid Systems 603
Pure Asterisk, Nondistributed 605
Asterisk and Database Integration 606
Single Database 606
Replicated Databases 608
Asterisk and Distributed Device States 609
Distributing Device States over a LAN 610
Distributing Device States over a WAN 611
Multiple Queues, Multiple Sites 613
Conclusion 614
23.
Distributed Universal Number Discovery (DUNDi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
How Does DUNDi Work? 617
The dundi.conf File 619
Configuring Asterisk for Use with DUNDi 621
General Configuration 622
Initial DUNDi Peer Definition 623
Creating Mapping Contexts 625
xiv | Table of Contents
www.it-ebooks.info

Using Mapping Contexts with Peers 627
Allowing Remote Connections 629
Controlling Responses 630
Performing Lookups from the Dialplan 634
Conclusion 637
24. System Monitoring and Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
logger.conf 639
Reviewing Asterisk Logs 641
Logging to the Linux syslog Daemon 642
Verifying Logging 643
Log Rotation 643
Call Detail Records 643
CDR Contents 644
Dialplan Applications 645
cdr.conf 645
Backends 646
Example Call Detail Records 653
Caveats 653
CEL (Channel Event Logging) 654
Channel Event Types 654
Channel Event Contents 655
Dialplan Applications 656
cel.conf 657
Backends 657
Example Channel Events 663
SNMP 668
Installing the SNMP Module for Asterisk 668
Configuring SNMP for Asterisk Using OpenNMS 669
Monitoring Asterisk with OpenNMS 672
Conclusion 673

25.
Web Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Flash Operator Panel 676
Queue Status and Reporting 676
Queue Status Display 677
Queue Reporting 677
Call Detail Records 677
A2Billing 678
Conclusion 678
26. Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
Table of Contents | xv
www.it-ebooks.info
Scanning for Valid Accounts 679
Authentication Weaknesses 681
Fail2ban 681
Installation 682
Configuration 683
Encrypted Media 687
Dialplan Vulnerabilities 687
Securing Asterisk Network APIs 689
IAX2 Denial of Service 689
Other Risk Mitigation 691
CLI Permissions 693
Resources 694
Conclusion—A Better Idiot 694
27.
Asterisk: A Future for Telephony. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
The Problems with Traditional Telephony 695
Closed Thinking 696
Limited Standards Compliance 697

Slow Release Cycles 697
Refusing to Let Go of the Past and Embrace the Future 698
Paradigm Shift 698
The Promise of Open Source Telephony 698
The Itch that Asterisk Scratches 698
Open Architecture 699
Standards Compliance 700
Lightning-Fast Response to New Technologies 700
Passionate Community 700
Some Things that Are Now Possible 701
The Future of Asterisk 705
Speech Processing 705
High-Fidelity Voice 706
Video 707
WebRTC 709
Wireless 709
Unified Messaging 710
Peering 710
Challenges 711
Opportunities 714
A. Understanding Telephony. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
B. Protocols for VoIP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
xvi | Table of Contents
www.it-ebooks.info
C. Preparing a System for Asterisk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
Table of Contents | xvii
www.it-ebooks.info
www.it-ebooks.info
Foreword

When we were thinking of who we could ask to write a foreword for the fourth edition
of the book, lots of names were tossed around. We had already had Mark Spencer (author
of Asterisk) write it for the first two editions of the book. Next, John Todd did a fantastic
job for the third edition. After batting around several names (of which you will see
below), we thought, “This is a book written by the community, how about we do a
community foreword?” With that idea in mind, we picked several people whom we
respect, and who have been using Asterisk as long as (if not longer than) ourselves.
When we were thinking of people, we wanted to get several perspectives and loosely
answer several questions about Asterisk. The questions we were looking at included:

How has Asterisk helped in communities?

What worldly endeavors has Asterisk contributed to?

Where has Asterisk been and where is it going?

Why is Asterisk being deployed and what needs does it solve?
These are all questions that most people who have used Asterisk for an extended period
of time are either asked, or have asked themselves. After posing those questions to the
following authors, they all came back with various viewpoints about the Asterisk soft‐
ware, and how it has changed the telecommunications industry and the lives of people.
We hope you enjoy reading about their contributions as much as we did.
Matt Jordan (Engineering Manager, Digium)
When Leif asked me to write a foreword for the updated edition of Asterisk: The De‐
finitive Guide, he posed the following question: “Where has Asterisk been and where is
it going?” This means some prognostication is ahead—you’ve been warned!
To answer the first part, I looked at how Asterisk has evolved over the past several
versions. Each version has built upon the previous in an iterative fashion, while still
xix
www.it-ebooks.info

remaining true to what made Asterisk great: a free and open source platform to build
telephon
y applications. As time passed and the telephony landscape changed, Asterisk
changed with it. Asterisk evolved with new functionality to meet the changing needs of
the people who used and developed it. At times, Asterisk has pushed the telephony
industry; at times it has responded to it. The result of this push and pull is the state of
Asterisk today—it is in many things and in many places. It powers the phone systems
of my local grocery store, drug store, and pizza chain—it is the engine of choice that
powers the PBXs of everyone from hobbyists to large enterprises.
The second part is trickier. As Asterisk nears its 15
th
birthday, the question in my mind
isn’t so much “where is Asterisk going,” but “where is the telephony industry going?”
The convergence of mobile platforms, hosted solutions, and WebRTC will fundamen‐
tally change not only our definition of a phone, but how businesses deploy their com‐
munication infrastructure and what it means to communicate. So how does Asterisk
respond to fundamental shifts in deployment, operability, and usage?
In my mind, the way it always has—by being innovative. By leading the way in adopting
standards for communication. By exposing new APIs that make it easier for anyone to
use Asterisk to build communication applications for a wide range of business needs.
And finally, by being willing to change. Asterisk has traditionally provided applications
for you—if you wanted call queues, you used the Queue application. If you wanted voice
mail, you used VoiceMail. As we go forward in the next major versions of Asterisk, I
see the emphasis being less on providing functionality for you and more on providing
the building blocks to build whatever communications functionality you need.
It is an exciting time to be a user and developer of Asterisk—and I look forward to
building Asterisk with you.
Alex Balashov (Principal, Evariste Systems)
Asterisk is most often celebrated for its free licensing and its generous feature set. How‐
ever, as most adopters of open source technology know, or quickly discover, it has im‐

plementation costs, too. The essential value of Asterisk does not, in my view, lie in the
economic or technical efficiency of a free PBX, but in the disruptive structural effect it
has had upon the larger domain of innovation in which it participates. It has irrevocably
shifted the conversation about possibilities in telephony.
Asterisk did not merely offer an open source challenge to incumbent PBX vendors. The
fact that it could run on commodity PC hardware and small, PC-compatible embedded
devices set off a tectonic shift toward the commoditization of business problems that
were previously solvable only by complex data interchange performed on expensive,
proprietary hardware or expensively licensed software, such as, for instance, interactive
voice response (IVR) systems that provide self-service interfaces to banks. Asterisk has
numerous integration pathways and APIs that allow it to connect to other commodity
xx | Foreword
www.it-ebooks.info
services using open standards and ubiquitous protocols, drastically lowering the cost
of making it talk to other systems. It is impossible to overstate the transformative impact
this has had, enabling entirely new business models to take flight, untethered by hitherto
prohibitive capital drag.
Asterisk can take credit for the fact that there are now entirely new, generational answers
to the question, “can we make the phone system do this?” Incumbent telecom vendors,
irrespective of the degree to which they view Asterisk as a competitor, have had to re-
frame their marketing message in terms of the possibilities that it has forced open.
Asterisk has changed the observational language—the vocabulary, the thought process,
the basic economic assumptions—of business telephony systems.
Asterisk’s interoperability and attachment to commodity hardware has also weakened
the walls of formidable fortresses of telecom monopoly that were previously thought
impregnable. I have witnessed its use with libss7 as an interconnection element by
competitive operators in several emerging-market countries, and as the backbone of
toll bypass applications and cost-efficient calling card services. The impact of this
Asterisk-driven pressure wave of innovative, low-cost alternatives is titanic, having cre‐
ated entirely new social connections, jobs, and livelihoods around the world, enriching

the lives of many people. My own family is scattered around the globe, and my Asterisk
PBX has made that world a whole lot smaller. We simply could not afford to commu‐
nicate so closely, regularly, and richly before.
In sum, I think that in the overall continuum of technological development, Asterisk
may well be remembered less for what is inside of it and more for what it has shoved
aside outside of it with its powerful elbows.
Kevin McAllister (VP of Engineering, CoreDial, LLC)
In the late summer of 2005 I was offered a job at a startup that planned to deliver hosted
IP PBX services to businesses. At the time I knew Linux system administration, IP
networking, and enough to be scared to death of voice.
The first reason for the fear of voice was that I knew how the Internet worked. Voice is
the canary in the coal mine that is the Internet—when the network breaks, the voice
dies first. The second reason to be afraid is that people are very familiar with phones,
and therefore they have strong ideas about what phones should do to help run their
business, and expect voice service to be more reliable than electricity. I would be re‐
sponsible for trying to make feature after feature work under these demanding
circumstances.
The plan was to build on top of an existing prototype based on Asterisk. So not only
would I have the daunting task of pushing voice through my network, but also learning
how to use a complex piece of open source software that traditionally offers documen‐
tation that is incomplete and often inaccurate. So the situation was I didn’t know what
Foreword | xxi
www.it-ebooks.info
I wanted it to do, I didn’t know how to make the software do it, and I had no way to find
out.
Luckily, there was only one book available to help at that time: Asterisk™: The Future of
Telephony. That first version of this book helped me to quickly understand not only the
Asterisk software, but the basics of VoIP. The presentation allowed me to see how I could
quickly combine the many and very flexible features of the Asterisk software to build
complex and reliable features demanded by my customers.

Now—almost eight years and countless millions of successful calls later—I have learned
firsthand the things that do and do not work when building Internet VoIP systems. But
I continue to rely heavily on Asterisk and on the authors of this book to help me quickly
understand this constantly changing and improving software. You’ve chosen a great
starting point for working with Asterisk. I wish you even more success than I have had.
Brian Capouch (Computer Science Department, Saint
Joseph’s College [Indiana])
“Well, you can actually do that pretty easily.” That observation, over and over, burned
itself into my brain back when I first began hacking with Asterisk. I had already been
playing around—enjoying some success but suffering a lot of misery, too—with some
early IP telephony products, when one day I first saw mention of Asterisk on a mailing
list. I fetched the code and built it (before it was versioned!), and I’ll forever remember
the first sound I heard: Allison Smith’s “Comedian Mail” voice prompt. I laughed and
laughed. What was going on here??!!??
I dug in, and it changed my life. At the time, I operated a wireless ISP. It was an inde‐
scribable thrill that I was able to set up a network of Asterisk servers running on cheap
eBay hardware, connected to local telco lines at fifteen POPs scattered over 500 square
miles of mostly desolate Indiana farmland. I not only got my own wide-area toll-free
calling zone, it was free—back in the days when minutes actually cost something.
For another project, I hooked up Asterisk and a $20 USB camera I bought on eBay, and
got live video surveillance of an old railroad hotel I own in Medaryville, Indiana. It was
built in 1853, and had not yet been outfitted with modern electrical service. The system
ran off a marine battery that I replaced every few days.
Later on, one summer evening my friend Bob staged a faux break-in at the hotel while
I was giving a late-afternoon presentation at a technical conference in faraway Califor‐
nia. My audience and I watched the entrance door through a live feed from the camera,
and before the image of Bob’s entry had refreshed on the display monitor, a portable
SIP phone in my pocket rang, annunciating a “security situation” at my hotel. Asterisk
servers handled the call point-to-point between the hotel and the conference center.
xxii | Foreword

www.it-ebooks.info
Asterisk is about all kinds of telephony functionality, for all kinds of situations, perfectly
free for anyone to use. It’s another example of the way open source products not only
save a lot of money, but do a better job than the commercial products from the big
players. For me, Asterisk is about empowerment, about freedom from the dying tyranny
of the greedy monopolists, and about new worlds yet to come. No matter what new
communications trick you could think to try, the answer is likely, “Well, you can do that
pretty easily.” This book was created by great friends who were, like me, almost present
at the creation. They energetically and creatively maintain an invaluable, friendly, and
comprehensive guide to one of the greatest open source products ever. Enjoy!
Foreword | xxiii
www.it-ebooks.info

×