Office Telephony on Asterisk + FreePBX


For some political reasons, I faced the task of transferring the telephony of our office from the Panasonic KX-TDA200 hybrid analog PBX to SIP. The presence of SCS in the office simplified the task, and complicated the use by operators of panels with buttons for quickly switching calls.

Considered options:
  • Upgrade PBX to KX-TDE Series
  • Buy something iron like Cisco or Avaya
  • Put Asterisk

As a free software proponent, I persuaded my superiors to accept the third option. Moreover, I just freed up a server that could be used for this task.

Purchasing and preparation

For communication with city telephone networks, an OpenVox DE130E board was purchased . Phones were purchased by Grandstream .

I put on the server:
  • Current version of debian
  • dhcp3-server - for distributing addresses and parameters to telephones
  • ntp - to provide phones with current time
  • tftp - to provide phones with firmware and configurations
  • mysql, apache, php - for FreePBX
  • build-essential - for building Asterisk


I decided to take Asterisk not from the package, but to assemble from the sources, since there was no certainty that it would work from the package with the OpenVox board.

DAHDI driver for OpenVox

Instructions for assembling and configuring the DAHDI driver are available on the openvox website ( PDF ). No ambushes were encountered. The piece of iron immediately saw the stream.


Asterisk I took version 10.9.0 (yes, they recently changed the principle of version numbering). I downloaded, unpacked, said ./configure; make menuconfig, just like in the old days for the kernel. First ambush - for menuconfig you need ncurses, newt or GTK. Moreover, since we compile from source, we need -dev versions of libraries (this is also true for all other packages delivered in the process).
The asterisk menuconfig is clear and convenient, if some component cannot be assembled, then it says what needs to be added in order for the assembly to work out. So, for example, it was necessary to deliver for the fax libspandsp-dev. Do not forget to restart after reinstalling the libraries ./configure. If the assembly requires additional files to be downloaded, they will be downloaded automatically.

For FreePBX to work, Asterisk must have a manager interface. You must remember to enable this module, and before installing FreePBX, put the sane password and permissions in the /etc/asterisk/manager.conf file.

So, all the components are selected, you can run the standard make; make install. Installing FreePBX will require us to already run asterisk, so let's say another make samples.

Attention! After that, when you start, you will get a completely live asterisk in the "for example" configuration, which is not a security example. In other words, close the firewall.

FreePBX requires that Asterisk and Apache spin from the same user, so create a user and asterisk group, write them to the Apache config. Permits to files FreePBX corrects itself.


Surprisingly, no rake appeared. I downloaded it, strictly according to the instructions, created the database, the user, ran the scripts, launched it. You can go to the settings interface.


Initial setup

On the first screen of the administration interface in the “FreePBX Notices” area, a bunch of messages fell out that / etc / asterisk contained a lot of configuration files that FreePBX should manage. I deleted these files (saved copies). When you click the big red “Apply Config” button, FreePBX generated the necessary files by itself.

Choosing FreePBX Modules

Went to the "Admin - Module Admin". Noted the Basic, Extended repositories, and just in case, Unsupported. I clicked on “Check Online” and got the opportunity to type modules for myself. In addition to the default ones, I chose:
  • Call Recording - for recording conversations
  • Conferences - for organizing conferences with passwords, etc.
  • Ring Groups - for group call processing (secretaries)
  • PBX End Point Manager - for creating phone configurations
  • Fax Configuration - to configure fax

Preparing phone settings

Group settings of phones are very conveniently done using the End Point Manager.

In Connectivity - End Point Configuration, you need to choose the manufacturer and model of phones that we use. Just for starters, you should click “Check for Updates”, as the project is quite lively and constantly releases new models.

Then in Connectivity - End Point Advanced Settings, you need to specify the path to the directory from where tftp distributes the files. And now there are several options:
  • You can connect all the phones, wait for the download and scan the network from the “Connectivity - End Point Device List”
  • When entering a device, you can fill in the End Point Manager section, specifying the MAC address and device model
  • You can add devices one at a time

I registered one phone for each model, edited the settings templates, and then, when I entered each device, I indicated its MAC address and selected the model and template. After that, End Point Manager generated the correct cfgMAC files and put them in the directory for distribution on tftp.

DHCP setup

In order for the phones to correctly pick up their configs, they must be informed about this. Here is a piece from the file /etc/dhcp/dhcpd.conf:
subnet netmask {
  server-name "";
  option domain-name "my.domain";
  option domain-name-servers;
  option domain-search "my.domain";
  option routers;
  option nntp-server;
  option tftp-server-name "";

Pay attention to where there are quotes and where not. - the address of the server on which the entire system is spinning.

End of setting

To configure communication lines with the outside world, use the “Connectivity - Trunks” screen. Your connections with SIP providers are registered there, and, in my case, the flow through the OpenVox board.
To describe how incoming calls will be processed, configure “Connectivity - Inbound Routes”. I have there for the flow indicated which incoming numbers where to send the call (in which format the DID number will come, check with the operator).
To schedule how to handle outgoing calls, use Connectivity - Outbound Routes. Here you can configure, for example, intercity via sipnet, or the choice of operator by dialing prefix.

Extra goodies

FreePBX automatically generates all configuration files, but what if you want something strange? Fortunately, the developers have provided for such desires. In each used context, macro or subroutine, there is a mandatory inclusion of an element имяэлемента-custom.
You need to put your extra chips in a file /etc/asterisk/extensions_custom.conf. For example, I added this:
; Talking clock for Russian
exten => ru,1,Playback(at-tone-time-exactly)
exten => ru,n,SayUnixTime(${FutureTime},,kM)
exten => ru,n,Return()
; Directed FAX
exten => 667,1,Set(FAX_FOR_NUM=${CONNECTEDLINE(num)})
exten => 667,n,NoOp(Directed call transfer from ${CALLERID(all)} for ${FAX_FOR_NUM})
exten => 667,n,GoTo(ext-fax,${FAX_FOR_NUM},1)

With the first block, everything is clear, out of the box there is simply no setting for the Russian language of the watch. But the second block may be interesting. By default, a system fax is located at 666 (yes, FreePBX authors clearly consider faxes to be evil). When connecting to this number, the fax is received and sent to the e-mail address specified in the system as the “system recipient of the fax” (I have this shared folder in Exchange, but nothing but spam usually gets there). And what if the manual fax wants to receive our chief accountant Ivan Ivanovich? And of course, he does not want to shine it in a shared folder. In my phone settings, Ivan Ivanovich is:
Fax: Enabled
Fax Email: Ivan.Ivanov@my.domain

And now, if Ivan Ivanovich transfers the call to number 667, then the received fax will be sent to his personal mail. Do not forget to put GhostScript so that poor Ivan Ivanovich does not suffer, trying to open tiff.


  • FreePBX turned out to be a very convenient tool for configuring Asterisk. Routine tasks are solved simply, and for non-standard problems, it is possible to manually write configs.
  • There were absolutely no problems with the OpenVox board. It took off instantly.
  • Grandstream phones turned out to be convenient and easily customizable, on the one hand. Build quality, on the other hand, is just awful. I handed over more than 10% of the devices under warranty - everyone did not have a handset, some had a speaker, others had a microphone. I do not recommend their DECT DP715 phone separately.

Future plans

Deliver hylafaxand send faxes, not just receive.
Put the module Phonebook, make a general office phone book and show not only the number, but also the name of the caller for incoming calls.
Install a TAPI driver and give people the ability to call contacts directly from Outlook.

I have omitted many details that are obvious to me in this article, I will be happy to answer questions.

Also popular now: