Free sample of the first three chapters

The entire eBook can be bought at www.asteriskguide.com

 

 

 

 

 

 

 

 

astconfguideen2

 

How to build and configure a PBX with Open Source Software

Featuring release 1.4

Flavio E. Gonçalves

Third Generation

2nd Edition/April/2007

rev. 8.7

 

 

 

 

 

 

 

By Flavio E. Goncalves


Asterisk PBX Configuration Guide

Flavio E. Gonçalves

Revision: Luis F. Gonçalves

 

Copyright © 2006 V.Office Networks Ltda., All rights reserved

 

Printing History

 

First Edition: November 2006,

File Date: Friday, January 25, 2008

ISBN: 978-85-906904-2-9

 

Some manufacturers claim trademarks for several designations that distinguish their products. Wherever those designations appear in this book and we are aware of them, the designation is printed in CAPS or the initials are capitalized.

 

Although a great degree of care was used in writing this book, the author assumes no responsibility for errors and omissions, or damages resulting from the use of the information contained in this book.

 

Asterisk, Digium, IAX and DUNDI trademarks are property of Digium Inc.


Preface

 

This book is for anyone who wants to learn how to install and configure a PBX (Private Branch eXchange) based on Asterisk PBX. Asterisk is an open source telephony platform capable to use VoIP and TDM channels.

 

This is the third generation of the book Asterisk Configuration Guide. The book is also available in Spanish and Portuguese. The material that I present in this book helped to prepare for the dCAP certification from Digium last May 2006 and to pass it in the first try. Originally, this e-Book was written for version 1.0. The second generation was updated to version 1.2 and this one is based on version 1.4. However, you may still find examples that were based in the older version. Wherever possible, those examples have been suppressed or changed.

 

The Asterisk Open Source PBX is revolutionary. Telephony will never be the same after this program. For many years, telephony has been dominated by huge companies with proprietary systems. Finally, users can recover their buying power by having access to an open telephony platform. Thus, things that were not possible before because they were not economically viable are likely to start happening. Examples include resources like CTI (computer telephony integration, IVR (interactive voice response), ACD (automatic call distribution), and voicemail, that are now available to everybody. 

 

This book was not designed to teach every single detail of Asterisk. In fact, you will probably not become a guru simply by reading this e-Book. However, you will be able to build and configure a PBX with advanced features like voicemail, IVR an ACD by the end of reading. I hope you enjoy as much learning about Asterisk as I have enjoyed writing about it.

 

Flavio E. Gonçalves

CEO

V.Office Networks

flavio@asteriskguide.com


Audience

 

This book is intended for those who are new to Asterisk. We assume your are familiar with Linux, Linux shell commands and Linux text editors. You could test Asterisk using a Linux system with a graphical interface which may be easier for Linux newbies. Some users will try to execute Asterisk using VMWare and this is really not a problem, except for poorer voice quality. For production systems we do not encourage VMware or Linux with a graphical user interface.

 

It is also desirable that the reader has some knowledge of IP networks, voice over IP (VoIP) and telephony concepts.

 

Acknowledgments

 

I have to thank my family for the patience to see me work at late hours and during the weekends for several months. A special thanks to Ana Cristina Gama, Luis F. Goncalves, Karla Braga and Anna Leticia Loch for their help in the revision and publishing tasks.

Mistakes and errors in the e-Book

 

We always try to find and eliminate errors and mistakes. Please, if you find something wrong, give us feedback and we will act on it immediately.

 

E-mail address for feedback: oops@voffice.com.br

Use as a training material

 

We use this book for Asterisk training. If you are interested to use it in your training center, please send an e-mail to flavio@asteriskguide.com. We have additional materials such as presentations and lab guides.


Table of Contents

Asterisk Introduction. 11

1.1 Objectives. 11

1.2 What is Asterisk? 11

1.3 Why Asterisk? 13

1.4 Asterisk Architecture. 16

1.5 Overview.. 20

1.6 Differences between the old and the new world. 21

1.7 Building a test system. 23

1.8 Asterisk scenarios. 24

1.9 Finding information and help. 29

1.10 Summary. 30

1.11 Questions. 30

Downloading and installing Asterisk. 33

2.1 Objectives. 33

2.2 Introduction. 33

2.3 Minimum Hardware. 33

2.4 Choosing an operating system. 35

2.5 Installing Linux prepared for Asterisk. 36

2.6 Preparing the Debian system for Asterisk. 49

2.7 Obtaining and compiling Asterisk. 52

2.8 Starting and stopping Asterisk. 54

2.9 Installation Directories. 55

2.10 Log files and log rotation. 56

2.11 Starting Asterisk with a non-root user. 58

2.12 Asterisk installation notes. 58

2.13 Summary. 59

2.14 Questions. 59

First Steps. 61

3.1 Objectives. 61

3.2 Understanding the configuration files. 61

3.3 Grammars. 62

3.4 Configuring a PSTN interface. 63

3.5 SIP IP phones configuration. 65

3.6 Dial plan introduction. 67

3.7 Creating a basic dial plan. 72

3.8 Labs. 76

3.9 Summary. 77

3.10 Questions. 77

Analog and digital channels. 81

4.1 Objectives. 81

4.2 Telephony basics. 81

4.3 PSTN interfaces. 83

4.4 Analog FXS, FXO and E&M interfaces. 84

4.5 E1/T1 digital lines. 86

4.6. Asterisk telephony channels setup. 89

4.7 Zapata.conf configuration options. 101

4.8 MFC/R2 configuration. 106

4.9 ZAP channel format. 119

4.10 Unicall channel format. 119

4.11 Questions. 119

Voice over IP with Asterisk. 123

5.1 Objectives. 123

5.2 Introduction. 123

5.3 VoIP benefits. 124

5.4 Asterisk VoIP architecture. 124

5.5 VoIP protocols and the OSI (ISO Open Systems Interconnect) model. 126

5.6 How to choose a protocol. 127

5.7 Peers, Users and Friends. 129

5.8 Codecs and codec translation. 130

5.9 How to choose a Codec. 131

5.10 Overhead caused by protocol headers. 132

5.11 Traffic Engineering. 133

5.12 Reducing the bandwidth required for VoIP. 136

5.13 Summary. 140

5.14 Questions. 140

The IAX Protocol. 143

6.1 Objectives. 143

6.2 Introduction. 143

6.3 How it works? 144

6.4 Bandwidth usage. 145

6.5 Channel naming. 147

6.6 Using IAX. 148

6.7 IAX authentication. 157

6.8 The iax.conf file configuration. 162

6.9 IAX2 debug commands. 164

6.10 Summary. 167

6.11 Questions. 167

The SIP Protocol. 169

7.1 Objectives. 169

7.2 Overview.. 169

7.3 SIP advanced scenarios. 176

7.4 Advanced configurations. 182

7.5 SIP NAT Traversal. 186

7.6 SIP limitations. 191

7.7 SIP dial strings. 191

7.8 SIP CLI commands. 192

7.9 Questions. 192

Introduction to the dial plan. 195

8.1 Objectives. 195

8.2 Extensions.conf file structure. 196

8.3 Contexts. 198

8.4 Extensions. 199

8.5 Variables. 202

8.6 Expressions. 206

8.7 Functions. 208

8.8 Applications. 209

8.9 Building a Dialplan. 216

8.10 Building a simple Dial Plan. 218

8.11 Adding some logic to your dial plan. 220

8.12 Summary. 221

8.13 Questions. 221

Dial Plan advanced features. 223

9.1 Objectives. 223

9.2 Receiving calls using an IVR menu. 223

9.3 Context inclusion. 233

9.4 Using the switch statement. 234

9.5 Dial plan processing order. 235

9.6 The #INCLUDE statement. 236

9.7 Macros. 236

9.8 Implementing Call Forward, Black Lists and DND. 237

9.9 Using a blacklist. 240

9.10 Time based contexts. 241

9.11 To get a new dial tone use DISA. 242

9.12 Limit simultaneous calls. 243

9.13 LAB - Putting it all together. 244

9.14 Summary. 248

9.15 Questions. 248

Using PBX features. 251

10.1 Objectives. 251

10.2 PBX features support. 251

10.3 Call Transfer. 255

10.4 Call parking. 256

10.5 Call pickup. 257

10.6 Call Conference (Meetme) 258

10.7 Call Recording. 263

10.8 Music on hold. 265

10.9 Application Maps. 268

10.10 Questions. 269

ACD Automatic Call Distribution. 271

11.1 Objectives. 271

11.2 Introduction. 271

11.3 ACD architecture. 273

11.4 Queues. 273

11.5 Agents. 275

11.6 ACD related applications. 276

11.7 Configuration tasks. 280

11.8 Queue operation. 283

11.9 Advanced resources. 284

11.10 Questions. 285

Voicemail. 287

12.1 Objectives. 287

12.2 Introduction. 287

12.3 Configuration task list. 288

12.4 Sending voicemail to e-mail. 292

12.5 Voicemail Web interface. 293

12.6 Voicemail notification. 294

12.7 Using the directory application. 295

12.8 Summary. 296

12.9 Questions. 297

Asterisk Call Detail Records. 299

13.1 Introduction. 299

13.2 Objectives. 299

13.3 Asterisk CDR Format. 299

13.4 Account codes and automated message accounting. 300

13.5 Changing the CDR format. 300

13.6 CDR Storage. 301

13.7 Applications and functions. 303

13.8 User authentication. 304

13.9 Using passwords from voicemail. 305

13.10 Summary. 305

13.11 Questions. 306

Extending Asterisk with AMI and AGI 309

14.1 Introduction. 309

14.2 Objectives. 309

14.3 Major ways to extend Asterisk. 309

14.4 Extending Asterisk with console CLI 310

14.5 Extending Asterisk using the System() application. 310

14.6 What is AMI? 311

14.7 Configuring users and permissions. 312

14.8 Asterisk Manager Proxy. 316

14.9 Asterisk Gateway Interface. 318

14.10 Changing the source code. 323

14.11 Summary. 323

14.12 Questions. 324

Asterisk Real-Time. 327

15.1 Introduction. 327

15.2 Objectives. 327

15.3 How  does  Asterisk Real Time work? 328

15.4 LAB 1 Installing Asterisk Real/Time. 329

15.5 Configuring Asterisk Real Time. 329

15.6 Database configuration. 332

15.7 Lab 2 – Installing and creating the database tables. 333

15.8 Lab 3 – Configuring and testing ARA. 336

15.9 Summary. 338

15.10 Questions. 338

Question’s Responses. 341

Chapter 1. 341

Chapter 2. 343

Chapter 3. 345

Chapter 4. 347

Chapter 5. 349

Chapter 6. 351

Chapter 7. 352

Chapter 8. 354

Chapter 9. 356

Chapter 10. 358

Chapter 11. 360

Chapter 12. 362

Chapter 13. 364

Chapter 14. 366

Chapter 15. 367