Wednesday, March 14, 2007

Asterisk + Openser + Freeradius + Mysql (1)

*Installation

1. Binding one new IP address on eth0 (for SIP server only)
2. your system has following packages check
gcc or icc, bison or yacc, flex, zlib, zlib-devel, MySQL and MySQL-devel.
command: rpm -qa |grep xxxx

3. unixODBC installation
install unixODBC-dev and libmyodbc

4. FreeRadius installation
download freeradius-1.1.4.tar.gz
cd /usr/src
tar zxvf freeradius-1.1.4.tar.gz
cd freeradius-1.1.4
./configure
make
make install

5. Radiusclient-ng installation
download radiusclient-ng-0.5.2.tar.gz
cd /usr/src
tar zxvf radiusclient-ng-0.5.2.tar.gz
cd radiusclient-ng-0.5.2
./configure
make
make install

6. OPENSER installation
cd /usr/src
wget http://www.openser.org/pub/openser/1.1.1/src/openser-1.1.1-tls_src.tar.gz
tar zxvf openser-1.1.1-tls_src.tar.gz
cd openser-1.1.1-tls

cd modules/acc
vi Makefiles
uncomment acc.........

To enable Radius accounting, edit the “modules/acc/Makefile” and uncomment
the part related to Radius accounting. You can comment the part related to
SQL (database) accounting.
Next, edit “Makefile” and remove from “exclude_modules” all modules that
have “_radius” in their name. You can remove from “exclude_modules” the
“mysql” module as well -- the configuration file for OpenSER presented in
this document uses it.

make all
make install


7. RtpProxy installation
cd /usr/src
wget http://ftp.iptel.org/pub/rtpproxy/rtpproxy-0.3.tar.gz
tar zxvf rtpproxy-0.3.tar.gz
cd rtpproxy
./configure
make
make install

run /usr/local/bin/rtpproxy -l 59.125.160.36 -s udp:localhost:7890

8. Asterisk Installation
cd /usr/src
wget http://ftp.digium.com/pub/asterisk/asterisk-1.4.1.tar.gz
tar zxvf asterisk-1.4.1.tar.gz
cd asterisk-1.4.1

Edit 'apps/app_voicemail.c' and change the size of memeber 'uniqueid' in 'struct ast_vm_user' to 128


/* Structure for linked list of users */
struct ast_vm_user {
char context[AST_MAX_CONTEXT]; /* Voicemail context */
char mailbox[AST_MAX_EXTENSION];/* Mailbox id, unique within vm context
char password[80]; /* Secret pin code, numbers only */
char fullname[80]; /* Full name, for directory app */
char email[80]; /* E-mail address */
char pager[80]; /* E-mail address to pager (no attachme
char serveremail[80]; /* From: Mail address */
char mailcmd[160]; /* Configurable mail command */
char language[MAX_LANGUAGE]; /* Config: Language setting */
char zonetag[80]; /* Time zone */
char callback[80];
char dialout[80];
char uniqueid[128]; /* Unique integer identifier */ <<<<<========== here!!! char exit[80]; unsigned int flags; /* VM_ flags */ int saydurationm; int maxmsg; /* Maximum number of msgs per folder fo struct ast_vm_user *next; }; ./configure --with-odbc make menuselect enable "ODBC for voicemail" make make install # boot start make config 9. Database Create OpenSER Database /usr/local/sbin/openser_mysql.sh create Create FreeRadius Database mysql -uroot -p radius <>

use asterisk;
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,
PRIMARY KEY (`id`),
KEY `dir` (`dir`)
) ENGINE=MyISAM;

CREATE VIEW vmusers AS
SELECT phplib_id as uniqueid,
username as customer_id,
'default' as context,
username as mailbox,
vmail_password as password,
CONCAT(first_name,' ',last_name) as fullname,
email_address as email,
NULL as pager,
datetime_created as stamp
FROM openser.subscriber;

CREATE VIEW sipusers AS
SELECT username as name,
username,
'friend' as type,
NULL as secret,
domain as host,
CONCAT(rpid, ' ','<',username,'>') as callerid,
'default' as context,
username as mailbox,
'yes' as nat,
'no' as qualify,
username as fromuser,
NULL as authuser,
domain as fromdomain,
NULL as insecure,
'no' as canreinvite,
NULL as disallow,
NULL as allow,
NULL as restrictcid,
domain as defaultip,
domain as ipaddr,
'5060' as port,
NULL as regseconds
FROM openser.subscriber;

# if you wanna use another account not root
GRANT ALL ON asterisk.* to asterisk@localhost IDENTIFIED BY 'some_password';