FreePBX, Asterisk and Linux Advanced Topics

Sections: 

Here are a few advanced topics covering some things that can be done to any FreePBX or strictly Asterisk distribution.  These would be things one might be interested in doing beyond the standard Linux-Asterisk-Freepbx installation.


Automatically configuring zaptel cards

First of all a few words about zaptel cards.  These are any and all hardware cards used to connect your Asterisk system to the public switched telephone network whether it is analog line(s) or digital (T1 PRI, E1, ISDN).  I won't go into much detail about how to configure them.  I just want to point out some automated tools for setting them up. 

For standard zaptel cards the command is called genzaptelconf.  For Sangoma cards the command is called wancfg_zaptel.  Simply run this command and it will create an /etc/zaptel.conf and /etc/asterisk/zapata.conf file based on the detected hardware.  If it worked correctly that is all that should be required to configure your zaptel hardware. 
NOTE: For trademark reasons Digium is changing the word zaptel to DAHDI


Caching nameserver

DNS translates human readable names into IP addresses.  It's usually a good idea to set up Linux on your PBX so that it has a way of translating DNS otherwise you may get some unpredictable things happening in Asterisk if you lose your internet connection.  The method recommended in the Open Telephony Training Seminar is to set up a caching-nameserver on the PBX.  Basically all it does is cache DNS names from some other DNS server. This local DNS cache avoids extra traffic and use of the internet connection to call external name servers everytime a phone or other VoIP device requests a previously used name translation.

Install caching-nameserver if not already installed:
yum -y install bind
yum -y install bind-utils
yum -y install caching-nameserver


nano /etc/named.conf

Open /etc/named.caching-nameserver.conf and copy/paste the contents into /etc/named.conf.  Add the following line to the end of the section called options in the named.conf file.

forwarders { xxx.xxx.xxx.xxx; xxx.xxx.xxx.xxx; };

Where the two xxx.xxx.xxx.xxx entries are your primary and secondary DNS servers. You could use your ISP's DNS servers or a 3rd party DNS provider such as OpenDNS.org or you could use the IP address of your router which usually just forwards to your ISP's DNS servers.

Set it to automatically start on boot.
chkconfig --level 345 named on

nano /etc/resolv.conf


Add the following to the first line of /etc/resolv.conf so that DNS queries check the PBX cache for matches before going upstream.

nameserver 127.0.0.1

Now start the service for this session.
service named start

DHCP option 66
Option 66 is a parameter of a DHCP server that points to the TFTP server.  In Asterisk PBX's this is commonly used to store and serve the SIP phone configuration files and firmware upgrades.  When the phones connect to the IP network they are typically set to obtain an IP address automatically from the local network DHCP server.  If the server is capable of providing the Option 66, the TFTP IP address will be configured into the phone at which point it can locate the TFTP server, upgrade its firmware and download it's configuration files and configure itself.  This is a good option to have in larger installations where there are many phones that need to be connected.  It is also of some benefit at remote locations where you may not be readily available to go onsite to install phones.  With DHCP Option 66 you could theoretically send the phone and have anyone simply connect it to the network and configure itself.  Not all DHCP servers are capable of providing Option 66 such as many inexpensive routers.  In that case mDNS, as explained in this link may be worth considering.

 
Getting notified of problems

Obviously if the PBX has some problem it would be useful if it were to email you. 
Some of the problems you can configure Linux-Asterisk to notify you of are:
Asterisk crashes
RAID problems
Hard drive errors (S.M.A.R.T)

This assumes you have sendmail or postfix installed.
nano /usr/sbin/safe_asterisk
remove any '#' before the NOTIFY line
change the email address to your email address


NOTE: make sure to set hostnames on each client PBX to be unique so you can identify which PBX the notification is coming from.

for RAID notification:
nano /etc/mdadm.conf
Change the MAILADDR variable to your email address

For S.M.A.R.T notification:
nano /etc/smartd.conf

#Add the following lines (assuming your using SATA)
/dev/sda -d ata -S on -o on -a -I 194 -m youremail@yourdomain.com
/dev /sdc -d ata -S on -o on -a -I 194 -m youremail@yourdomain.com

(Ctrl-X>y>ENTER)


service smartd start
chkconfig --level 345 smartd on


These were some of the topics presented in more detail at the Open Telephony Training Seminar -  Advanced Topics by Ethan Schroeder