12 July 2012

VICIDIAL DIALPLAN ENTR

Globals String:
Code:
DIAL9TRUNK = SIP/pbxchange


Dialplan Entry:
Code:
exten =>_91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten =>_91NXXNXXXXXX,2,Dial(${DIAL9TRUNK}/${EXTEN:1},,tTor)
exten =>_91NXXNXXXXXX,3,Hangup
exten =>_9011XXXXXXXX.,1,AGI(agi://127.0.0.1:4577/call_log)
exten =>_9011XXXXXXXX.,2,Dial(${DIAL9TRUNK}/${EXTEN:4},,tTor)
exten =>_9011XXXXXXXX.,3,Hangup

*The above assumes the NXXNXXXXXX US dialplan is appropriate for your area (10 digits, neither 1st nor 4th can be 0 or 1). Change that portion of the dialplan to fit your locale.
*note that "EXTEN:4" will strip of 9011 and send the rest of the number to your provider. This may or may not fit their expected dial string for international numbers. If you post their expectations, we can adjust it to fit.


Campaign Dial Prefix:

Code: 
9

Using MySQL, Administration

Using MySQL, Administration
Workshop Requirements

You should have access to the MySQL command line client software.

Various different PRIVILEGES on the MySQL Server
Introduction

In the other MySQL Virtual Workshops we have used commands that are pretty much applicable to anyone. This part of the MySQL series is aimed at giving a rudimentary understanding of managing a MySQL database server. As such the task covered here are not really about manipulating data or database structures, but the actual databases themselves.
Creating a Database

In order to create a database you need to have the PRIVILEGES- this may be because you are the root user or you (or you systems administrator) has created an admin user that has ALL PRIVILEGES over all databases. In these examples a user called 'admin' has been created precisely for this purpose. Creating a database is fairly straightforward.
Logging In

A reminder of how to start the MySQL Client Software, and as we are not concerned with manipulating just one database we don't have to specify a database as part of our startup command.

$ mysql -u -p
Enter password:

Create database command

Next we are ready to enter the very simple command to create a database which is:

mysql> CREATE DATABASE ;

Let's imagine that we are going to create a 'vworks' database (those wishing to create a database for use with the VWs should use this). We would enter the command:

mysql> CREATE DATABASE vworks;

We can now check for the presence of this database by typing:

mysql> SHOW DATABASES;
+-----------+
| Database |
+-----------+
| mysql |
| vworks |
+-----------+
2 rows in set (0.06 sec)

The other database listed ('mysql') is the internal database which MySQL uses to manage users, permissions etc.

NOTE: Deleting or DROPing a database is similar to the DROP TABLE command issued in Part 4. e.g.

DROP DATABASE 

Granting Privileges on the new database

Now that we have created a database, we need to decide who gets to use it. This is done by granting permissions for a user to use the database. This has a simplified syntax of:

GRANT 
ON 
TO 
[IDENTIFIED BY ]
[WITH GRANT OPTION]

Where the items in square brackets are optional. The most common use is to give ALL PRIVILEGES on a database to a local user who has to use a password to access the database (in this case vworks).

mysql> GRANT ALL PRIVILEGES
-> ON vworks.*
-> TO newuser@localhost
-> IDENTIFIED BY 'newpassword';

If you are creating a database for use with the rest of the Virtual Workshops you should use this statement, substituting your username and password of choice. There are some other options we will look at. To restrict the user to manipulating data (rather than table or database structures) the statement would be altered to:

mysql> GRANT SELECT,INSERT,UPDATE,DELETE
-> ON vworks.*
-> TO newuser@localhost
-> IDENTIFIED BY 'newpassword';

So that the user can only change the data using SELECT,INSERT,UPDATE or DELETE statements. If you wished to give a non-local user permissions on the database (for use with remote clients) then you could designate an IP or host address from which the user can connect:

mysql> GRANT ALL PRIVILEGES
-> ON vworks.*
-> TO newuser@192.168.0.2
-> IDENTIFIED BY 'newpassword';

Now a user on the machine '192.168.0.2' can connect to the database. To allow a user to connect from anywhere you would use a wildcard '%'

mysql> GRANT ALL PRIVILEGES
-> ON vworks.*
-> TO newuser@'%'
-> IDENTIFIED BY 'newpassword';

You could even decide that a user doesn't need a password if connecting from a certain machine.

mysql> GRANT ALL PRIVILEGES
-> ON vworks.*
-> TO newuser@192.168.0.2

But I think it is sometimes good to provide a password anyway. Finally we'll look at the WITH GRANT OPTION condition. This allows the user to give others privileges to that database:

mysql> GRANT ALL PRIVILEGES
-> ON vworks.*
-> TO newuser@localhost
-> IDENTIFIED BY 'newpassword'
-> WITH GRANT OPTION;

This would allow the user 'newuser' to log into the database and give their friend privileges to SELECT,INSERT,UPDATE or DELETE from the database.

mysql> GRANT SELECT,INSERT,UPDATE,DELETE
-> ON vworks.*
-> TO friend@localhost
-> IDENTIFIED BY 'friendpass';

The WITH GRANT OPTION usually signifies ownership although it is worth noting that no user can GRANT more privileges that they themselves possess.
Revoking privileges

Revoking privileges is almost identical to granting them as you simply substitute RE VOKE.... FROM for GRANT....TO and omit any passwords or other options.

For example to REVOKE the privileges assigned to a user called 'badvworks':

mysql> REVOKE ALL PRIVILEGES
-> ON vworks.*
-> FROM badvworks@localhost;

Or just to remove UPDATE, INSERT and DELETE privileges to that data cannot be changed.

mysql> REVOKE INSERT,UPDATE,DELETE
-> ON vworks.*
-> FROM badvworks@localhost;

Backing Up Data

There are several methods we can use to backup data. We are going to look at a couple of utilities that come with MySQL: mysqlhotcopy and mysqldump.
mysqlhotcopy

mysqlhotcopy is a command line utility written in Perl that backs up (to a location you specify) the files which make up a database. You could do this manually, but mysqlhotcopy has the advantage of combining several different commands that lock the tables etc to prevent data corruption. The syntax (as ever) first.

$ mysqlhotcopy -u -p /backup/location/

Which SHOULD copy all the tables (*.frm, *.MYI, *.MYD) into the new directory - the script does require the DBI perl module though. To restore these backup files simply copy them back into your MySQL data directory.
mysqldump

This is my preferred method of backing up. This outputs the table structure and data in series of SQL commands stored in a text file. The simplified syntax is

$ mysqldump -u -p [table] > file.sql

So for example to back up a 'vworks' database which may have been created by completing the workshops:

$ mysqldump -u admin -p vworks > vworks.sql

After entering the password a 'vworks.sql' file should be created. When you look at this file you can actually see that the data and structures are stored as a series of SQL statements. e.g.:

-- MySQL dump 8.22
--
-- Host: localhost Database: vworks
---------------------------------------------------------
-- Server version 3.23.52

--
-- Table structure for table 'artist'
--

CREATE TABLE artist (
artistID int(3) NOT NULL auto _increment,
name varchar(20) default NULL,
PRIMARY KEY (artistID)
) TYPE=MyISAM;

--
-- Dumping data for table 'artist'
--


INSERT INTO artist VALUES (1,'Jamiroquai');
INSERT INTO artist VALUES (2,'Various');
INSERT INTO artist VALUES (3,'westlife');
INSERT INTO artist VALUES (4,'Various');
INSERT INTO artist VALUES (5,'Abba');

And so on for the other tables.

We could also have chosen to output just one table from the database, for example the artist table:

$ mysqldump -u admin -p vworks artist > artist.sql

We could even dump all the databases out (providing we have the permissions).

$ mysqldump -u admin -p --all-databases > alldb.sql

Restoring a Dump

Restoring a dump depends on what you have actually dumped. For example to restore a database to a blank database (perhaps having transferred the sql file to another machine) it is fairly simple.

$ mysql -u admin -p vworks < vworks.sql ...or to add a non-existent table to a database... $ mysql -u admin -p vworks < artist.sql However, what happens if we want to restore data to an existing database (perhaps a nightly backup) ? Well we would have to add other options: The equivalent of overwriting the existing tables would be telling the dump to automatically drop any tables that exist before restoring the stored tables. This is done with the ' --add-drop-table ' option added to our statement. $ mysqldump -u admin -p --add-drop-table vworks > vworks.sql

Then restore like normal:

$ mysql -u admin -p vworks < vworks.sql The reverse might also be true. We may wish to create the database if it doesn't already exist. To do this we use the '--databases' option to specify the database we wish to back up (you can specify more than one). $ mysqldump -u admin -p --databases vworks > vworksDB.sql

This will create additional SQL statements at the start of each database that CREATEs the dumped database (checking first to see if it does indeed exist) then USEing that database to import the table data into.

-- Current Database: vworks
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ vworks;

USE vworks;

Again we can resort like normal, but of course this time we can omit the database name.

$ mysql -u admin -p < vworksDB.sql Optimising a dump There are a couple of options that are sometimes worth including when backing up and restoring large databases. The first option is '--opt', this is used override the mysql server's normal method of reading the whole result set into memory giving a faster dump. Example: $ mysqldump -u admin -p --opt vworks > vworks.sql

The second option is '-a' or '-all' (either will do). Which also optimises the dump by creating mysql specific CREATE statements that speeds up the restore:

$ mysqldump -u admin -p --all vworks > vworks.sql

Using mysqldump to copy databases.

It is possible to combine a dump and a restore on one line by using a pipe '|' to pass the output of the dump directly to mysql basically bypassing the file. This may initially seem a bit redundant, but we can use this method to copy a database to another server or even create a duplicate copy.

For example to copy the 'vworks' database to a mysql server called 'remote.server.com':

$ mysqldump -u admin -p --databases vworks | \
> mysql -u backup -p MyPassword -h remote.server.com

Note: the"\" at the end of the first line means you wish to contine the command on another line before executing it.

You may, in certain circumstances, wish to make a copy of live data so that you can test new scripts and 'real world' data. To do this you would need to duplicate a local database. First create the duplicate database:

mysql> CREATE DATABASE vworks2;

Then once appropriate privileges have been assigned we can copy the tables from the first table into the second.

$ mysqldump -u admin -p vworks | mysql -u backup -p MyPassword vworks2

Notice in both these examples the second half of the line (after the pipe) passes the password as part of the connection statement. This is because asking for two separate passwords at the same time breaks most shells. That is why I have used a 'backup' user who can be granted permissions and have them revoked as necessary.
Miscellaneous Leftovers

This final bit includes a few brief tricks that weren't really appropriate to include elsewhere, but are still worth noting.
Remote Client Connection

If you have set the privileges to allow remote connections to a database, you can connect from a remote command line client by using the -h flag:

$ mysql -u -p -h 

For example to connect to a fictional vworks.keithjbrown.co.uk server:

$ mysql -u admin -p -h vworks.keithjbrown.co.uk

Non-Interactive Commands

Sometimes you may wish to just do a quick look up on a table without the hassle of logging into the client, running the query then logging back out again. You can instead just type one line using the ' -e ' flag. For example:

$ mysql -u admin -p vworks -e 'SELECT cds.artist, cds.title FROM cds'

Enter password:
+------------+------------------------------+
| artist | title |
+------------+------------------------------+
| Jamiroquai | A Funk Odyssey |
| Various | Now 49 |
| westlife | westlife |
| Various | Eurovision Song contest 2001 |
| Abba | Abbas Greatest Hits |
+------------+------------------------------+

Using command line wodim tool to burn iso image

Instead of conventional burning method using GUI application there are also many ways on how to burn a ISO image to a CD-RW or CD-R from a command line. One way is to use a wodim command. Firs we use wodim to detect our burning device:

# wodim --devices

OUTPUT:

wodim: Overview of accessible drives (1 found) :
-------------------------------------------------------------------------
0 dev='/dev/scd0' rwrw-- : 'TSSTcorp' 'CD/DVDW SH-S183L'
-------------------------------------------------------------------------

now we can combine the device file of our burning device with wodim command to write actual ISO image:

wodim -eject -tao speed=0 dev=/dev/scd0 -v -data /my/directory/image.iso

if you get an error mesage saying : wodim: trying to use a high speed medium on low writter try use higher burninng speed such us speed=1 or speed=2:

wodim -eject -tao speed=1 dev=/dev/scd0 -v -data /my/directory/image.iso

---------------------------------------------------------------------------------------

Purpose: In my earlier post, we saw 10 useful programs to burn CDs/DVDs in Linux amongst which cdrecord was one of them. In this blog post we will learn how to use the cdrecord program to burn CDs and DVDs. The package cdrecord is just a dumy package in Debian Lenny which provides wodim, the real utility which does the burning work.

Step 1: Find your CD/DVD Writer

# wodim –scanbus

scsibus1:
1,0,0 100) ‘ATAPI ‘ ‘iHAS120 6 ‘ ’7L02′ Removable CD-ROM
1,1,0 101) *
1,2,0 102) *
1,3,0 103) *
1,4,0 104) *
1,5,0 105) *
1,6,0 106) *
1,7,0 107) *
#

# wodim –devices
wodim: Overview of accessible drives (1 found) :
————————————————————————-
0 dev=’/dev/scd0′ rwrw– : ‘ATAPI’ ‘iHAS120 6′

————————————————————————-

Step 2: Erase your Re-writable CD/DVD

# umount /dev/cdrom

# cdrecord device=1,0,0 blank=fast

# wodim dev=/dev/scd0 blank=fas

Step 3: Burn an ISO image

# wodim -v -dao speed=4 dev=/dev/scd0 /root/projects/debian-500-i386-netinst.iso

Step 4: Create an ISO image and then burn it

# mkisofs -r -o mycdimage.iso /home/kushalk/mydatadirectory

# wodim -v -dao speed=4 dev=/dev/scd0 mycdimage.iso

That’s it. Happy cdrecording!

Fail2Ban

Here's a way to configure a fail2ban system for SIP and IAX2 registration attemps :

Install fail2ban :

apt-get install fail2ban

First we need to log to syslog. Add the following configuration to /etc/asterisk/logger.conf:

syslog.local0 => notice ; Used by fail2ban 

Then you need to configure rsyslog to store those messages in a file (for instance /var/log/auth-asterisk.log). Create /etc/rsyslog.d/asterisk-auth.conf and add the following lines to it:

#
# Logging for asterisk registration
#
local0.* -/var/log/auth-asterisk.log

We now have the necessary authentication logs for fail2ban to work. We will now configure it to ban users 10 minutes after 5 failed authentication attempts. First, add the following entry in a file named /etc/fail2ban/jail.local:

[asterisk-iptables]

enabled = true
filter = asterisk
action = iptables-allports[name=ASTERISK, protocol=all]
logpath = /var/log/auth-asterisk.log
maxretry = 5
bantime = 600

Then, we describe how the failed attempts look like in the logs with the use of a regular expression. Open a file named /etc/fail2ban/filter.d/asterisk.conf and add the following code:

[Definition]

failregex = asterisk.*chan_sip.c.*Registration from .* failed for '' - Wrong password
asterisk.*chan_sip.c.*Registration from .* failed for '' - No matching peer found
asterisk.*chan_sip.c.*Registration from .* failed for '' - Username/auth name mismatch
asterisk.*chan_iax2.c.*register_verify: Host '' did not provide proper plaintext password for.*
asterisk.*chan_iax2.c.*register_verify: Host '' failed MD5 authentication for .*

ignoreregex =

Restart fail2ban, asterisk and rsyslog so the changes are applied. Make 5 login attempts with a wrong password and you should see a line in the netfilter firewall that blocks your IP.

To finish this shiny new configuration, you might want to add /var/log/auth-asterisk.log to the asterisk logrotate configuration file.

Vicidial Database Auto-Backup Script And Procedures

STEP 1:
mkdir /var/www/html/backup

STEP 2: Edit the file below.
nano /root/dbbackup.sh

STEP 3: Install mutt. Mutt is a text-based mail client along the lines of Pine or Elm.
yum -y install mutt

STEP 4: Paste the script below.

#!/bin/bash
echo "Starting to backup database"
mysqldump --opt -uroot -ppassword asterisk > /var/www/html/backup/vicidial-db_`date '+%Y-%m-%d'`.sql
echo "backup done..."
echo "Please wait, Compressing backup file..."
gzip /var/www/html/backup/vicidial-db_`date '+%Y-%m-%d'`.sql
echo "gzip done..."
echo " -- sending mail"
echo | mutt -s "Mysql Backup Done" emailaddress
echo "DONE"

STEP 5:
Save and exit.

STEP 6:
chmod 755 /root/dbbackup.sh

STEP 7:
crontab -e

STEP 8: Copy and paste the script below at the lower part of crontab.

### Fixing and Optimizing Database
30 1 * * 0 /usr/bin/mysqlcheck -ucron -p1234 --auto-repair --check --optimize --all-databases

### Weekend Database Back-up after operation every Sunday 2PM
0 2 * * 0 /root/dbbackup.sh

### Delete Database backup
24 0 * * 0 /usr/bin/find /var/www/html/backup -maxdepth 1 -name "vicidial-db*.*" -mtime +30 -print | xargs rm -f

STEP 9:
Save and exit

11 July 2012

Install Open Source VMware Tools on Linux Red Hat/CentOS 6



VMware makes a repository available to install the VMware tools for a variety of Linux distributions including Red Hat, CentOS.

1. Import the VMware repository GPG public keys:

rpm --import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub
rpm --import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub


2. Add the VMware repository:

Create the file "vmware-tools.repo" in the directory "/etc/repos.d/".

touch /etc/yum.repos.d/vmware-tools.repo

Add the following lines:

[vmware-tools]
name=VMware Tools
baseurl=http://packages.vmware.com/tools/esx/4.1latest/rhel6/$basearch
enabled=1
gpgcheck=1



3. Install VMware tools:

yum install -y vmware-open-vm-tools

Setting CallerID in Asterisk and A2Billing


Configuring Asterisk to set CallerID

This can be done easily by inserting the following code in your sip.conf:

exten => _X.,1,Set(CALLERID(num)=+32484212093)

Doing this will set the CallerID to +32484212093

If you want to set the callerID to Private simply erase it by doing:

exten => _X.,1,SET(CALLERID(name)=anonymous)


exten => _X.,2,SET(CALLERID(num)=anonymous)

Attention:

Invalid CallerID's will be automatically set to Private by the terminating carrier.

A2Billing send connect signal for calls too early


When using A2Billing to place wholesale calls it’s possible that A2Billing send connect signal for a call before it is answered.

The reason that this happens is that Asterisk is answering the call, when it doesn’t need to. It only needs to answer the call if you want to play audio to the caller (balance, time remain...) but you would not normally do this for wholesale calls.



Solution:
  1. Ensure Asterisk does not answer the callIn your Asterisk dial plan, ensure that the context that SIP calls are getting passed to does not have an "Answer" line in it. The used context is "a2billing" and it is in the "/etc/asterisk/extensions.conf" file.[billing]exten => _X.,1,Agi(a2billing.php,1).
  2. Ensure A2Billing is not set to answer the callIn the agi-conf that you are using for the calls, ensure that the "answer_call" option is set to "no".

  1. Ensure there is no "H" on the Asterisk dial commandHaving a "H" in the A2Billing dialcommand_param can cause Asterisk to answer the call and cause incorrect billing. 



Google plus one button XHTML compliant

Introduction:

+1 buttons let people who love your content recommend it on Google search
If you added a Google +1 button to your website, you certainly noticed that the Google +1 button is not valid at all.

Installation:
Include the google plus one javascript file somewhere on your page between and tags.



Add this special tag in the location where you would like your plus one button to appear. Your tag will look something like this:


W3C error:
element "g:plusone" undefined

Correction:
The following XHTML code is W3C compliant for the plus one button.
  1. Include the google plus one javascript file somewhere on your page between and tags.
  2. Add this special tag in the location where you would like your plus one button to appear. Your tag will look something like this:

Configure Paypal with A2Billing


System settings configuration:

System settings > Group list > epayment_method

enable

Enable e-payment methods
Value: Yes

http_server

Server address of customer website. (It should be empty for productive Servers)
Value:

https_server

Secure customers server address
https: // www.ighost.com

http_cookie_domain

Domain Name or IP Address for the Customers application
Value:

https_cookie_domain

Secure server Domain Name or IP Address for the Customers application
Value: 888.683.814.888

enable_ssl

Secure webserver for checkout procedure
Value: Yes

http_domain

Http Address
Value: 888.683.814.888

paypal_payment_url

URL of the paypal gateway
Value: https://secure.paypal.com/cgi-bin/webscr

paypal_verify_url

Paypal transaction verification url
Value: ssl://www.paypal.com

store_name

Paypal store name to show in the paypal site
Value: iGhost.com




Payment configuration:

Billing > Payment methods > Click to paypal view details

Enable PayPal Module
Value: True

E-Mail Address (The e-mail address to use for the PayPal service)
Value: atef@atefsaeed.com



Least Cost Routing (LCR) with A2Billing


Introduction:
One way A2Billing supports least cost routing using multiple providers is when each provider’s data have the exact same length prefixes for each area. But most (probable 95%) of the time this is not the case so just importing providers rates and expecting a2billing to find the least cost route will give one a very sad disappointment. Many providers will have many of the same prefixes but almost all will have many that are different length for same areas.
Example:
  • Provider A gives USA rates by area code and prefix 812 which is three digits. (Rate = 0.015)
  • Provider B gives USA rates by area code and prefix 812739 which is six digits. (Rate = 0.01)
  • Provider C gives USA rates by area code and prefix 8127392 which is 7 digits. (Rate = 0.03)
When a call is made to 812-739-2340 the call will go out Provider C even though its double the rate of Provider A and three times the rate of Provider B. This is because A2Billing looks for the longest prefix.
The best way at the moment to use the A2Billing least cost routing is by converting all the prefixes for all the providers to match the longest used prefix for any giving area.
Solution:
Here is a free program to help converting prefixes from different providers to the same format. I can send sources on demand (Created with Delhi 7).
http://www.data4ict.com/download/lcr.zip

User manual:

  1. Create a csv file with longest prefixesFormat: Prefix,Destination
  2. Create a csv file with the rates of your provider (One csv file by provider)Format: Prefix,Destination,Price
  3. Generate the LCR output table
  4. Export the generated file (csv format)


Demo:
Here are four files (Prefixes, Provider1, Provider2, Provider3) to test the program.
http://www.data4ict.com/download/lcr_demo.zip


A2Billing - Fake ring


As soon as a call is passed, it is possible for A2Billing to tell Asterisk to pass back a ringing tone to the caller, while the call is being processed.
Asterisk - Dial command - Option "r"
r: Generate a ringing tone for the calling party, passing no audio from the called channel(s) until one answers. Without this option, Asterisk will generate ring tones automatically where it is appropriate to do so; however, "r" will force Asterisk to generate ring tones, even if it is not appropriate.
Disable this option
In the agi-conf that you are using for the calls, remove the "r" option.


09 February 2012

A2Billing System Settings

  • Global List
  • Group List
  • Add Agi-conf
  • Config Editor 
System Settings are where the different areas of the platform are setup, including the agi-conf(s) which manage the call in progress.
    • Global - System wide settings such as currency.
    • Call-Back - Call-back behaviour
    • WebcustomerUI - Configuration variables for the customer interface
    • SIP-IAX-Info - VoIP customer configuration information.
    • Epayment_method - Configure online payment gateways.
    • Signup - Sign-up related settings.
    • Backup - Backup and restore settings.
    • WebUI - WebUI and API configuration
    • Peer_friend - Default settings for auto-creation of VoIP accounts.
    • Log-files - Handles the location of the log files.
    • Agi-conf1 - The default agi-conf controlling the call in progress.
    • Notifications - Notifications configuration.
    • Dashboard - Dashboard configuration.
    • WebAgentUI - Handles the agent user interface parameters.
New agi-conf can be added as required and addressed via the asterisk dialplan. Agi-conf1 is by default set up for calling card operations. All subsequent agi-confs are copied from the agi-conf1 settings. Different agi-conf are required to provide different services, e.g. calling card or VoIP.

A2Billing Initial Set-up

This guide takes you through the initial stages of setting up A2Billing for production.

System Settings | Global Settings.

Set the base currency, manager settings timezones, and all the other settings which are appropriate to your installation. Note that if you change the currency, you also have to update the currencies under Billing | Currency List

Trunks

Create the trunks to the service provider in Asterisk, and confirm they work by configuring an extension in Asterisk and dialling out via the new trunk. Then tell A2Billing that the trunks exist and they can be used in the Providers | Trunks section.

Call-plans & Rate Tables

Create a call-plan and rate tables under rates. The relationship is that one customer has one call plan, which may have multiple rate tables (usually one per trunk) which in turn has multiple rates. Edit the call-plan and add the rate tables pertaining to that call-plan.

Rates

Create your rates and upload them into your rate tables, Note that the longest match of dial-code to dialed-digits is chosen first, and that a call cannot be made unless a rate exists for the destination.

Asterisk Dial-Plan

A VoIP dial-plan may look like...
[a2billing]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,DeadAgi(a2billing.php,1)
exten => _X.,1,Hangup()
...whereas a calling card dial-plan may look like this: -
[a2billing-callingcard]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,Answer()
exten => _X.,n,Wait(2)
exten => _X.,n,DeadAgi(a2billing.php,1)
exten => _X.,1,Hangup()
Note that with VoIP, the call is not usually answered, whereas with a calling card, it is, so you can play audio to the customer. A2Billing VoIP accounts will use the a2billing context by default, whereas you will have to configure your calling card access number to pass into the a2billing-callingcard context.

Agi-Conf

The “1” after “a2billing.php” in the above dial-plan examples refer to which agi-conf to use. The agi-conf under System Settings controls the call in progress and how the call is to behave, e.g. whether to read out the balance, prompt for the number to call, ask for PIN etc. The agi-conf is well commented, so set its parameters according to the way that you want to handle the call.

Create Customer and Test

Once you have defined your product using call-plans and rates, then you can create a new customer, and at the same time this, by default, creates new VoIP settings. You can now register a VoIP phone or test calling cards once you have added credit to the customer's account.

A2Billing Install Guide

Some knowledge of Asterisk and Linux is expected in order to install the system.
  1. Install Asterisk with Asterisk Realtime, MySQL, Apache and PHP version 5.2
  2. Download and explode the A2Billing tarball.
  3. Move, copy or symlink the Admin, Customer, Agent and Common directories into web-root, or configure apache to display them in a directory of your choice.
  4. Move copy or symlink AGI/a2billing.php into the asterisk agi-bin directory, and also copy or symlink the common/lib directory.
  5. Create a new A2Billing database then create the database schema with DataBase/mysql-5.x/a2billing-mysql-schema-v1.7.0.sql
  6. Apply each “DataBase/mysql-5.x/UPDATE...” SQL file in order from 1.7.0 to the latest version.
  7. Place a2billing.conf in /etc/ and adjust the database settings to suit your install.
  8. Move or copy your sound files from addons/sounds/ into the asterisk “sounds” directory.
  9. Install the cronjobs from the Cronjobs/ directory. The comments at the top of each file give a suggested schedule for each cronjob.
  10. Configure the Asterisk dial-plan for A2Billing using the files in addons/asterisk-conf/ as a guide.
The role of A2Billing is to provide public telephony services and therefore in the majority of cases, customers must be given access by both web services and VoIP. A2Billing is often better hosted on a public IP address to reduce NAT issues.
Although an aggregation or PBX distribution can be used as a base for A2Billing, most are not security hardened for connection directly to the Internet and indeed are provided with the caveat that they should be located behind a separate hardware firewall with no access allowed from outside the LAN (Local Area Network).
Note that any telephony server exposed to the internet is a valuable target where an attacker can make real money using a variety of fraudulent techniques. Therefore great care should be taken in building any telephony system to ensure that it is secure.
We recommend that all customers and users operate the latest version of A2Billing. In general we have a policy of not removing any functionality from A2Billing, so there is little or no danger in upgrading to the latest stable version.

How Call-Back Works

Call-Back services are often used in countries where the cost of making an international call is very expensive, and the customer can save money by launching a call from another country, and then being presented with secondary dial-tone so that they can make an onwards call.
How Call-Back Works
How Call-Back Works
A2Billing supports a number of ways of triggering a call-back. A call is triggered to the customer, this is called the A leg, and then the customer can make an onwards call. This is called the B Leg.
The customer calls an access number or trigger number on the A2Billing platform, the call is never answered, so the customer is not charged for this call, even if the trigger number is an international number.

ANI Call-Back

The A2Billing platform captures the caller ID of the caller, and a few seconds later, giving the customer time to hang up their phone after triggering the call-back, a call is launched back to the customer. The customer is then prompted for a PIN number to identify the customer, alternatively, their caller ID is recognized, and secondary dial tone is presented, prompting the customer to dial their desired destination.

DID Call-Back

DID based call-back is used in circumstances where the caller ID is not always delivered reliably, often in an effort to block call-back services by the incumbent operator. The customer calls their own personal DID, which in turn triggers a call-back to a previously defined number. This is expensive on DID usage, but may be the only reliable methodology.

Web Based Call-Back

As standard with A2Billing, there is a Customer Portal, and one of the options with the portal is to be able to launch a call-back. The customer types in the number they want to receive the call-back on, and the telephone number of the person they want to call. The call-back is launched with a call to the customer first, and then as soon as they pick up the phone, the second leg of the call is launched to the person they want to call.

IVR Call-Back

IVR call-back is a system developed where tone clamping takes place. The customer rings the trigger number, and via an IVR, is prompted for the number to call, and the number to call-back on. The cost to the customer is a brief call to the access number charged by their operator, then the call-back and subsequent conversation is then charged via A2Billing.

How Billing Works

A2Billing can authenticate calls in a number of ways:-
  1. VoIP registration – the endpoint is registered to A2Billing with a username and password.
  2. IP Address – All calls accepted from a specific IP address.
  3. PIN Authentication – Using a unique PIN code.
  4. Caller ID authentication – Using the CID for authentication. (Pinless dialling)
When a call comes into A2Billing, the customer is recognised using one of the above methods. From their identity, we know the amount of credit available for that customer.
The customer's dialled digits are captured, and from the rate tables pertaining to that particular customer, we know the rate for the destination.
By dividing the available balance by the cost per minute of the call, the total maximum duration of the call can be calculated. A “Dial” command is sent to Asterisk with the total time allowed for the call.
At the end of the call, which is either forcibly disconnected by Asterisk or when either party hangs up, the actual cost of the call is calculated, and the customer's balance decremented.
A2Billing has a very flexible billing system including connection and disconnection charges and stepped billing.

DID Resale

A2Billing is equipped for DID (Telephone Number) resale  and redirection with a variety of charging methods. DID are delivered to the switch from VoIP DID providers or via a PRI. (Primary Rate Interface)
DID Resale

Monthly Subscriptions

Monthly Subscription – a fixed rental for the DID is removed from the customers account on the monthly anniversary of the DID's destination being set up.

A-Leg DID Billing

A-Leg – DID ingress charges are applied per minute. Connection charges can also be applied. Per minute billing can be negative or positive making it suitable for apportioning revenue for revenue share numbers.

B-Leg DID Billing

B-Leg - DID egress charges can be applied for numbers directed to PSTN destinations via A2Billing trunks, or the calls can simply be passed directly to a VoIP destination.

ON-Net DID Billing

On-Net charges can be applied, so that customers can phone each another, and a charge be made for the call, but no carrier charges are incurred, as the DID routes through the platform.

Purchase DID online

Customers can purchase new DID online via the customer portal.

DID Failover

A number of destination priorities can be set up to allow calls to failover to PSTN destinations if the VoIP destination is unavailable. This makes A2Billing particularly suitable for delivering DID reliably to business IP-PBX systems.

How Calling Cards Work

Calling card services is still one of the best ways to allow people to make low cost international calls from their mobile and fixed line phone, and very profitable businesses have been built around the calling card features available on an A2Billing Softswitch.
How Calling Cards Work


A calling card customer calls a DID or access number which is directed to the A2Billing Softswitch. The calling card customer is then prompted for some identification. The A2Billing Softswitch supports both identification by PIN or on the basis of the caller ID, otherwise known as Pinless Dialling.
Optionally, the balance is read out, and the calling card customer is presented with secondary dial-tone, or prompted to dial the number they require.
The rate the customer pays for the call is usually far lower than the cost of the same call using a payphone, the incumbent telephone company or a cell-phone. This is particularly true of international calls.

08 February 2012

Overview of A2Billing

Below is a diagram showing the calls and data-flow between the entities in A2Billing.
A2Billing, A Business in a Box
A2Billing, A Business in a Box

Services

A2Billing can provide a number of services to the end customers including, but not limited to, Wholesale, business and residential VoIP origination and termination, calling card and call-back services, and special applications requiring telephony and billing.

Termination and Origination

A2Billing supports origination and termination using a variety of technologies such as VoIP, PSTN (PRI, BRI and analogue circuits) and GSM gateways.

Revenue Management

A2Billing has a number of payment methods including online payment processors including Paypal, as well as manual payment and top-ups using vouchers via an IVR or the customer's portal with full accounting and reporting.

Sales and Marketing

A2Billing supports commission agents allowing online signup and affiliate marketing, as well automated signup via a simple telephone call providing easy customer acquisition.

Softswitch Architecture

The architecture of A2Billing consists of a database server, Asterisk telephony server and a web-server for administration, agent, customer and online sign-up. Usually these servers are hosted on the same physical hardware, but can be distributed across multiple servers to increase the capacity. A SIP proxy can be added to load balance calls across multiple Asterisk servers and assist with NAT traversal.

VoIP Billing & Termination

There are three main customer types for Voice over IP, and A2Billing supports all of them with flexible VoIP Billing and charging options.

Residential VoIP

Residential VoIP

Residential VoIP - Providing VoIP services, VoIP Billing and DID redirection to the general public. The endpoint is usually a PC-Dialler (or softphone) a physical VoIP phone or ATA. The latest smartphones also support VoIP.

Business VoIP

VoIP for Business

Business VoIP - Providing VoIP termination to IP-PBX systems for companies, billing the calls, as well as providing invoices for VoIP services as well as supplying DID directed to the IP-PBX via VoIP or PSTN.

Wholesale VoIP


Wholesale VoIP - Terminating and billing large numbers of calls from a customer who has an A2Billing Softswitch or similar class 4 or class 5 switch.
The only difference between the above types of service as far as A2Billing is concerned in in terms of volume. Configuration is broadly similar for each service.
The A2Billing Softswitch supports both the SIP and IAX2 protocol as well as a range of VoIP codec protocols, such as g711 which is a high quality uncompressed codec. Where bandwidth is limited, the supplied GSM codec can be used or commercial g729 licenses or g729 voice compression cards for high capacity systems are available.
The customer’s end-point is configured to pass its VoIP traffic through the A2Billing Softswitch, where the call is then least cost routed via the lowest cost carrier, the call is rated, and the customers available balance decremented.

A2Billing Install Guide

Some knowledge of Asterisk and Linux is expected in order to install the system.
  1. Install Asterisk with Asterisk Realtime, MySQL, Apache and PHP version 5.2
  2. Download and explode the A2Billing tarball.
  3. Move, copy or symlink the Admin, Customer, Agent and Common directories into web-root, or configure apache to display them in a directory of your choice.
  4. Move copy or symlink AGI/a2billing.php into the asterisk agi-bin directory, and also copy or symlink the common/lib directory.
  5. Create a new A2Billing database then create the database schema with DataBase/mysql-5.x/a2billing-mysql-schema-v1.7.0.sql
  6. Apply each “DataBase/mysql-5.x/UPDATE...” SQL file in order from 1.7.0 to the latest version.
  7. Place a2billing.conf in /etc/ and adjust the database settings to suit your install.
  8. Move or copy your sound files from addons/sounds/ into the asterisk “sounds” directory.
  9. Install the cronjobs from the Cronjobs/ directory. The comments at the top of each file give a suggested schedule for each cronjob.
  10. Configure the Asterisk dial-plan for A2Billing using the files in addons/asterisk-conf/ as a guide.
The role of A2Billing is to provide public telephony services and therefore in the majority of cases, customers must be given access by both web services and VoIP. A2Billing is often better hosted on a public IP address to reduce NAT issues.
Although an aggregation or PBX distribution can be used as a base for A2Billing, most are not security hardened for connection directly to the Internet and indeed are provided with the caveat that they should be located behind a separate hardware firewall with no access allowed from outside the LAN (Local Area Network).
Note that any telephony server exposed to the internet is a valuable target where an attacker can make real money using a variety of fraudulent techniques. Therefore great care should be taken in building any telephony system to ensure that it is secure.
We recommend that all customers and users operate the latest version of A2Billing. In general we have a policy of not removing any functionality from A2Billing, so there is little or no danger in upgrading to the latest stable version.


A2Billing Initial Set-up

System Settings | Global Settings.

Set the base currency, manager settings timezones, and all the other settings which are appropriate to your installation. Note that if you change the currency, you also have to update the currencies under Billing | Currency List

Trunks

Create the trunks to the service provider in Asterisk, and confirm they work by configuring an extension in Asterisk and dialling out via the new trunk. Then tell A2Billing that the trunks exist and they can be used in the Providers | Trunks section.

Call-plans & Rate Tables

Create a call-plan and rate tables under rates. The relationship is that one customer has one call plan, which may have multiple rate tables (usually one per trunk) which in turn has multiple rates. Edit the call-plan and add the rate tables pertaining to that call-plan.

Rates

Create your rates and upload them into your rate tables, Note that the longest match of dial-code to dialed-digits is chosen first, and that a call cannot be made unless a rate exists for the destination.

Asterisk Dial-Plan

A VoIP dial-plan may look like...
[a2billing]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,DeadAgi(a2billing.php,1)
exten => _X.,1,Hangup()
...whereas a calling card dial-plan may look like this: -
[a2billing-callingcard]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,Answer()
exten => _X.,n,Wait(2)
exten => _X.,n,DeadAgi(a2billing.php,1)
exten => _X.,1,Hangup()
Note that with VoIP, the call is not usually answered, whereas with a calling card, it is, so you can play audio to the customer. A2Billing VoIP accounts will use the a2billing context by default, whereas you will have to configure your calling card access number to pass into the a2billing-callingcard context.

Agi-Conf

The “1” after “a2billing.php” in the above dial-plan examples refer to which agi-conf to use. The agi-conf under System Settings controls the call in progress and how the call is to behave, e.g. whether to read out the balance, prompt for the number to call, ask for PIN etc. The agi-conf is well commented, so set its parameters according to the way that you want to handle the call.

Create Customer and Test

Once you have defined your product using call-plans and rates, then you can create a new customer, and at the same time this, by default, creates new VoIP settings. You can now register a VoIP phone or test calling cards once you have added credit to the customer's account.