Design a complete Voice over IP (VoIP) or traditional PBX system with Asterisk, even if you have only basic telecommunications knowledge. This bestselling guide makes it easy with a detailed roadmap that shows you how to install and configure this open source software, whether you’re upgrading your existing phone system or starting from scratch.
Ideal for Linux administrators, developers, and power users, this updated fifth edition shows you how to set up VoIP-based private telephone switching systems within the enterprise. You’ll get up to speed on the features in Asterisk 16, the latest long-term support release from Digium. This book also includes new chapters on WebRTC and the Asterisk Real-time Interface (ARI).
• Discover how WebRTC provides a new direction for Asterisk
• Gain the knowledge to build a simple but complete phone system
• Build an interactive dialplan, using best practices for Asterisk’s advanced features
• Learn how ARI has emerged as the API of choice for interfacing web development languages with Asterisk
Author(s): Jim Van Meggelen, Russell Bryant, Leif Madsen
Edition: 5
Publisher: O'Reilly Media
Year: 2019
Language: English
Commentary: True PDF
Pages: 414
City: Sebastopol, CA
Tags: Security; Relational Databases; Monitoring; System Administration; Logging; VoIP; Asterisk; WebRTC; Interactive Voice Response
Copyright
Table of Contents
Foreword
Joshua Colp (Senior Software Developer, Sangoma/Digium)
Dan Jenkins (Founder, Nimble Ape Ltd)
Joyce Wilmot (Senior Web Developer)
Matt Florell (Founder, VICIdial)
Matt Fredrickson (Director of Asterisk Engineering, Sangoma/Digium)
Preface
Audience
Software
Conventions Used in This Book
O’Reilly Online Learning
How to Contact Us
Acknowledgments from Jim Van Meggelen
Chapter 1. A Telephony Revolution
Asterisk and VoIP: Bridging the Gap Between Traditional and Network Telephony
The Zapata Telephony Project
Massive Change Requires Flexible Technology
Asterisk: The Hacker’s PBX
Asterisk: The Professional’s PBX
The Asterisk Community
Asterisk’s Discourse-Based Community Site
The Asterisk Mailing Lists
Asterisk Wiki Sites
The IRC Channels
Conclusion
Chapter 2. Asterisk Architecture
Modules
Applications
Bridging Modules
Call Detail Recording Modules
Channel Event Logging Modules
Channel Drivers
Codec Translators
Format Interpreters
Dialplan Functions
PBX Modules
Resource Modules
Add-on Modules
Test Modules
File Structure
Configuration Files
Modules
The Resource Library
The Spool
Logging
The Dialplan
Hardware
Asterisk Versioning
Conclusion
Chapter 3. Installing Asterisk
Linux Installation
Choosing Your Platform
VirtualBox Steps
Linux (OpenStack) Host
Dependencies
Asterisk Installation
Download and Prerequisites
Compiling and Installing
Initial Configuration
SELinux Tweaks
Firewall Tweaks
Final Tweaks
Validating Your New Asterisk System
Common Installation Errors
Some Final Configuration Notes
Sample Configuration Files for Future Reference
The Asterisk Shell Command
safe_asterisk
Conclusion
Chapter 4. Certificates for Endpoint Security
The Inconvenience of Security
Securing SIP
Subscriber Names
Secure SIP Signaling
Securing Media
Encrypted RTP
Conclusion
Chapter 5. User Device Configuration
Telephone Naming Concepts
Hardphones, Softphones, and ATAs
Configuring Asterisk
How Channel Configuration Works with the Dialplan
chan_pjsip
Testing to Ensure Your Devices Have Registered
A Basic Dialplan to Test Your Devices
Under the Hood: Your First Call
Conclusion
Chapter 6. Dialplan Basics
Dialplan Syntax
Contexts
Extensions
Priorities
Applications
The Answer(), Playback(), and Hangup() Applications
A Basic Dialplan Prototype
A Simple Dialplan
Hello World
Building an Interactive Dialplan
The Goto(), Background(), and WaitExten() Applications
Handling Invalid Entries and Timeouts
Using the Dial() Application
Using Variables
Pattern Matching
Includes
Conclusion
Chapter 7. Outside Connectivity
The Basics of Trunking
Fundamental Dialplan for Outside Connectivity
The PSTN
Traditional PSTN Trunks
VoIP
Network Address Translation
PSTN Termination and Origination
Configuring SIP Trunks
Emergency Dialing
Conclusion
Chapter 8. Voicemail
The voicemail.conf File
An Initial voicemail.conf File
The [general] Section
The [zonemessages] Section
Mailboxes
Voicemail Dialplan Integration
The VoiceMail() Dialplan Application
The VoiceMailMain() Dialplan Application
Standard Voicemail Keymap
Creating a Dial-by-Name Directory
Voicemail to Email
Voicemail Storage Backends
Linux Filesystem
IMAP
Message Storage in a Database
Conclusion
Chapter 9. Internationalization
Devices External to the Asterisk Server
PSTN Connectivity, DAHDI, Digium Cards, and Analog Phones
DAHDI Drivers
Internationalization Within Asterisk
Caller ID
Language and/or Accent of Prompts
Time/Date Stamps and Pronunciation
Conclusion—Easy Reference Cheat Sheet
Chapter 10. Deeper into the Dialplan
Expressions and Variable Manipulation
Basic Expressions
Operators
Dialplan Functions
Syntax
Examples of Dialplan Functions
Conditional Branching
The GotoIf() Application
Time-Based Conditional Branching with GotoIfTime()
GoSub
Defining Subroutines
Returning from a Subroutine
Local Channels
Using the Asterisk Database
Storing Data in the AstDB
Retrieving Data from the AstDB
Deleting Data from the AstDB
Using the AstDB in the Dialplan
Handy Asterisk Features
Conferencing with ConfBridge()
Handy Dialplan Functions
CALLERID()
CHANNEL()
CURL()
CUT()
IF() and STRFTIME()
LEN()
REGEX()
STRFTIME()
Conclusion
Chapter 11. PBX Features, Including Parking, Paging, and Conferencing
features.conf
The [general] Section
The [featuremap] Section
The [applicationmap] Section
Application Map Grouping
Parking and Paging
Call Parking
Paging (aka Public Address)
Places to Send Your Pages
Zone Paging
Advanced Conferencing
Video Conferencing
Conclusion
Chapter 12. Automatic Call Distribution Queues
Creating a Simple ACD Queue
Queue Members
Controlling Queue Members via the CLI
Defining Queue Members in the queue_members Table
Controlling Queue Members with Dialplan Logic
Automatically Logging Into and Out of Multiple Queues
Advanced Queues
Priority Queue (Queue Weighting)
Queue Member Priority
Changing Penalties Dynamically (queuerules)
Announcement Control
Overflow
Using Local Channels
Queue Statistics: The queue_log File
Conclusion
Chapter 13. Device States
Device States
Checking Device States
Extension States Using the hint Directive
Hints
Checking Extension States
SIP Presence
Using Custom Device States
Conclusion
Chapter 14. The Automated Attendant
An AA Is Not an IVR
Designing Your AA
The Greeting
The Main Menu
Timeout
Invalid
Dial by Extension
Building Your AA
Recording Prompts
The Dialplan
Delivering Incoming Calls to the AA
IVR
Conclusion
Chapter 15. Relational Database Integration
Your Choice of Database
Managing Databases
Troubleshooting Database Issues
SQL Injection
Powering Your Dialplan with func_odbc
A Gentle Introduction to func_odbc
Getting Funky with func_odbc: Hot-Desking
Using Realtime
Static Realtime
Dynamic Realtime
Storing Call Detail Records
Database Integration of ACD Queues
Storing Dialplan Parameters for a Queue in a Database
Writing queue_log to Database
Conclusion
Chapter 16. Introduction to Interactive Voice Response
Components of an IVR
IVR Design Considerations
Asterisk Modules for Building IVRs
CURL()
func_odbc
AGI
AMI
ARI
A Simple IVR Using CURL()
The Dialplan
A Prompt-Recording IVR Function
Speech Recognition and Text-to-Speech
Text-to-Speech
Speech Recognition
Conclusion
Chapter 17. Asterisk Manager Interface and Call Files
Call Files
Your First Call File
Notes About Call Files
AMI Quick Start
AMI over TCP
AMI over HTTP
Configuration
manager.conf
http.conf
Protocol Overview
Message Encoding
AMI over HTTP
Example Usage
Originating a Call
Redirecting a Call
Development Frameworks
Conclusion
Chapter 18. Asterisk Gateway Interface
Quick Start
AGI Variants
Process-Based AGI
FastAGI—AGI over TCP
Async AGI—AMI-Controlled AGI
AGI Communication Overview
Setting Up an AGI Session
Commands and Responses
Ending an AGI Session
Example: Account Database Access
Development Frameworks
Conclusion
Chapter 19. Asterisk REST Interface
ARI Quick Start
Basic Asterisk Configuration
Testing Your Basic ARI Environment
Working with Your ARI Environment Using Swagger
The Building Blocks of ARI
REST
WebSocket
Stasis
Frameworks
ari-py (and aioari) for Python
node-ari-client
AsterNET.ARI
ari4java
phpari
aricpp
asterisk-ari-client
Conclusion
Chapter 20. WebRTC
The Browser as a Telephone
Preliminary Knowledge
Configuring Asterisk for WebRTC
Cyber Mega Phone
More About WebRTC
Conclusion
Chapter 21. System Monitoring and Logging
logger.conf
Reviewing Asterisk Logs
Logging to the Linux syslog Daemon
Verifying Logging
Log Rotation
Call Detail Records
CDR Contents
Dialplan Applications
cdr.conf
Backends
Example Call Detail Records
Caveats
Channel Event Logging
Conclusion
Chapter 22. Security
Scanning for Valid Accounts
Authentication Weaknesses
Fail2ban
Installation
Configuration
Encrypted Media
Dialplan Vulnerabilities
Securing Asterisk Network APIs
Other Risk Mitigation
Resources
Conclusion—A Better Idiot
Chapter 23. Asterisk: A Future for Telephony
The Telephone Is Dead (Except When It’s Not)
Communications Overload
The Problems with Open Source Development
The Future of Asterisk
WebRTC
The Future of Telephony
Index
About the Authors
Colophon