login | register
Fri 22 of Aug, 2008 [00:28 UTC]

voip-info.org

Discuss [4] History

Asterisk sip mysql peers

Created by: oej,Last modification on Thu 18 of Aug, 2005 [14:21 UTC] by Nuttah

IAX2 / SIP peers in MySQL Database


The SIP and IAX2 channels support definition of friends in a MySQL database.

To enable this, you need to edit the Makefile in the channels directory of your source tree and enable MYSQL_FRIENDS. This enables database definition of both IAX2 and SIP friends. Make sure you have the MySQL development kit (libraries) installed before compilation.

You also need to define the following variables in the general section of sip.conf and iax.conf:
  • dbname: Name of database in your Mysql server
  • dbhost: Hostname of server
  • dbuser: Username in MySQL
  • dbpass: Password for user in MySQL

The following data is stored in the database:
  • name: Name of peer (used in SIP registration)
  • secret: Secret (password) stored in plaintext!
  • context: Default context for incoming calls from user
  • ipaddr: Default IP address of user
  • port: Default port

Database format:

 # Table structure for table `sipfriends`
 #
 CREATE TABLE `sipfriends` (
   `name` varchar(40) NOT NULL default '',   
   `username` varchar(40) default '',
   `secret` varchar(40) NOT NULL default '',
   `context` varchar(40) NOT NULL default '',
   `ipaddr` varchar(20) NOT NULL default '',
   `port` int(6) NOT NULL default '0',
   `regseconds` int(11) NOT NULL default '0',
   PRIMARY KEY  (`name`)
 ) TYPE=MyISAM;

 # Table structure for table `iaxfriends`
 #
 CREATE TABLE `iaxfriends` (
 `accountcode` varchar(20) NOT NULL default '',
 `name` varchar(40) NOT NULL default '',
 `secret` varchar(40) default '',
 `context` varchar(40)  default '',
 `ipaddr` varchar(20)  default '',
 `port` int(6) default '0',
 `regseconds` int(11) default '0',
  PRIMARY KEY  (`name`)
 ) TYPE=MyISAM;


'accountcode' column needed for IAX2 calls to complete successfully (IAX2 calls will error incorrrectly saying "no authority found" if this field is not available in the iaxfriends table)


How to securely store passwords in the database:

MySQL offers several ways of storing passwords in the database:

See



If you wish to decrypt/encrypt passwords for storing in sip.conf, then you would look at using DES_DECRYPT/ENCRYPT or AES_DECRYPT/ENCRYPT. Or, you can store a MD5 hash of the password in the database, but you will not be able to decrypt the password because it is one-way encryption.


See also



Comments

Comments Filter
222

333Asterisk realtime

by duca03, Saturday 19 of May, 2007 [11:20:10 UTC]
Hi there,
Im wanting to do exactly what is article is talking about running the sip.conf usernames from a mysql db.
Just wondering if it is requiered to have the asterisk realtime stuff? if so what is it exactly.
222

333regseconds

by , Wednesday 29 of December, 2004 [23:54:10 UTC]
regseconds not documented? (:eek:)
222

333not found in CVS HEAD

by , Saturday 06 of November, 2004 [23:27:18 UTC]
Hi, I've just tried to enable MYSQL Friends in CVS HEAD. But i cannot find this option.. :-(
222

333Installed

by lamsre, Thursday 12 of August, 2004 [07:49:30 UTC]
i did installed my both cisco ata phone and asterisk under one router and when i dial its ringing but no voice. please help me. i did not installed any fxo fxs card on my pc.