terça-feira, maio 20, 2014

Installing DAHDI

Software Installation

Digium® hardware requires drivers and libraries that are not integrated with the Linux kernel. These drivers and libraries including application software, and may be obtained from Digium’s downloads server at: http://downloads.digium.com

For an introduction to Asterisk®, Digium’s telephony software, including information on its configuration, setup and features, please refer to: http://www.asterisk.org.  For product-specific documentation inlcuding product’s manual and other related information please visit http://www.digium.com

Software Requirements

  • Linux 2.6.18 or later
Digium recommends CentOS, Debian, RedHat, and Ubuntu distributions of Linux.
  • Development libraries and headers for ncurses, zlib, openssl and libnewt
  • GCC and standard software build tools
Debian like OS:  # apt-get install gcc libncurses-devel kernel-devel kernel-smp-devel gcc-c++ libnewt-dev zlib-devel unixODBC-devel libtool make

Red Hat like OS: # yum install gcc ncurses-devel libtermcap-devel kernel-devel gcc-c++ newt-devel zlib-devel unixODBC-devel libtool make
Note: These commands includes optional libaries which are used by Asterisk and Asterisk-addons 

Installation Steps

It is recommended that you use the most recent version of the Asterisk, DAHDI, and libpri software for the best results. If you have previously installed any of these, Digium recommends that you upgrade to the latest “-current” version of each.

Also, please be aware that you may need to re-compile Asterisk if you are upgrading DAHDI or libpri. The Application programming interface (API) of these packges tends to change between versions, re-compilation is the only way that you make Asterisk's adapt  to the new API. 
  • Download and install the latest DAHDI drivers. DAHDI is available for download from: http://downloads.digium.com/pub/telephony/dahdi-linux-complete
# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-X.X.X+X.X.X.tar.gz
# tar -zxvf  dahdi-linux-complete-X.X.X+X.X.X.tar.gz
# cd dahdi-linux-complete-X.X.X+X.X.X.tar.gz
# make
# make install
# make config
  • If you are installing a Digium Digital Card, download and install the latest version of libpri after installing DAHDI. libpri is available for download from: http://downloads.digium.com/pub/telephony/libpri
# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-X.X.X.tar.gz
# tar -zxvf libpri-X.X.X.tar.gz
# cd libpri-X.X.X/
# make
# make install
 

Setup Asterisk on CentOS

Setup  on CentOS

We need to install all of Asterisk’s dependencies.  These are programs that are required to be installed before you can compile asterisk.  This is the list I use, it includes the source compilers, some needed development libraries, as well as some dependencies for various asterisk modules I like to load.
  • Install Asterisk dependencies
    yum install gcc gcc-c++ make openssl-devel newt-devel ncurses-devel doxygen libtermcap-devel libxml2-devel kernel-devel perl curl curl-devel
  • We’ll install a MySQL database server to handle our CDR (call detail records) storage, and also to prepare the way for using the Asterisk Realtime Architecture (the ability to store our configuration parameters in a database as opposed to flat files). 

    yum install libtool-ltdl libtool-ltdl-devel unixODBC-devel mysql mysql-devel mysql-server mysql-connector-odbc   
  • Create a directory under /usr/src to keep everything tidy. Download all of the sources for this install.
    cd /usr/src
    mkdir asterisk
    cd asterisk
    wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.11.tar.gz
    wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-addons-1.6.2.1.tar.gz
    wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
    wget http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz
    tar zxvf asterisk-1.6.2.11.tar.gz
    tar zxvf asterisk-addons-1.6.2.1.tar.gz
    tar zxvf dahdi-linux-complete-current.tar.gz
    tar zxvf libpri-1.4-current.tar.gz
  • LibPRI.  LibPRI is a library used by TDM cards (T1 / E1 cards, etc).  Even if you don’t have one of these cards, it’s safe to install LibPRI – it won’t have any negative effects on your system.
    cd /usr/src/asterisk/libpri-1.4.11.2
    make clean
    make
    make install
  • DAHDI.  DAHDI means “Digium Asterisk Hardware Device Interface”, it’s pronounced “Daddy”, and it’s the replacement of the old Zaptel driver stack.  DAHDI is the set of linux kernel modules and also a set of tools for interfacing with TDM cards.  More importantly, DAHDI provides timing to several asterisk components, such as the MeetMe application as well as Music on Hold.  If you don’t have a proper timing source installed, you’ll notice lots of stuttering pauses in any kind of audio playback (Music on Hold, IVR prompts, voicemail greetings) from asterisk.  If you don’t have any TDM hardware installed in your server, DAHDI also provides a “dummy” driver that will provide a timing source to asterisk.
    cd /usr/src/asterisk/dahdi-linux-complete-2.3.0.1+2.3.0/
    make all
    make install
    make config
  • Now you need to configure DAHDI.  You do that by editing the following files, based on your situation.  The files themselves contain lots of documentation, if you have no TDM cards and are only installing DAHDI for the dummy timing source, you can comment out every driver referenced in the modules file.

    nano /etc/dahdi/modules
    nano /etc/dahdi/system.conf      
    Set DAHDI to start automatically and then start it.
    chkconfig dahdi on
    service dahdi start
  • Install Asterisk.
    cd /usr/src/asterisk/asterisk-1.6.2.11/
    make clean
    ./configure         # or ./configure --disable-xmldoc (if you get error)
    make menuselect
    Choose which options to install (audio files, voicemail storage, codecs etc.)
    make menuselect 
    make 
    make install
    Install sample files in /etc/asterisk, install docs/manpages and set to start on boot.
    make samples
    make progdocs
    make config
    chkconfig asterisk on
    Check Asterisk starts properly, by manually starting asterisk from the command line.
    asterisk -vvvvc
    *CLI> core stop now
    Assuming it does start properly, you probably want to start it in the background:
    service asterisk start
  • Asterisk-addons
    cd /usr/src/asterisk/asterisk-addons-1.6.2.1
    make clean
    ./configure
    make menuselect
          
    Choose what you do and don't want. Unless you really need oh323, deselect it as it can be the cause of compilation woes. Be sure to select at least the following items:
    • Applications – app_addon_sql_mysql
    • Call Detail Recording – cdr_addon_mysql
    • Resource Modules – res_config_mysql
    make
    make install
    make samples      
    Edit /etc/asterisk/cdr_mysql.conf and add 'loguniqueid=yes' to the global section.

domingo, maio 18, 2014

DID based routing with Asterisk

DID based routing with Asterisk

GENERAL INFORMATION
In this guide we will configure inbound routing based on the DID (number) information returned by Callcentric. In order to do this you will need to do further editing to your current Asterisk configuration.

Below we will provide the necessary information to configure your Asterisk installation to route based on the called DID in your Callcentric account.

Understand that this guide presents the most basic configuration for configuring DID based routing and is meant as a learning tool to assist you in configuring your own complex routing.

The setup information below is based on Asterisk 1.4; although most other older and newer versions should be very similar.


Please note that Callcentric is not responsible for preventing unwanted physical or remote access your IP PBX. If your IP PBX is compromised then you will be responsible for any damage caused.
Please be sure to read this guide regarding securing your IP PBX solution.

RESOURCES
Main Project:
Asterisk - http://www.digium.com

Help and Support:
AussieVoIP sip_header information - sip_header
AussieVoIP context information - contexts
AussieVoIP extension information - extensions

CONFIGURATION
Prerequisites:
In order to use this guide you will need a properly configured Asterisk installation which can receive incoming calls from Callcentric. You may double check our Asterisk setup guide to make sure that your system can at least initially receive incoming calls.

Once you can receive incoming calls properly you may configure DID based routing by following the instructions below:
1Creating or editing the inbound context
Here we will configure the inbound context which will be used to handle the routing of inbound calls to your Asterisk installation. To create this context you can either use the command line or a text editor to edit the extensions.conf file.

Once you are able to access the extensions.conf file you can follow the steps below:

1. Enter the following context:
[incoming]
exten => s,1,Set(Var_TO=${SIP_HEADER(TO)})
exten => s,2,GotoIf($["${Var_TO}" = ""]?extension2,s,1:3)
exten => s,3,GotoIf($["${Var_TO}" = ""]?extension2,s,1:4)
exten => s,4,GotoIf($["${Var_TO}" = ""]?extension1,s,1:5)
exten => s,5,GotoIf($["${Var_TO}" = ""]?extension1,s,1:6)
exten => h,6,Macro(hangupcall)

Where and are the exact information returned by Callcentric's servers for your 1777 number and any DID on your account, respectively.

And where extension1 and extension2 are contexts which decide where to send the call. For example:
[extension1]
exten => s,1,Dial(SIP/100)

[extension2]
exten => s,1,Dial(SIP/200)


2. Save the file.
2Configure your inbound routing to route to your DID routing context
In your extensions.conf file use the following, from-callcentric can also be your own incoming context:

[from-callcentric]
exten => s,1,Goto(incoming,s,1) 

3Placing Test Calls
Once you are done save your changes and then test incoming calling to see that your Asterisk setup now routes inbound calling based on the number called.

To test inbound calls from Callcentric to your new DID based routing setup, follow the directions listed in this FAQ. You will also want to test calls directly to your DID from a PSTN phone if you have a DID on your account.