Asterisk: The Definitive Guide, 5th Edition

Book description

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

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
    1. Joshua Colp (Senior Software Developer, Sangoma/Digium)
    2. Dan Jenkins (Founder, Nimble Ape Ltd)
    3. Joyce Wilmot (Senior Web Developer)
    4. Matt Florell (Founder, VICIdial)
    5. Matt Fredrickson (Director of Asterisk Engineering, Sangoma/Digium)
  2. Preface
    1. Audience
    2. Software
    3. Conventions Used in This Book
    4. O’Reilly Online Learning
    5. How to Contact Us
    6. Acknowledgments from Jim Van Meggelen
  3. 1. A Telephony Revolution
    1. Asterisk and VoIP: Bridging the Gap Between Traditional and Network Telephony
      1. 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
      1. Asterisk’s Discourse-Based Community Site
      2. The Asterisk Mailing Lists
      3. Asterisk Wiki Sites
      4. The IRC Channels
    6. Conclusion
  4. 2. Asterisk Architecture
    1. Modules
      1. Applications
      2. Bridging Modules
      3. Call Detail Recording Modules
      4. Channel Event Logging Modules
      5. Channel Drivers
      6. Codec Translators
      7. Format Interpreters
      8. Dialplan Functions
      9. PBX Modules
      10. Resource Modules
      11. Add-on Modules
      12. Test Modules
    2. File Structure
      1. Configuration Files
      2. Modules
      3. The Resource Library
      4. The Spool
      5. Logging
    3. The Dialplan
    4. Hardware
    5. Asterisk Versioning
    6. Conclusion
  5. 3. Installing Asterisk
    1. Linux Installation
      1. Choosing Your Platform
      2. VirtualBox Steps
      3. Linux (OpenStack) Host
    2. Dependencies
    3. Asterisk Installation
      1. Download and Prerequisites
      2. Compiling and Installing
      3. Initial Configuration
      4. SELinux Tweaks
      5. Firewall Tweaks
      6. Final Tweaks
    4. Validating Your New Asterisk System
    5. Common Installation Errors
    6. Some Final Configuration Notes
      1. Sample Configuration Files for Future Reference
      2. The Asterisk Shell Command
      3. safe_asterisk
    7. Conclusion
  6. 4. Certificates for Endpoint Security
    1. The Inconvenience of Security
    2. Securing SIP
      1. Subscriber Names
      2. Secure SIP Signaling
    3. Securing Media
      1. Encrypted RTP
    4. Conclusion
  7. 5. User Device Configuration
    1. Telephone Naming Concepts
    2. Hardphones, Softphones, and ATAs
    3. Configuring Asterisk
      1. How Channel Configuration Works with the Dialplan
      2. chan_pjsip
    4. Testing to Ensure Your Devices Have Registered
    5. A Basic Dialplan to Test Your Devices
    6. Under the Hood: Your First Call
    7. Conclusion
  8. 6. Dialplan Basics
    1. Dialplan Syntax
      1. Contexts
      2. Extensions
      3. Priorities
      4. Applications
      5. The Answer(), Playback(), and Hangup() Applications
      6. A Basic Dialplan Prototype
    2. A Simple Dialplan
      1. Hello World
    3. Building an Interactive Dialplan
      1. The Goto(), Background(), and WaitExten() Applications
      2. Handling Invalid Entries and Timeouts
      3. Using the Dial() Application
      4. Using Variables
      5. Pattern Matching
      6. Includes
    4. Conclusion
  9. 7. Outside Connectivity
    1. The Basics of Trunking
    2. Fundamental Dialplan for Outside Connectivity
    3. The PSTN
      1. Traditional PSTN Trunks
    4. VoIP
      1. Network Address Translation
      2. PSTN Termination and Origination
      3. Configuring SIP Trunks
    5. Emergency Dialing
    6. Conclusion
  10. 8. Voicemail
    1. The voicemail.conf File
      1. An Initial voicemail.conf File
      2. The [general] Section
      3. The [zonemessages] Section
      4. Mailboxes
    2. Voicemail Dialplan Integration
      1. The VoiceMail() Dialplan Application
      2. The VoiceMailMain() Dialplan Application
      3. Standard Voicemail Keymap
      4. Creating a Dial-by-Name Directory
    3. Voicemail to Email
    4. Voicemail Storage Backends
      1. Linux Filesystem
      2. IMAP
      3. Message Storage in a Database
    5. Conclusion
  11. 9. Internationalization
    1. Devices External to the Asterisk Server
    2. PSTN Connectivity, DAHDI, Digium Cards, and Analog Phones
      1. DAHDI Drivers
    3. Internationalization Within Asterisk
      1. Caller ID
      2. Language and/or Accent of Prompts
      3. Time/Date Stamps and Pronunciation
    4. Conclusion—Easy Reference Cheat Sheet
  12. 10. Deeper into the Dialplan
    1. Expressions and Variable Manipulation
      1. Basic Expressions
      2. Operators
    2. Dialplan Functions
      1. Syntax
      2. Examples of Dialplan Functions
    3. Conditional Branching
      1. The GotoIf() Application
      2. Time-Based Conditional Branching with GotoIfTime()
    4. GoSub
      1. Defining Subroutines
      2. Returning from a Subroutine
    5. Local Channels
    6. Using the Asterisk Database
      1. Storing Data in the AstDB
      2. Retrieving Data from the AstDB
      3. Deleting Data from the AstDB
      4. Using the AstDB in the Dialplan
    7. Handy Asterisk Features
      1. Conferencing with ConfBridge()
    8. Handy Dialplan Functions
      1. CALLERID()
      2. CHANNEL()
      3. CURL()
      4. CUT()
      5. IF() and STRFTIME()
      6. LEN()
      7. REGEX()
      8. STRFTIME()
    9. Conclusion
  13. 11. PBX Features, Including Parking, Paging, and Conferencing
    1. features.conf
      1. The [general] Section
      2. The [featuremap] Section
      3. The [applicationmap] Section
      4. Application Map Grouping
    2. Parking and Paging
      1. Call Parking
      2. Paging (aka Public Address)
      3. Places to Send Your Pages
      4. Zone Paging
    3. Advanced Conferencing
      1. Video Conferencing
    4. Conclusion
  14. 12. Automatic Call Distribution Queues
    1. Creating a Simple ACD Queue
    2. Queue Members
      1. Controlling Queue Members via the CLI
      2. Defining Queue Members in the queue_members Table
      3. Controlling Queue Members with Dialplan Logic
      4. Automatically Logging Into and Out of Multiple Queues
    3. Advanced Queues
      1. Priority Queue (Queue Weighting)
      2. Queue Member Priority
      3. Changing Penalties Dynamically (queuerules)
      4. Announcement Control
      5. Overflow
      6. Using Local Channels
    4. Queue Statistics: The queue_log File
    5. Conclusion
  15. 13. Device States
    1. Device States
      1. Checking Device States
    2. Extension States Using the hint Directive
      1. Hints
      2. Checking Extension States
    3. SIP Presence
    4. Using Custom Device States
    5. Conclusion
  16. 14. The Automated Attendant
    1. An AA Is Not an IVR
    2. Designing Your AA
      1. The Greeting
      2. The Main Menu
      3. Timeout
      4. Invalid
      5. Dial by Extension
    3. Building Your AA
      1. Recording Prompts
      2. The Dialplan
      3. Delivering Incoming Calls to the AA
      4. IVR
    4. Conclusion
  17. 15. Relational Database Integration
    1. Your Choice of Database
    2. Managing Databases
      1. Troubleshooting Database Issues
      2. SQL Injection
    3. Powering Your Dialplan with func_odbc
    4. A Gentle Introduction to func_odbc
    5. Getting Funky with func_odbc: Hot-Desking
    6. Using Realtime
      1. Static Realtime
      2. Dynamic Realtime
    7. Storing Call Detail Records
    8. Database Integration of ACD Queues
      1. Storing Dialplan Parameters for a Queue in a Database
      2. Writing queue_log to Database
    9. Conclusion
  18. 16. Introduction to Interactive Voice Response
    1. Components of an IVR
    2. IVR Design Considerations
    3. Asterisk Modules for Building IVRs
      1. CURL()
      2. func_odbc
      3. AGI
      4. AMI
      5. ARI
    4. A Simple IVR Using CURL()
      1. The Dialplan
    5. A Prompt-Recording IVR Function
    6. Speech Recognition and Text-to-Speech
      1. Text-to-Speech
      2. Speech Recognition
    7. Conclusion
  19. 17. Asterisk Manager Interface and Call Files
    1. Call Files
      1. Your First Call File
      2. Notes About Call Files
    2. AMI Quick Start
      1. AMI over TCP
      2. AMI over HTTP
    3. Configuration
      1. manager.conf
      2. http.conf
    4. Protocol Overview
      1. Message Encoding
      2. AMI over HTTP
    5. Example Usage
      1. Originating a Call
      2. Redirecting a Call
    6. Development Frameworks
    7. Conclusion
  20. 18. Asterisk Gateway Interface
    1. Quick Start
    2. AGI Variants
      1. Process-Based AGI
      2. FastAGI—AGI over TCP
      3. Async AGI—AMI-Controlled AGI
    3. AGI Communication Overview
      1. Setting Up an AGI Session
      2. Commands and Responses
      3. Ending an AGI Session
    4. Example: Account Database Access
    5. Development Frameworks
    6. Conclusion
  21. 19. Asterisk REST Interface
    1. ARI Quick Start
      1. Basic Asterisk Configuration
      2. Testing Your Basic ARI Environment
      3. Working with Your ARI Environment Using Swagger
    2. The Building Blocks of ARI
      1. REST
      2. WebSocket
      3. Stasis
    3. Frameworks
      1. ari-py (and aioari) for Python
      2. node-ari-client
      3. AsterNET.ARI
      4. ari4java
      5. phpari
      6. aricpp
      7. asterisk-ari-client
    4. Conclusion
  22. 20. WebRTC
    1. The Browser as a Telephone
    2. Preliminary Knowledge
    3. Configuring Asterisk for WebRTC
    4. Cyber Mega Phone
    5. More About WebRTC
    6. Conclusion
  23. 21. System Monitoring and Logging
    1. logger.conf
      1. Reviewing Asterisk Logs
      2. Logging to the Linux syslog Daemon
      3. Verifying Logging
      4. Log Rotation
    2. Call Detail Records
      1. CDR Contents
      2. Dialplan Applications
      3. cdr.conf
      4. Backends
      5. Example Call Detail Records
      6. Caveats
    3. Channel Event Logging
    4. Conclusion
  24. 22. Security
    1. Scanning for Valid Accounts
    2. Authentication Weaknesses
    3. Fail2ban
      1. Installation
      2. Configuration
    4. Encrypted Media
    5. Dialplan Vulnerabilities
    6. Securing Asterisk Network APIs
    7. Other Risk Mitigation
    8. Resources
    9. Conclusion—A Better Idiot
  25. 23. Asterisk: A Future for Telephony
    1. The Telephone Is Dead (Except When It’s Not)
    2. Communications Overload
    3. The Problems with Open Source Development
    4. The Future of Asterisk
      1. WebRTC
    5. The Future of Telephony
  26. Index

Product information

  • Title: Asterisk: The Definitive Guide, 5th Edition
  • Author(s): Jim Van Meggelen, Russell Bryant, Leif Madsen
  • Release date: June 2019
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492031604