Menu Close

Asterisk 1.8 instalation and configuration with ODBC and DAHDI modules on Debian (lenny)

This guide describes installation of Asterisk 1.8.4 with ODBC module for MySQL support and DAHDI module for timer clock support. The timer clock is needed by some applications such as MeetMe which provides conferences.
 
First of all, we make sure that the packages are up to date:
apt-get update
Then we install MySQL server and client libraries:
apt-get install mysql-server libmysqlclient-dev
We install ODBC as the database interface and also the ODBC libraries:
apt-get install unixodbc-dev libmyodbc
Additional components are required if we want to use MeetMe application. We have to install additional drivers for the timer clock support:
apt-get install libncurses-dev linux-headers-$(uname -r)
If we are doing the installation on a clean system we will need additional packages for compilation:
apt-get install gcc g++ make
Then we create the directory for Asterisk and download DAHDI package there. After that we unpack the package and compile it:
mkdir /usr/src/asterisk
cd /usr/src/asterisk
wget http://downloads.digium.com/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
tar zxvf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-2.4.1.2+2.4.1
make all
make install
make config
We load the dahdi module into Linux core after the compilation process:
modprobe dahdi_dummy
Then install additional library which is needed during the compilation process of Asterisk. Otherwise the configure script will end up with error:
apt-get install libxml12-dev
We download and unpack Asterisk and run the configure script which will check the system for needed requirements:
cd /usr/local/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8.4.tar.gz
tar xvfz asterisk-1.8.4.tar.gz
cd asterisk-1.8.4
./configure
We need to find out what is the current version of Asterisk 1.8.x.x, because Asterisk is still in development. We must download the appropriate version (just change the path for wget).
Then we run the menuselect and select which modules to compile. It is necessary to maximize the window to at least 80×27 characters. Otherwise the menuselect will not run and end up with error.
make menuselect
Here we check the desired packages, language etc. In our particular case we need to go into the Voicemail Build Options menu and choose the ODBC_STORAGE option submitting it by spacebar. Then we leave the menu by hitting the ESC key and we save the changes by hitting S key. Now it is possible to compile and install Asterisk.
make
make install
It is reccomended to run following commands for creation of default configuration files and for starting Asterisk after the boot:
make samples
make config
After the installation process we need to configure on which IP adress and port will the Asterisk listen. This is done in configuration file /etc/asterisk/sip.conf in section [general]. We uncomment the row and write the appropriate adress and port.
udpbindaddr=192.168.0.1:5060 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
 
Then we create the Asterisk database, grant permissions for this databse and create tables. Don’t forget to change the asterisk password in GRANT command.
CREATE DATABASE asterisk;

USE asterisk;

GRANT ALL ON asterisk.* TO asterisk@localhost IDENTIFIED BY 'asterisk_password';

CREATE TABLE `sipusers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL DEFAULT '',
`host` varchar(31) NOT NULL DEFAULT '',
`nat` varchar(5) NOT NULL DEFAULT 'no',
`type` enum('user','peer','friend') NOT NULL DEFAULT 'friend',
`accountcode` varchar(20) DEFAULT NULL,
`amaflags` varchar(13) DEFAULT NULL,
`call-limit` smallint(5) UNSIGNED DEFAULT NULL,
`callgroup` varchar(10) DEFAULT NULL,
`callerid` varchar(80) DEFAULT NULL,
`cancallforward` char(3) DEFAULT 'yes',
`canreinvite` char(3) DEFAULT 'yes',
`context` varchar(80) DEFAULT NULL,
`defaultip` varchar(15) DEFAULT NULL,
`dtmfmode` varchar(7) DEFAULT NULL,
`fromuser` varchar(80) DEFAULT NULL,
`fromdomain` varchar(80) DEFAULT NULL,
`insecure` varchar(4) DEFAULT NULL,
`language` char(2) DEFAULT NULL,
`mailbox` varchar(50) DEFAULT NULL,
`md5secret` varchar(80) DEFAULT NULL,
`deny` varchar(95) DEFAULT NULL,
`permit` varchar(95) DEFAULT NULL,
`mask` varchar(95) DEFAULT NULL,
`musiconhold` varchar(100) DEFAULT NULL,
`pickupgroup` varchar(10) DEFAULT NULL,
`qualify` char(3) DEFAULT NULL,
`regexten` varchar(80) DEFAULT NULL,
`restrictcid` char(3) DEFAULT NULL,
`rtptimeout` char(3) DEFAULT NULL,
`rtpholdtimeout` char(3) DEFAULT NULL,
`secret` varchar(80) DEFAULT NULL,
`setvar` varchar(100) DEFAULT NULL,
`disallow` varchar(100) DEFAULT NULL,
`allow` varchar(100) DEFAULT NULL,
`fullcontact` varchar(80) NOT NULL DEFAULT '',
`ipaddr` varchar(15) NOT NULL DEFAULT '',
`port` mediumint(5) UNSIGNED NOT NULL DEFAULT '0',
`regserver` varchar(100) DEFAULT NULL,
`regseconds` int(11) NOT NULL DEFAULT '0',
`lastms` int(11) NOT NULL DEFAULT '0',
`username` varchar(80) NOT NULL DEFAULT '',
`defaultuser` varchar(80) NOT NULL DEFAULT '',
`subscribecontext` varchar(80) DEFAULT NULL,
`useragent` varchar(20) DEFAULT NULL,
`sippasswd` varchar(80) DEFAULT NULL,
PRIMARY KEY  (`id`),
UNIQUE KEY `name_uk` (`name`)
);
 
CREATE TABLE `sipregs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL DEFAULT '',
`fullcontact` varchar(80) NOT NULL DEFAULT '',
`ipaddr` varchar(15) NOT NULL DEFAULT '',
`port` mediumint(5) UNSIGNED NOT NULL DEFAULT '0',
`username` varchar(80) NOT NULL DEFAULT '',
`regserver` varchar(100) DEFAULT NULL,
`regseconds` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY  (`id`),
UNIQUE KEY `name` (`name`)
);
 
CREATE TABLE IF NOT EXISTS `voiceboxes` (
`uniqueid` int(4) NOT NULL AUTO_INCREMENT,
`customer_id` varchar(10) DEFAULT NULL,
`context` varchar(10) NOT NULL,
`mailbox` varchar(10) NOT NULL,
`password` varchar(12) NOT NULL,
`fullname` varchar(150) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`pager` varchar(50) DEFAULT NULL,
`tz` varchar(10) DEFAULT 'central',
`attach` enum('yes','no') NOT NULL DEFAULT 'yes',
`saycid` enum('yes','no') NOT NULL DEFAULT 'yes',
`dialout` varchar(10) DEFAULT NULL,
`callback` varchar(10) DEFAULT NULL,
`review` enum('yes','no') NOT NULL DEFAULT 'no',
`operator` enum('yes','no') NOT NULL DEFAULT 'no',
`envelope` enum('yes','no') NOT NULL DEFAULT 'no',
`sayduration` enum('yes','no') NOT NULL DEFAULT 'no',
`saydurationm` tinyint(4) NOT NULL DEFAULT '1',
`sendvoicemail` enum('yes','no') NOT NULL DEFAULT 'no',
`delete` enum('yes','no') NULL DEFAULT 'no',
`nextaftercmd` enum('yes','no') NOT NULL DEFAULT 'yes',
`forcename` enum('yes','no') NOT NULL DEFAULT 'no',
`forcegreetings` enum('yes','no') NOT NULL DEFAULT 'no',
`hidefromdir` enum('yes','no') NOT NULL DEFAULT 'yes',
`stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY  (`uniqueid`),
KEY `mailbox_context` (`mailbox`,`context`)
);
 
CREATE TABLE `voicemessages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`msgnum` int(11) NOT NULL DEFAULT '0',
`dir` varchar(80) DEFAULT '',
`context` varchar(80) DEFAULT '',
`macrocontext` varchar(80) DEFAULT '',
`callerid` varchar(40) DEFAULT '',
`origtime` varchar(40) DEFAULT '',
`duration` varchar(20) DEFAULT '',
`mailboxuser` varchar(80) DEFAULT '',
`mailboxcontext` varchar(80) DEFAULT '',
`recording` longblob,
`flag` varchar(128) DEFAULT '',
PRIMARY KEY  (`id`),
KEY `dir` (`dir`)
);
Sipuser table is a standard table for storing user profiles and their passwords for authentication. Sipregs table is used for location database purposes. Tables voiceboxes and voicemessages are needed by voicemail service.
 
Then we edit the configuration file for ODBC /etc/odbcinst.ini :
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
CPTimeout =
CPReuse =
UsageCount = 1
And we add following rows into /etc/odbc.ini file:
[MySQL-asterisk]
Description = MySQL Asterisk database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER = asterisk
PASSWORD = asterisk_password
PORT = 3306
DATABASE = asterisk
In configuration file for Asterisk /etc/asterisk/res_odbc.conf, we need to uncomment the appropriate rows and add the following:
[asterisk]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => asterisk_password
pre-connect => yes
Then we add following rows for users, location database and voicemail to the /etc/asterisk/extconfig.conf file:
sipusers => odbc,asterisk,sipusers
sippeers => odbc,asterisk,sipusers
sipregs => odbc,asterisk,sipregs
voicemail => odbc,asterisk,voiceboxes
The last step is to add users to the databse. For our purposes we add users 101, 102 a 103 to the database and to create voicemail accounts for them. The passwords for authentication are 101, 102, 103 and the passwords for voicemail are 1234. We can also add more new users in such a manner.
mysql -r -p
use asterisk
INSERT INTO sipusers (name, username, host, sippasswd, fromuser, fromdomain, mailbox)
  VALUES ('101', '101', 'dynamic', '101', '101', 'yourdomain.com', '101');
INSERT INTO sipusers (name, username, host, sippasswd, fromuser, fromdomain, mailbox)
  VALUES ('102', '102', 'dynamic', '102', '102', 'yourdomain.com', '102');
INSERT INTO sipusers (name, username, host, sippasswd, fromuser, fromdomain, mailbox)
  VALUES ('103', '103', 'dynamic', '103', '103', 'yourdomain.com', '103');
 
INSERT INTO sipregs(name) VALUES('101');
INSERT INTO sipregs(name) VALUES('102');
INSERT INTO sipregs(name) VALUES('103');
 
INSERT INTO voiceboxes(customer_id, context, mailbox, password) VALUES ('101', 'default', '101', '1234');
INSERT INTO voiceboxes(customer_id, context, mailbox, password) VALUES ('102', 'default', '102', '1234');
INSERT INTO voiceboxes(customer_id, context, mailbox, password) VALUES ('103', 'default', '103', '1234');

Finally, we can run Asterisk after these steps.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.