Panasonic PBX or free Asterisk? PBX based on Asterisk® Asterix telephony.

Panasonic PBX or free Asterisk? PBX based on Asterisk® Asterix telephony.

03.03.2022

Despite the development of various information exchange systems such as e-mail and instant messaging services, the conventional telephone will remain the most popular means of communication for a long time to come. A key event in the history of telecommunications and the Internet was the emergence of voice over IP networks, so in recent years the very concept of a telephone has changed. The use of VoIP is modern, convenient, and cheap, since it is possible to unite remote offices without even resorting to the services of telephone operators. What other arguments are needed in order to raise your IP telephony server?

Project Asterisk

Asterisk present in the package repositories of most distributions. So, in Ubuntu, the command sudo apt-cache search Asterisk gives a decent list of packages, after installing which you can immediately start configuring. But installing from the repository has one drawback - as a rule, it contains the version Asterisk well behind the current one, which can be downloaded from the official site. Therefore, we will consider a universal installation method using the example of the same Ubuntu, although everything said (with rare exceptions) applies to other distributions.

Install the packages needed for compilation:

$ sudo apt-get install build-essential automake
autoconf bison flex libtool libncurses5-dev libssl-dev

It is also highly recommended to install the libpri library even if Primary Rate ISDN (Integrated Services Digital Network Primary Type) support is not needed. This can be done either through the repository: sudo apt-get install libpri1.2, or using the sources:

$ wget -c downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz

Compiling the library is standard, so we won't dwell on it.

Now download the source texts from the site Asterisk and configure:

$ wget -c downloads.digium.com/pub/Asterisk/Asterisk-1.4.11.tar.gz
$ tar xzvf Asterisk-1.4.11.tar.gz
$ cd Asterisk-1.4.11
$ ./configure --prefix=/usr

At the end of the script in the console, we will see the logo of the project and some information about the settings.

$make
$ sudo make install

Note: if version 1.2 is being installed, then to support the mp3 format, you must enter “make mpg123” before the make command, version 1.4 no longer reacts to this command.

After compilation, among other things, the following executable files will be installed:

  1. /usr/sbin/Asterisk - server daemon Asterisk, which provides all the work;
  2. /usr/sbin/safe_Asterisk - script to start, restart and check server operation Asterisk;
  3. /usr/sbin/astgenkey - script for creating private and public RSA keys in PEM format, which are necessary for work Asterisk.

To install configuration file templates and documentation, type:

$ sudo make samples

Sample config files will be copied to /etc/ Asterisk. If there are already configuration files in this directory, they will be renamed with ".old" prefix. To build the documentation, you will need the doxygen package, if it is not there, install:

$ sudo apt-get install doxygen
$ sudo make progdocs

Similarly, we put the package with extensions Asterisk-addons (this step is optional, you can safely skip it). Many of the modules included in this set are experimental. They should be installed only if you need to write information to the database, support mp3 files and the ooh323c protocol (Objective Systems Open H.323 for C):

$ wget -c downloads.digium.com/pub/Asterisk/Asterisk-addons-1.4.2.tar.gz
$ tar xzvf Asterisk-addons-1.4.2.tar.gz
$ cd Asterisk-addons-1.4.2
$ ./configure; make; sudo make install; sudo make samples

Installation Asterisk finished. It is recommended to start the server in debug mode first and check the output for errors:

$ sudo /usr/sbin/Asterisk -vvvgc

If we receive the message Asterisk Ready" and the management console prompt, then everything is in order. Exit:

*CLI> stop now

Now you can move on to further configuration.

Configuring Interface Card Support

If you plan to connect a server Asterisk using special interface cards to ordinary telephone networks, you should take care of the availability of the appropriate drivers implemented as a kernel module. But even if there are no such devices in the computer, it is still recommended to install these drivers. The fact is that all Zaptel devices have a timer, and for the full operation of the IP telephony server, it is necessary. But if you don't have a Zaptel device at hand, you can use a special driver - ztdummy - to emulate it.

Install zaptel, zaptel-source packages from the repository and assemble modules for your system:

$ sudo apt-get install zaptel zaptel-source
$ sudo module-assistant prepare
$ sudo m-a -t build zaptel

The zaptel-modules-*_i386.deb package will appear in /usr/src, install it with dpkg. After that, we check the operation of the kernel modules:

$ sudo depmod -a
$ sudo modprobe ztdummy

And if you need device support:

$ sudo modprobe zaptel
$ sudo modprobe wcfxo

To ensure their automatic loading, run the following command:

$ echo "ztdummy\nzaptel\nwcfxo" >> /etc/modules

Create rules for UDEV:

$ sudo mcedit /etc/udev/rules.d/51-zaptel.rules

KERNEL="zapctl", NAME="zap/ctl"
KERNEL="zaptimer", NAME="zap/timer"
KERNEL="zapchannel", NAME="zap/channel"
KERNEL="zappseudo", NAME="zap/pseudo"
KERNEL="zap0-9*", NAME="zap/%n"

You can also use the source code or the CVS version of the driver. When compiling yourself, you will need the kernel header files (or source texts):

$ sudo apt-get install linux-headers-`uname -r`

$ sudo ln -s /usr/src/linux-headers-2.6.20-15-generic /usr/src/linux-2.6

Now we get the latest version of the drivers:

$ cd /usr/src
$ wget -c downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz

Compile and install:

$ tar xzvf zaptel-1.4-current.tar.gz
$ cd /usr/src/zaptel-1.2.17.1
$ ./configure
$make
$ sudo make install

And in order not to manually create configuration files:

$ sudo makeconfig

After this command, a script will be created to automatically start the modules that are part of Zaptel, and the config /etc/default/zaptel (or /etc/sysconfig/zaptel) will be created, which will indicate which modules need to be loaded. I recommend leaving only what is necessary in this file. Trying to load the module:

$ sudo modprobe ztdummy
$ lsmod | grep ztdummy
6184 0
zaptel 189860 1

Everything is fine. After installation, two more files will appear in the system:

  1. /etc/zaptel.conf - describes the hardware configuration;
  2. /etc/Asterisk/zapata.conf - server settings Asterisk for the Zap channel driver to work.

Detailed instructions for various devices are given in the documentation. In Russian, you can read about this in the document “Asterisk% 0A+config+zaptel.conf">Zaptel kernel driver configuration". But we don't stop there, we still have a lot of work ahead of us. After configuration, we check the work with the ztcfg -vv command.

User Registration

If we now look in the /etc/ directory Asterisk, you can find a large number of files. But the size of a journal article will allow us to get acquainted with only some of them. Yes, in Asterisk.conf specifies the directories that will be used Asterisk during operation, the location and owner of the socket used to connect the remote management console, as well as the default parameters for starting the server. Some directories are not created during installation, this will have to be done manually:

$ sudo mkdir -p /var/(run,log,spool)/Asterisk
$ sudo adduser --system --no-create-home Asterisk
$ sudo addgroup --system Asterisk

Add a user Asterisk to the audio group:

$ sudo adduser Asterisk audio
$ sudo chown Asterisk:Asterisk /var/run/Asterisk
$ sudo chown -R Asterisk:Asterisk /var/(log,spool)/Asterisk

Next, we are interested in the sip.conf file, which defines the SIP servers and clients with which our Asterisk. Each of them is represented in the file by a separate block, which begins with a table of contents enclosed in square brackets. There are quite a few parameters in sip.conf, we will limit ourselves to adding a SIP account:

$ sudo mcedit /etc/Asterisk/sip.conf


type=friend
host=dynamic
; defaultip=192.168.1.200
username=grinder
secret=password
language=ru
nat=no
canreinvite=no
context=office
callerid=grinder<1234>
[email protected]
; disable all codecs before using the allow parameter
disallow=all
; the order of the codecs does not matter
allow=ulaw
allow=alaw

The type field specifies what this client can do. With the value user, he will only be allowed to receive incoming calls, with peer, he will only be able to make calls, and friend means all actions at once, that is, user + peer. The host field specifies the IP address from which this client is allowed to connect. If it can connect from any address, specify host=dynamic. And in order to call the client in this case, when it has not yet been registered, in defaultip you should write the IP address by which it can always be found. In username and secret we specify the login and password used by the client when connecting. The Language parameter specifies the greeting language code and specific settings for phone tones,
which are defined in the indications.conf file. When the client is behind NAT, the corresponding field must be set to yes. Disabling canreinvite causes all RTP voice traffic to go through Asterisk. If clients support SIP re-invites, they can be allowed to connect directly by specifying canreinvite=yes. The context field defines the dialing plan that calls coming from this client fall into, and callerid is the string that will be displayed when calling from the client. By default, the default context is used, which takes all the settings from the demo context. The latter is intended for demonstration purposes only, you need to create your own context in the working system.
The mailbox field points to voice mailbox 1234 in the office context. Other clients are configured similarly.
After defining SIP accounts, our clients can register on the server Asterisk and make outgoing calls. In order for them to be able to receive calls, you should refer to the extensions.conf file, which describes the dial plan (Dialplan) that distributes calls in the system. All allowed extensions are also listed here.

$ sudo mcedit /etc/Asterisk/extensions.conf


include => default
exten => 1234,1,Dial(SIP/grinder,20)
exten => 1234,2,Voicemail(grinder)

Everything is simple here. We assign the number 1234 to the grinder user, and if he does not answer the call, he can leave a message in his voice mail. The number after the number indicates the priority, which determines the order in which the tasks are to be performed. Now if Asterisk is running, you should connect to its console by executing on the same machine Asterisk-r, and use the reload command to force it to reread the configuration files. There are also commands to reload a specific file. For example, the dial plan is reread with the extensions reload command.

The server is ready to receive clients. At Asterisk%0AAsterisk%0A _softphone.html">www. Asterisk guru.com/tutorials/configuration_ Asterisk _softphone.html choose a soft client and try to connect. For example, I like the free version of ZoIPer (formerly Idefisk), a simple and easy-to-use program. There are versions for Linux, Windows and Mac OS X. Another good and also multi-platform client is X-Lite.

If everything is fine, a message like “Registered SIP "grinder" at 192.168.0.1 port 5060” should appear in the console, dial the number and call.

We customized Asterisk in the minimum configuration, but this is far from all that it can. Behind the scenes, there was a connection to another IP telephony server, call parking, music while waiting, billing, using the GUI to administer the server, and so on, but we will try to fill these gaps in the following articles.


Asterisk is a complete software PBX. It can run on operating systems such as Linux, BSD, Windows and OS X and gives you all the features that a regular PBX has and more. Asterisk is based on protocols that enable Voice over Internet Protocol (VOIP) networks and, due to this, this PBX can work with almost any IP telephony equipment that uses standard protocols for VOIP, while using relatively inexpensive hardware. security.

Asterisk provides voice mail (Voicemail), conferencing, interactive voice menu (IVR), call center and processing (Call Queuing). It also has support for services such as call transfer to another subscriber, the service for determining and transmitting the caller ID (callerID) to the called subscriber, ADSI protocols, (both in terminal mode and in gate mode), (only for call manager) and SCCP /Skinny (not completely). See the Features section for a more complete list of features that Asterisk can perform.

Asterisk does not need any additional hardware to implement voice over IP (VOIP). You can use a single (or multiple) VOIP providers for incoming and/or calls (incoming and outgoing calls may be handled by different Internet and/or regular telephony providers)

To enable communications between digital and analog telephony equipment, Asterisk has support for several hardware devices that can be referred to as equipment manufactured by the Asterisk project sponsor, Digium. Digium manufactures single and quad and interface boards for communications with and . In addition, interfaces are produced, from one to four ports per card, for communication with analog telephone lines and which are popular when building a small PBX. Interface devices from other manufacturers can be used for channeling (ISDN2) with four and eight ports if they are CAPI compliant or based on the HFC chipset.

And finally, for the rest of the range of tasks, including expanding FXO or FXS ports, you can use stand-alone devices with FXO or FXS ports that can simply be connected to an IP network and registered with Asterisk as telephone channels.

Previous stable version of Asterisk - Asterisk v1.2|1.2.40
Previous stable version of Asterisk - Asterisk v1.4|1.4.41
Previous stable version of Asterisk - Asterisk v1.6|1.6.2.16.1
Previous stable release of Asterisk - Asterisk v1.8|1.8.2.1
The previous stable version of Asterisk was Asterisk v11|11.25.1
The current stable version of Asterisk is Asterisk v13|13.15.0
The next (not stable) release of the Asterisk server is Asterisk 14|14.4.0
In development version of Asterisk - Asterisk 15

Start

Introductory information
: - THIS IS THE BEST PLACE TO START!. third party developers. FAQ and solution help: Looking for answers to your questions? Search here too. Asterisk tips and tricks: Solutions to various problems and tips on what else can be done with this software. Local information resources in your region. News, Project status and history of its development. Asterisk Linux Mailing Lists 101 : Some documentation on Linux for beginners (eng). Overview of non-technical aspects of Asterisk - Basic information and analyzes (eng). Asteriskguru Tutorials A huge collection of documentation on the asterisk server (eng).
Hardware
Asterisk phones: Phones commonly used in conjunction with the Asterisk server. : Hardware tested for compatibility with Asterisk. : How much processing power is needed and how many simultaneous calls can the system withstand? Hardware use cases: Recommended hardware for various needs. : Video support in Asterisk. Asterisk text: Support for sending text messages to Asterisk. Asterisk legacy integration: How to connect Asterisk and a regular PBX Asterisk Embedded Systems: Asterisk server on simple (exotic) hardware. Asterisk and VoIP GSM gateway: How to connect a VoiceBlue VOIP GZM gateway to an Asterisk server. Asterisk and Cable Modems with embedded ATAs: How to connect embedded ATA to an Asterisk server.
Administration
. Q: What processor do I need, how many concurrent calls can my hardware handle? : (SIP proxy, load sharing). A: Asterisk and SIP connections over NAT. billing support. - configuring Asterisk using database Configuring Asterisk using template files. Asterisk password files: Where can you find descriptions of users and their passwords in Asterisk configuration files? : a section created to help you find the PBX feature you need in Asterisk. Asterisk QoS: how Asterisk supports QoS.
Asterisk rollout tips: Help to move from testing to practical use. Asterisk security: The security of your PBX. : Monitor the server and periodically check its health. Asterisk High Availability Solutions: Software and hardware solutions to increase server reliability. Asterisk Bootable CDROM: Boot and start the Asterisk server from CDROM. Asterisk OS Platforms: What operating systems can Asterisk run on.

Links

Configuration
: Full list! : Description of Asterisk configuration files. : Variables used in configuration and dial plan. : Embedded database used in the dial plan. - Asterisk configuration using a database. Asterisk configuration using template files. : Powerful scripting interface. : Asterisk Extension Language : Asterisk Extension Language version 2 - configuring Asterisk to support DUNDi and SIP connections - configuring Asterisk to work with Ranch Networks devices using the MIDCOM protocol

How to set up an Asterisk server connection with other VOIP providers. Asterisk Configuration Examples: Complete Asterisk configuration examples from various users. Asterisk Data Configuration: Zaptel and Asterisk data and hybrid configuration Notes on configuring the Asterisk server to work with some specific phones. Asterisk Slimming: How can we slim-up about so many modules Asterisk tips and tricks: Lots of examples of solving various problems using configuration files.

Management: Supported codecs. Asterisk libpri: Open Source library. Asterisk Paging and Intercom. : Standard sound files and their purpose. Asterisk multi-language: Notes on multilingual Asterisk server configuration. Asterisk vertical service activation codes: *XX ​​codes used in Zap channels.
Asterisk debugging: How to get debug information in Asterisk. Asterisk PSTN interface debugging: Issues with echo, signal strength, etc.
  • Clients can't get through to you? Asterisk + Internet multiline phone number and your customers will no longer hear a busy signal. All calls will be accepted.
  • Consolidation of branches into a single telephone network! Free calls between offices across the country or even the world using short numbers for a specific employee*
  • Big bills for communication services? Asterisk + voip provider and bills won't bother you anymore.
  • High cost of business calls? Astersk + sip-client on your mobile phone or computer and you call colleagues in the office for free, and in other directions - at the rates of the operator providing communication services in your office*
  • Need to connect remote employees? Asterisk + ip-phone or sip-client - and you call them and they call you for free by a short number, like colleagues in the office *
  • The secretary does not have time to process calls and cannot prepare coffee for you? There is a solution - Asterisk + interactive voice menu! It will relieve your secretary and make it easier for clients to connect with the right department or employee.
  • Missed an important call? Asterisk + flexible call forwarding and it won't happen again!
  • Managers spend a lot of time calling customers? Asterisk + and numbers are dialed automatically from your contact list!
  • Worried about information leakage or staff honesty? Asterisk + call recording and security department are thrilled!

    * - you pay only for Internet access services.

These and not only tasks can be solved by a modern ip-telephony system based on a free product - Asterisk software telephone exchange.

What is Asterisk?

For the organization of office telephony, we bring to your attention solutions based on the free Asterisk IP-PBX software telephone exchange from Digium, which has all the features of a classic PBX, as well as powerful additional functionality available only in expensive corporate-level hardware PBXs. At the same time, Asterisk is quite affordable for small and medium businesses - the cost of its deployment is comparable to the cost of installing a conventional office PBX.

Both software and hardware VoIP phones, as well as conventional analog telephones, SIP-DECT microcellular communication equipment can be used as terminal devices. Integration with the existing hardware automatic telephone exchange is possible.

Asterisk is not demanding on hardware resources and can be deployed on a simple personal computer, netbook, or virtual machine. In the case of using VoIP phones, it is not required to lay SCS for analog telephony, you can use a regular computer network.

Asterisk is a flexible system that can change and adapt to any future requirements. As the business grows, Asterisk will scale up and grow with it.

Features of Asterisk IP-PBX:

  • call switching according to set rules with extremely flexible capabilities (almost anything is possible), including call routing to the operator with the lowest call cost
  • transfer, parking, forwarding, intercepting calls, follow me lists, groups (hunt, ucd, etc.);
  • call center functions (queuing calls and distribution among operators);
  • interactive voice menu (IVR);
  • answering machine, voice mail, sending messages to e-mail;
  • conference call;
  • callback (Call Back), as well as access to various directions of calls by pin-code;
  • reception of faxes to e-mail, fax server;
  • recording telephone conversations;
  • call log (CDR);
  • call reporting and statistics;
  • support for a variety of VoIP protocols and codecs (SIP, H.323, etc.);
  • the ability to connect to VoIP providers (Sipnet, Skype, etc.);
  • connection to the PSTN via both analog lines and E1 streams;
  • support for any end devices (conventional analog, mobile, hardware and software VoIP phones);
  • integration with hardware PBXs via VoIP or E1 using standard interoffice protocols;
  • unification of remote offices into a single telephone network;
  • providing remote, mobile employees with an internal office phone;
  • integration with Microsoft Outlook and other applications that support the TAPI interface
  • integration with external systems and software (1C products, CRM systems, Internet site, etc.).

An example of programming the logic of an incoming call from city lines:


For small businesses, we offer an inexpensive solution based on IP PBX Yeastar S20.
For medium and large companies, as well as for those who need flexibility and scalability, we offer a universal solution that can be installed on a virtual machine or a physical server. As a result, the customer receives guaranteed fresh stable software (CentOS, Asterisk, FreePBX) installed in his working environment.

Basic implementation cost:

19,500 rubles

including VAT 18%

The base price includes the following:

  • Installation of Asterisk on the customer's equipment or virtual machine (includes installation of the latest stable versions of CentOS, FreePBX, Asterisk)
  • Connecting to a sip provider
  • Create up to 20 internal numbers and set up IP phones*
  • Typical call switching, transfer, call pickup
  • Voice greeting with the possibility of dialing internal numbers
  • Fax reception by e-mail
  • Voice mail with sending messages to the subscriber's e-mail
  • Web access to call statistics and station management (FreePBX)
  • Recording telephone conversations
  • Delivery and installation of the server to the customer's site (Moscow and the nearest Moscow Region)

*- with self-configuration, it is possible to reduce the cost of implementation to 16500 rub.


To manage Asterisk, we use the FreePBX system with our own modifications that increase the usability of ip-telephony.

We offer well-established Yealink telephones as terminal equipment. Our company is the official dealer of this brand and we are ready to offer you devices at a bargain price.

As gateways for connecting to classical telephony, we use the well-proven equipment Linksys, Cisco.


On the Internet, you can find many instructions for. And they help set up and manage the PBX in most cases. But setting up a “clean” Asterisk gives you much more options.

In the article, we will do the basic configuration of Asterisk through the configuration files. It is assumed that we have already installed and initially configured the OS, downloaded and installed the dahdi, libpri, iax2 modules, the necessary voice files and codecs, and installed Asterisk.

If you have not installed anything yet, then take a look at our article

You will also need it for tracing and debugging SIP messages. Let's go?

Theory

So, let's start implementing Asterisk. The structure of directories used by Asterisk is as follows:

  • /usr/lib64/asterisk/modules– here are the loadable modules;
  • /var/log/asterisk– log files are located here, including the call log (if not configured otherwise);
  • /var/spool/asterisk- there are subfolders that contain backups, call recordings, voice mail, faxes, and so on;
  • /var/lib/asterisk- there are subfolders that contain audio files for music on hold, audio files for selected languages ​​(for example, for playing voice messages in IVR), recorded voice messages for greetings, and so on.

The configuration files are located in the /etc/asterisk folder. Each Asterisk module requires a configuration file to work. These files (with the .conf extension) contain channel definitions, describe various internal services, locate other modules, and communicate with the dialplan. It is not necessary to customize all files. Require configuration only those that are necessary for your configuration.

Main configuration files:

  • asterisk.conf- defines global parameters, directories and options for starting Asterisk;
  • cdr.conf– defines settings for writing call parameters to a file or database;
  • sip.conf– defines the settings for using the SIP protocol (both general and parameters for registering providers, internal users, and so on);
  • rtp.conf– defines ports for voice (RTP);
  • iax.conf– defines settings for using the IAX protocol (both general and parameters for registering providers, internal users, and so on);
  • extensions.conf- the main file, which describes the entire dialplan, that is, the rules for processing all calls;
  • features.conf– describes additional features (forwarding, call parking, enabling recording on demand, and so on);
  • logger.conf– defines the type and detail of messages written to the log files;
  • modules.conf- determines which modules will or vice versa will not be loaded when Asterisk starts;
  • musiconhold.conf– used to configure the different music classes used in idle music applications and their locations;

Recall that this is only a part of the configuration files. Necessary files can be added at any time as needed. Examples and contents of such files can be found in the archive by clicking the button below:

Download archive

Immediately after installing asterisk, if you did not choose to install the basic configuration, there is not a single file in it.

To connect to asterisk in command line mode, enter

Asterisk -rvvvvv

  • r– connection to an already running process;
  • vvvvv- the level of logging, that is, the output of information (from the word verbose - v). The more v we set, the more detailed information will be displayed on the command line;

Creating and editing the necessary files

Let's start with a file asterisk.conf:


  • (!) - specify the location of the necessary directories. The sign (!) indicates the attribute of the template. The template specifies general settings that can be referenced further.
  • - specify the necessary options, one of the required maxcalls indicates the number of simultaneous calls allowed on Asterisk;
    • transmit_silence_during_record = yes- transmit silence to SLINEAR during channel recording;
    • languageprefix = yes | no- Should the language code be the last or the first component of the sound file name? If disabled, sound files are searched in // format; If enabled, search is performed in // format;
    • execincludes=yes | no- Allow #exec entries in configuration files;
    • hideconnect=yes | no- Show a message about connecting remote consoles;
    • dontwarn=yes | no- Disable warnings (warning messages);
    • debug = no- Debug: No or value (1-4);
    • maxcalls = 10- Maximum number of simultaneous calls;

Getting to the file cdr.conf. Comments on options in the config:

enable=yes ; turn on the very possibility of logging calls unanswered=no ; unanswered calls are not logged safeshutdown=yes ; when the server is turned off, we will wait until ALL logs are written usegmtime=yes ;date/time log in GMT format. Default NO loguniqueid=yes loguserfield=yes

Finished. Now the file features.conf:

; here we describe the functions used and their parameters blindxfer => ## ; unconditional translation atxfer => *2 ; conditional translation automon => *1 disconnect => ** parkext => 700 ; parking parkpos => 710-780 ; port range for parking context => parkedcalls ; context for handling parked calls parkingtime => 180 ; parking time comebacktoorigin => no ; return the call to the initiator when the call parking time has expired parkedplay => both ; who to play the courtesytone when the call is removed from the parking lot. Options: callee, caller, both or no (default) parkedcalltransfers => caller ; Who can transfer a parked call using DTMF. Options: callee, caller, both or no (default) parkedcallrepark => caller ; Who can park a parked call using DTMF. Options: callee, caller, both or no (default) parkedcallhangup => no ; Who can end a parked call using DTMF Options: callee, caller, both or no (default) parkedcallrecording => no ; Who can initiate the recording, using DTMF. Options: callee, caller, both or no (default). parkedmusicclass => default ; Waiting music class for parked, adsipark => no ; Whether or not to pass ADSI info about a parked call to the person who parked findslot => first pickupexten => *8 ; call pickup; here we describe the applications used sendsms => *99,peer/both,Macro,sendsms pitch => *00,self/both,Macro,pitch

Now we configure RTP in the file rtp.conf

rtpstart=36600 rtpend=39999

Music on hold in the building. Opening the file musiconhold.conf

Mode=files directory=/var/lib/asterisk/moh/

Next, open the file logger.conf:

Console => notice,warning,error,dtmf,verbose(5) ; verbosity level of messages output to the console full => debug,notice,warning,error,verbose(9),dtmf,fax,security ; level of detail of messages output to the log file

And finally, the file modules.conf. There are 2 options: either read all modules and specify those that do not need to be read:

Autoload=yes noload => codec_g723-ast110-gcc4-glibc-x86_64-core2-sse4.so

Or we specify specific modules that need to be read and forbid reading all. In this case, for convenience, it is better to divide the modules into sections. Below is part of such an option:

autoload = no ; Applications load = app_bridgewait.so load = app_dial.so load = app_playback.so ; Bridging load = bridge_builtin_features.so load = bridge_builtin_interval_features.so load = bridge_holding.so ; Call Detail Records load = cdr_custom.so ; Channel Drivers load = chan_bridge_media.so load = chan_sip.so ; Codecs load = codec_gsm.so load = codec_ulaw.so load = codec_alaw.so load = codec_g722.so ; Formats load = format_gsm.so load = format_pcm.so load = format_wav_gsm.so load = format_wav.so ; Functions load = func_callerid.so load = func_cdr.so load = func_pjsip_endpoint.so ; Core/PBX load = pbx_config.so ; Resources load = res_musiconhold.so load = res_pjproject.so load = res_pjsip_acl.so

In this article, we use the first option. On this, with the configuration of the main files, we will finish. Later, as needed, you can make changes to them. We will make all subsequent settings in the files sip.conf And extensions.conf. We drove to the creation and registration of internal subscribers.

Creating and registering extensions

IN sip.conf first specify the general SIP parameters for Asterisk:

Bindaddr=0.0.0.0 ; specify the IP address and port on which bindport=5060 will be received; SIP traffic language=ru ; used language for voice messages alwaysauthreject=yes allowguest=no ; we prohibit receiving “guest” calls, that is, calls from unregistered users

Also in this section, you can specify whether video is supported, registration time, list local networks, specify the external IP address in case of using NAT, and so on.

In the case when we have different groups of subscribers (for example, there are several departments, subdivisions, or some other signs of a grouping of subscribers or a large number of subscribers), it is recommended to use templates in which you can make generalized settings.

The template name is taken in brackets and followed by (!) . In the template, you can specify the context for these subscribers, the codecs used, the allowed/denied networks for registering these subscribers, the use of NAT, and so on. An example template is shown below:

(!) type=friend deny=0.0.0.0/0.0.0.0 permit=192.168.10.0/255.255.255.0 host=dynamic context=from-internal nat=no qualify=yes directmedia=no disallow=all allow=alaw allow=ulaw dtmfmode=info

And there can be several such templates. Now, to create a record for registering subscribers, we only need to specify distinctive parameters, such as extension number, subscriber name, password for registration, and so on.

[NUMBER](PATTERN) callerid=NAME secret=PASSWORD callgroup=5 ; call group number pickupgroup=1,2,3,4,5 ; call pickup group numbers

Setting example:



As a result, on command sip show peers we see registered users

Subscribers have registered, but they still cannot call even among themselves. In order for them to make and receive calls, you need to configure routing (or dialplan). We will do this in a file extensions.conf, it also has its own structure. And here we again dive into the theory a little:

The dialplan consists of the following main elements:

  • contexts;
  • extension numbers;
  • priorities;
  • applications;

Context– a part (section) of the dialplan that describes the call processing algorithm and is isolated from the rest of the dialplan. Contains additional numbers (extension). Extensions defined in one context are completely isolated from extensions in another context unless specifically allowed. Also, using contexts, you can restrict access to various functions (for example, to long-distance or international calls). The context name is enclosed in square brackets . It is recommended to create different contexts for internal subscribers and for trunks.

At the beginning of the dialplan are two special contexts, And

  • – contains a list of general dialplan settings;
  • – contains global variables;

These two contexts are special. The context is one of the mandatory parameters for both the subscriber and the trunk.

Asterisk determines the context for processing according to the principle where the call came from, and not where it came from, that is, if a call came to a mobile number from a subscriber, then the context that is registered with a particular subscriber will be applied, and not specified in the trunk.

Extension numbers is a broad concept that defines unique sequences of steps (each step includes an application) that Asterisk will apply to a call on that line. Each context can have as many extensions as required. When a specific extension is called (either by incoming or internal call), Asterisk will follow the steps defined for that extension. Therefore, it is extension numbers that determine what happens to calls when they are processed according to the dialplan.

A complete extension has three components:

  • Name (or number). Any combination of numbers and letters can be used as a name;
  • Priority(each extension can include many steps; the sequence number of a step is called its priority);
  • Applications(or command) that performs some action on the call;

These three components are separated by commas:

Exten => name,priority,application()

There are also reserved extensions:

  • s- when calls arrive in the context for which no specific extension is specified, they are routed to extension s. (s is short for start), since this is where call processing will begin if no extension information is sent.;
  • i- when the subscriber presses the wrong button (non-existing extension), the call is routed to extension i;
  • t- if the caller does not press the button for too long after starting the WaitExten() application, the calls are routed to extension t (the default timeout is 10 seconds);
  • h- extension processed when the call ends. After the media channel has closed;

Sometimes you can find the use the same instead of exten. This is mainly used with automatic priority setting, that is, same => n and means "the same, continuation of the previous"

Priorities- sequence of application execution. Each priority is numbered sequentially, starting at 1, and runs one specific application. Asterisk has another priority n which means "next". Each time Asterisk encounters a priority n, it takes the number of the previous priority and adds 1. This makes it easier to make changes to the dialplan, because now you do not have to change the numbers of all steps.

Applications– performs a specific action on a specific extension (eg playing a sound, receiving tone input, calling a channel, disconnecting, and so on).

Some applications, such as Answer() and Hangup(), do not require any additional instructions to run. Some applications require additional information. These data, called arguments, can be passed to applications to influence how they perform their actions. To pass arguments to an application, they are separated by commas in parentheses following the application name.

To add comments to the extensions.conf file use ; - you could already guess this, judging by our comments right in the configs :)

In this way, you can both make notes for yourself and make configuration lines unexecutable (for example, during debugging)

Now let's get back to our created subscribers. Let's create a context that is specified for subscribers ( context=from-internal)

In it, we wrote that when dialing a number (NAME), with priority 1, execute the Dial application with the PROTOCOL / NUMBER parameters. When there are few numbers, then of course you can describe it that way. But it’s more correct and beautiful to do the same, but using a “mask”:

That is, when dialing any number from the 10xx range (the pattern is shown with an underline), make a call with priority 1 through the Dial application with the PROTOCOL/DIALED_NUMBER parameters, the call time is 60 seconds, and you can use the call transfer (transfer).

Number Template is a unique set of digits that defines the use of that number. If the dialed number matches this pattern, then subsequent numbers are not considered. Template filling format:

  • X- match any digit from 0 - 9;
  • Z- any number from 1 to 9;
  • N- match any number from 2 - 9;
  • - matches any numbers or letters and brackets (in this example, 1,2,3,7,8,9);

We reread the dialplan in the Asterisk console with the command dialplan reload and see the execution of the call.


Thus, we can come up with and implement almost any dialplan. For example, to bar international calls, it is enough to write 3 lines:

That is, when dialing 810, the destination-closed message (if it was loaded into Asterisk) will be played and a hangup signal will be sent.

Creating and registering trunks

Well, let's start with the fact that the IP trunks used in Asterisk come in 2 types - SIP and IAX.

SIP trunks are mainly used to connect ISPs, while IAX trunks are used to connect other Asterisks. Trunks can be with registration (that is, when the provider issues a login, password and address or domain for registration with him) and without registration (that is, when the connection goes to an IP address without a login and password). In the case of registration in a file sip.conf you must immediately after the section specify the registration string in the format:

Register => LOGIN:PASSWORD@SIP PROVIDER/NUMBER

  • SIP PROVIDER- either the IP address of the provider or its domain is indicated;
  • LOGIN: PASSWORD- issued by the provider for connection;
  • ROOM- the city number issued by the provider for making calls is indicated;

Consider creating a SIP trunk with registration. Again, if we have several (up to 3-5) such trunks, then we can describe them separately. And if there are more of them or in the future it is planned to increase their number, then you can use the template to connect to the operator.

(!); template name type=peer ; connection type context=from-trunk ; context to use for handling calls to disallow=all ; disable all codecs allow=alaw ; specify the codecs to use allow=ulaw insecure=invite,port ; do not require authorization for incoming calls qualify=yes ; check availability directmedia=no ; disable direct voice connections dtmfmode=rfc2833 ; specify the type of DTMF used, then it is enough to describe the specific settings for a particular operator and specify which template to use [OPERATOR-1](voip-provider) defaultuser=LOGIN-1 fromuser=LOGIN-1 secret=PASSWORD-1 host=DOMAIN1- OR IP ADDRESS TO CONNECT fromdomain= DOMAIN-1 OR IP ADDRESS TO CONNECT [OPERATOR-2](voip-provider) defaultuser=LOGIN-2 fromuser=LOGIN-2 secret=PASSWORD-2 host=DOMAIN-2 OR IP ADDRESS TO CONNECT fromdomain = DOMAIN OR IP ADDRESS TO CONNECT

Register => LOGIN-1:PASSWORD [email protected] DOMAIN-1/NUMBER-1 register => LOGIN-2:PASSWORD [email protected] DOMAIN-2/NUMBER-2

Rereading the file sip.conf and check registrations:

In case of connecting a trunk without registration, you can use the same template, and specify the parameters to be changed in the trunk settings

(voip-provider) type=friend ; for a trunk without registration, specify friend (that is, we trust this connection) port=5060 ; specify the port for connection insecure=port,invite host=IP-ADDRESS_PROVIDER context=from-trunk-sip-AST10SIP ; if a different context is used for processing calls through this trunk, then specify it here.

Rereading the file sip.conf and check registrations:

Now let's look at creating an IAX trunk. To configure IAX trunks, use the file iax.conf, which contains all the information Asterisk needs to create and manage IAX channels. Its structure is approximately the same as that of sip.conf:

; specify global parameters for the IAX protocol bindaddr=0.0.0.0 bindport=4569 ; by default, the IAX protocol uses port 4569, you can leave it, or you can override language=ru ; specify the lines for registering trunks register => msk-spb: [email protected] username = msk-spb ; login for registration on the remote side type = friend trunk = yes secret = SuperPASS ; password for registration qualify = yes host = 10.10.10.10 ; IP address of the remote side disallow= all context = from-iax ; context for handling calls coming through this trunk allow = alaw allow = ulaw

Saving the file iax.conf, reread and check the registration with the command iax2 show peers:

If there are subscribers working under the IAX protocol, then we also describe their registration in the same file similarly to SIP registration.

So, now we have registered subscribers who can call each other, and registered trunks. We can group internal subscribers by departments:

Exten => 500,1,Playback(it-department) ; play message it-otdel exten => 500,1,Dial(SIP/1001,5),Tt ; 5 seconds the call goes to number 1001 exten => 500,n,Dial(SIP/1002&SIP/1003) ; then the call goes simultaneously to 1002 and 1003

We can configure various functions, run various commands (including those for execution through the OS), set up recording and listening to conversations, and so on:

; answer, wait 2 seconds and hang up exten => 060,1,Answer() same => n,Wait(2) same => n,Hangup() ; answer, play hello-world message and hang up exten => 061,1,Answer() same => n,Playback(hello-world) same => n,Hangup() ; write a message to file somefile.gsm and then play it back exten => 067,1,Record(/tmp/somefile.gsm,3,30) same => n,Playback(/tmp/somefile)

To make calls through the created and registered SIP and IAX trunks: Suppose we have another Asterisk connected through the IAX trunk with internal numbering starting from 1, 2, 3. And to call these subscribers, we will use the prefix (route exit code) 2. Then the configuration lines will be as follows:

Exten => _2.,1,Dial(IAX2/msk-spb/$(EXTEN:1),30,r) exten => _2.,2,Hangup()

That is, when dialing starting from 21-23, a call will be made through the msk-spb trunk using the IAX protocol of the dialed number, after "cutting off" 1 (the first) dialed digit. If no answer is received within 30 seconds, the call will be terminated.

To enter the city, we use a trunk with operator-1 and we will use the exit prefix 9

Exten => _9849XXXXXXX,1,Dial(SIP/OPERATOR-1/$(EXTEN:1)) ;that is, when dialing starting with 9, a call will be made through the OPERATOR-1 trunk using the SIP protocol of the dialed number, having previously "cut off" 1 (first) dialed digit

It is important to understand here that everything that we implement for internal subscribers must be described in the appropriate context.

Now let's move on to trunks and incoming calls. Accordingly, in order to receive incoming calls, it is necessary to register routing already in the trunk context ( context=from-trunk or context = from-iax)

In order to be able to call our internal subscriber through the trunk (for example, through the trunk from the opposite PBX), it is necessary to insert into the context of the trunk exten => _10XX,1,Dial(SIP/$(EXTEN),60,tTm)

Let's consider the implementation of processing an incoming call from an operator (a call to a landline number) through the creation of an IVR menu and also implement the definition of working and non-working hours. The incoming call processing scheme is as follows:

Our working hours are from 9:00 to 19:00 and from Monday to Friday. When a call arrives outside of business hours, after the greeting message (01-hello), a message with the working time (07-working-hours) is played. When a call is received during working hours (checking is carried out in the line GoToIfTime(09:00-19:00,mon-fri)) after the greeting, a transition to another context is performed ( ), where you are prompted to select the required menu item (0 - call the secretary, 1 - call to the technical support group, 2 - go to another selection menu (GoTo (ivr-2, s, 1)), in which, according to the same principle, selection.In each menu, additional dialing of internal numbers is implemented (exten => _1xхx,1,NoOp), processing of incorrect number dialing (exten => i,1,NoOp), processing in case that nothing is selected (exten => t, 1,NoOp), the call is transferred to the secretary.

Naturally, it is necessary to load all used voice files into /var/lib/asterisk/sound/ru in case of using the Russian language. Here, let's get a little more detailed.

As we already indicated above in the system, we determined which main language we will use for voice files (in the file sip.conf parameter language = en). This means that Asterisk will look for the filenames that we specify, for example, in the ivr menu in the folder /var/lib/asterisk/sound/ru(look at the directory designations when starting asterisk at the beginning of the article). If we used English as the main language, then the folder would be /var/lib/asterisk/sound/en. Each of these folders contains voice files in the selected languages ​​and in the selected formats specified when compiling asterisk. If we want to record our messages (personal greetings, necessary announcements spoken in the ivr menus we create, and so on), we need to put these files in the appropriate language folder. At the same time, the files themselves can be recorded with any recording program (even though the program sound recording included in the standard distribution of any version of Windows) and save in wav format (uncompressed voice, 8kHz, 16bit, Mono)

The main thing here is not to confuse the names of the files in the folder with voice messages with the names indicated in the ivr menu. at the same time, in the ivr menu, the names are indicated without an extension. The listing is below.

Exten => _X.,1,NoOp(Time check: If it is in the range, go to the working-time context, if not, continue execution) same => n,Answer() same => n,Playback(01-hello) same => n,GoToIfTime(09:00-19:00,mon-fri,*,*?working-time,s,1) same => n,Playback(07-working-hours) same => n,Hangup () exten => s,1,Answer() same => n,Background(01-ivr1) same => n,StartMusicOnHold() same => n,WaitExten(5) ; exten => 0,1,NoOp(If you press "0" - call the secretary) same => n,Playbacr(ostavaites-na-linii) same => n,Dial(SIP/1005,30,mtT) same => n ,Hangup() ; exten => 1,1,NoOp(If you press "1" - call the call group: 1001+1002) same => n,Playback(it-otdel) same => n,Dial(SIP/1001&SIP/1002,30, mtT) same => n,Hangup() ; exten => 2,1,NoOp(If you clicked "2" - redirect to ivr-2) same => n,GoTo(ivr-2,s,1) ; exten => _1xxx,1,NoOp(Direct extension dialing) same => n,Playback(ostavaites-na-linii) same => n,Dial(SIP/$(EXTEN)15,mtT) same => n,Hangup () ; exten => i,1,NoOp(Handling erroneous dialing:i=illegal) same => n,Playback(oshibka) same => n,Dial(SIP/1005,30,r) ; exten => t,1,NoOp(In case you didn't wait for the press) same => n,Playback(ostavaites-na-linii) same => n,Dial(SIP/1005,30,m) ; exten => s,1,Background(02-ivr2) same => n,StartMusicOnHold() same => n,WaitExten(5) ; exten => 1,1,NoOp(If you press "1" - call 1001) same => n,Dial(SIP/1001,30,mtT) same => n,Hangup() ; exten => 2,1,NoOp(If you press "2" - call 1002) same => n,Dial(SIP/1002,30,mtT) same => n,Hangup() ; exten => _1xxx,1,NoOp(Direct extension dialing) same => n,Dial(SIP/$(EXTEN)15,mtT) same => n,Hangup() ; exten => i,1,NoOp(Handling erroneous dialing:i=illegal) same => n,Playback(oshibka) same => n,Dial(SIP/1005,30,r) ;

After saving the extensions.conf file, re-read the dialplan in the console (dialplan reload) and check. This concludes the examples.

Configuring Asterisk through configuration files, we get the opportunity to implement almost any logic of work, integrate with third-party services, run and execute scripts at the OS level, and so on.

Is this article helpful to you?

Please tell me why?

We are sorry that the article was not useful to you: (Please, if it’s not difficult, indicate for what reason? We will be very grateful for a detailed answer. Thank you for helping us become better!

Today we start a series of articles about Asterisk. And first of all, it makes sense to figure out what Asterisk is and what it is for.

Asterisk is a cross-platform computer telephony solution. In fact, this is a software PBX. In combination with certain equipment, it is able to provide all the features of a classic office PBX.

A bit about the history of Asterisk

Asterisk appeared thanks to Mark Spencer in 2004. His company couldn't afford a call center system, so Mark Spencer started thinking about building a software-based PBX. Moreover, a curious feature of the program was that it was released with open source. Accordingly, Asterisk continues to evolve thanks to people around the world.

Asterisk is distributed free of charge, which only adds to its popularity.

At the moment, Asterisk is the most common software-based PBX in the world. Many companies choose to work with Asterisk due to the flexibility and efficiency of the resulting communication.

What can Asterisk do?

Since Asterisk is a PBX, it provides the standard PBX functions:

1. Outgoing and incoming communication;
2. Internal communication (extensions for employees).

Among other things, Asterisk provides the ability to independently or with the help of a specialist to configure a number of additional functions:

1. Unlimited number of subscribers. You can connect the number of employees you need.

2. Saving the number when moving. Asterisk allows you to save the phone number by which most customers recognize you, even if you move.

3. Recording telephone conversations. You can customize the recording of name conversations as you need. Recording conversations will allow you not only to track the performance of employees, but also objectively resolve conflict situations.

5. Integration with CRM will become an important tool in working with clients, since your employees will be able to receive any data about the client who called and instantly find out how to conduct a conversation with the client.

6. 8-800 and a call back will help emphasize the company's customer focus. Of course, your customers will appreciate your desire to take all the costs of communication on yourself. Thanks to these features, your customers will contact your company with great enthusiasm.

7. Call from the site. If you decide to set up this function, you will immediately feel all the convenience of calling from the site. After all, now any client, if he did not have a phone at hand, will still be able to contact your company and get expert advice.

8. The call queue will allow you to prioritize the urgency of a particular call, because thanks to this function you can leave a call on the line, and the client at this time will receive interesting information or enjoy music.

9. Statistics. This function will be especially useful for obtaining statistical data on the time of calls, their number, the most active customers. Thanks to automatically collected statistics, you will be able to assess when customers are most active and optimize the work of managers.

10. Fax to mail. If you are interested in processing information received by fax as quickly as possible, then the function of redirecting fax to e-mail will be simply indispensable.

11. Videoconferencing and conferencing will become important business tools, especially if your company has a network of branches or partners throughout the country and abroad. All negotiations will become much more convenient, and meetings will be held more quickly.

Benefits of Asterisk

1. Savings. Perhaps this is the main advantage. Buying a real PBX will cost at least 5 times more than working with Asterisk. In addition, you do not have to spend money in order for the next function of your PBX to start working and benefit the company.

2. Connection of remote offices. It becomes much easier and more profitable to establish communication between offices or branches of the company.

3. Connection to any telephony operator, both IP and analog. You can choose exactly the telephony that meets all your requirements. Asterisk is suitable for any telecommunications solution.

4. No need for a lot of equipment and wires. To make Asterisk work, you do not have to pull endless wires, since this software only needs the wire that you already have - the Internet.

5. Flexibility and scalability. This is a very serious plus of Asterisk. After all, if you want to expand the number of subscribers or make some adjustments to the functionality of a conventional PBX, you will have to buy additional equipment and spend a long time dealing with a very complex setting, which will most likely require a specialist call. With Asterisk, there is no such problem, you can easily change the functionality and number of subscribers, thanks to the flexibility of the platform and the scalability of Asterisk.

As a result, we can say that using Asterisk to solve telecommunications problems is a good choice for a successful company. And in a duet with IP telephony, Asterisk will allow you to quickly, efficiently and profitably organize communication in your company, regardless of its scale and objectives.

© 2022 hecc.ru - Computer technology news