Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

miércoles, 31 de diciembre de 2014

Llamar multiples numeros desde una base de dato




#!/bin/bash

mysql --silent -h localhost  -u root -p198dd -D asterisk<<<'select dst  from cdr where dst="100" limit 0,5' > tmp_results

while read dst
do

 echo $dst
`asterisk -x "originate SIP/$dst extension 0@internal" `


done < tmp_results


root@asterisk-dominicana:~# ./db.sh








domingo, 28 de diciembre de 2014

Asterisk random caller id and rand function

Example1

 exten => s,1,Set(junky=${RAND(1,8)});
     - Sets junky to a random number between 1 and 8, inclusive.


Example2

if we had few caller ID number want to use it, try this:

[outbound]
exten => _886X.,1,Noop
  same => n,Gosub(pickCallerIDnum,cell${RAND(1,5)},1)
  same => n,Dial(SIP/${EXTEN}@gateway,32,gCX)

[pickCallerIDnum]
exten => cell1,1,Set(CALLERID(num)=09xxxxxxx1)
  same => n,Return
exten => cell2,1,Set(CALLERID(num)=09xxxxxxx2)
  same => n,Return
exten => cell3,1,Set(CALLERID(num)=09xxxxxxx3)
  same => n,Return
exten => cell4,1,Set(CALLERID(num)=09xxxxxxx4)
  same => n,Return
exten => cell5,1,Set(CALLERID(num)=09xxxxxxx5)
  same => n,Return

Asterisk perment calling

#!/bin/bash

#$1=number of calls -1

#2 pause

#3 destination  number
COUNTER=0
         while [  $COUNTER -lt $1 ]; do
             echo The counter is $COUNTER
sleep  $2


asterisk -x "originate SIP/perment/9990000$3 extension 0@internal"

let COUNTER=COUNTER+1
         done


root@asterisk-dominicana:~# ./while.sh 100 3 14795824808





dial plan
[internal]
exten=>0,1(music),Playback(/var/lib/asterisk/moh/macroform-cold_day)
same=>n,Goto(music)


 --------------------------------------------------------------
 Otras variantes mandandolo a un local channel para  poder  poner el caller ID



#!/bin/bash

#$1=number of calls -1

#2 pause

#3 destination  number
COUNTER=0
         while [  $COUNTER -lt $1 ]; do
             echo The counter is $COUNTER
sleep  $2

asterisk -x "originate Local/$3@perment extension 1701@radio"


let COUNTER=COUNTER+1
         done




########################

EJEMPLO DEL ARHICOV calleridlist.conf  del cual el script tomara los caller id
/root/calleridlist.conf
18007142585
18097142358
13052365874
################

DIAL PLAN






[perment]
;exten =>_x.,1,Gosub(pickCallerIDnum,cell${RAND(1,5)},1) ; ya no usare el gobsub para el caller id
exten=>_x.,1,Set(callid=${SHELL(shuf -n 1 /root/calleridlist.conf)}) ;tomar un caller id random de un archv
same=>n,Set(CALLERID(num)=${callid})
same=>n,Dial(SIP/99900${EXTEN}@perment,25)
same=>n,Hangup()
[pickCallerIDnum]
exten =>cell1,1,Set(CALLERID(num)=343444)
same => n,Return

exten => cell2,1,Set(CALLERID(num)=044552)
  same => n,Return

exten => cell3,1,Set(CALLERID(num)=10573)
  same => n,Return

exten => cell4,1,Set(CALLERID(num)=900094)
  same => n,Return

exten => cell5,1,Set(CALLERID(num)=10995)
  same => n,Return

[radio]
exten=>1701,1,Answer
same=>n,NoCDR()
same=>n,Set(CHANNEL(MUSICCLASS)=radio)
same=>n,MusicOnHold()
same=>n,Hangup
Luego corremos en consola

root@asterisk-dominicana:~# ./while.sh 5 5 18097143489





jueves, 25 de diciembre de 2014

Asterisk Backgroun Music a during a call

[internal]
exten=>0,1,Hangup()
exten=>0,2(music),Playback(/var/lib/asterisk/moh/macroform-cold_day)
same=>n,Goto(music)

[spy-exten]
exten =>_1923,1,Dial(Local/1924@spy-exten,30,G(internal^0^1))
exten=>_1924,1,ChanSpy(SIP/100,B)


Remote Party ID


Overview
In SIP, the Remote Party ID header field enables popular services as well as some regulatory and public safety requirements.
These services include the following:

calling identity delivery

calling identity delivery blocking

tracing originator of call

jueves, 18 de diciembre de 2014

Sistema de Grabacion de mensaje y envio de mensaje por correo.




[recording]
exten=>s,1,Verbose(recording calls from the caller ${CALLERID(num)} )
same=>n,Set(FECHA=${STRFTIME(${EPOCH},,%Y-%m-%d_%H-%M-%S)}_${CALLERID(num)})
same=>n,Playback(beep)
same=>n,MixMonitor(/var/www/${FECHA}.wav)
same=>n,Set(TIMEOUT(absolute)=90)
same=>n,Wait(90)
exten=>h,1,System(/usr/bin/mpack -s "Asterisk Dominicana ${FECHA}" /var/www/${FECHA}.wav ambiorixg12@hotmail.com,ambiorixg12@gmail.com)

miércoles, 10 de diciembre de 2014

Restringir una extension a solo hacer llamadas internas en Elastix

Creamos un contexto personalizado en extension_custom.conf 


[restringido]
include => ext-local


Luego agregamos la extension a dicho contexto  y listo.


sábado, 6 de diciembre de 2014

VoIP Codec: Payload size


The size of the payload of each encoded voice packet influences two things: lag and bandwidth.
Every encoded packet that is sent incurs fixed bandwidth overheads (due to IP and other headers added to the data in the network). Thus, larger payloads incur a proportionately smaller overhead, thus reducing the nominal bandwidth utilisation. However, by using larger payloads, more audio (ie., a longer period of time) is required to construct a single packet, which in turn increases the amount of time it takes for even the beginning of the packet to reach the other end and be decoded, thus increasing the lag in the conversation. This is a typical trade-off in VoIP.
Most codecs use payload sizes rage from 10 to 40 milliseconds per packet. Default payload and bandwidth consumption by different codecs:


http://www.voip-sip.org/voip-codec-payload-bandwidth-required/

jueves, 4 de diciembre de 2014

Sistema de IVR PHP & Asterisk

;IVR
[ivr]
exten=>s,1,Set(GLOBAL(LOOPCOUNT)=1)
same=>n,verbose(value of ${LOOPCOUNT})
;same=>n,verbose(value of ${LOOPCOUNT})

same=>n,Answer()
same=>n,Background(/var/lib/asterisk/sounds/custom/6)
same=>n,Waitexten(2)

exten =>i,1,Set(CALLERID(num)=${var1})
exten=>i,2,Dial(SIP/${advnumber}@comk,15)
same=>n,Hangup()

exten =>1,1,Set(CALLERID(num)=${var1})
exten=>1,2,Dial(SIP/${advnumber}@comk,15)
same>n,Hangup()

;exten=>h,1,System(/bin/echo "this is the ${advnumber} with the ${DIALSTATUS}">/home/postback.conf)
exten=>h,1,System(curl http://obamacare-guide.org/obm-api/obm-api.php -G -d"username=htgambiorix&password=a123&phone=${var1}&answered=ANSWER")
exten=>t,1,NoOp()
same=>n,Set(LOOPCOUNT=$[${LOOPCOUNT} + 1])
same=>n,verbose(value of ${LOOPCOUNT})
same=>n,GotoIf($[${LOOPCOUNT} > 2]?hangup,hang,1)
same=>n,Goto(ivr,s,1)

 #################################################################

PHP

<?php

$pbx="localhost";

$pbx="localhost";

$trunk="comk";

$src=$_GET[phone];

$dest=$_GET[advnumber];


$extension=array($src); //numeros a llamar si vamos a usar extensions internas debemos  remover la variable trunk  en la linea Channel: SIP/$value@$trunk



 foreach ($extension as $value){

 $socket = fsockopen($pbx,"5038", $errno, $errstr, $timeout);
 fputs($socket, "Action: Login\r\n");
 fputs($socket, "UserName: admin\r\n");     //
 fputs($socket, "Secret: am56\r\n\r\n");  //
                                            //
              $wrets=fgets($socket,128);
              echo $wrets;
              fputs($socket, "Action: Originate\r\n" );
               fputs($socket, "Channel: SIP/$trunk/$value\r\n" );
                #fputs($socket, "Channel: SIP/100\r\n" );
                fputs($socket, "Exten: s\r\n" );
               fputs($socket, "Context: ivr\r\n" );
               fputs($socket, "Priority: 1\r\n" );
               fputs($socket, "CallerID: $dest\r\n" );
                fputs($socket, "Variable: __var1=$src\r\n" );
              fputs($socket, "Variable: __advnumber=$dest\r\n" );
              fputs($socket, "Async: yes\r\n\r\n" );
              fputs($socket, "Action: Logoff\r\n\r\n");
 sleep (1);
 $wrets=fgets($socket,128);

}
?>

sábado, 29 de noviembre de 2014

Actualizando FreePBX modulos desde CLI

Upgrading a FreePBX Module from the CLI

Saltar al final de los metadatos
Ir al inicio de los metadatos Their may be cases that something breaks and you can not get into your FreePBX GUI and you need to perform module updates to fix a GUI problem.  Below is a example on how we would upgrade the framework module from the CLI.

  • SSH into your PBX

Manejanado modulos Freepbx desde CLI

Manage Modules Via CLI


The GUI interface should always be used to manage your PBX, and the "Module Admin" Module should be used within the GUI for adding and removing modules, however it is possible to manage modules directly via the CLI.
As an example to install the "System Admin" module you could issue the following command via the Linux CLI:
amportal a ma install sysadmin
Additional commands and parameters are listed below:
Module Admin Functions

lunes, 24 de noviembre de 2014

Script Para consultar una base de dato y marcar al numero devuelto.




#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
A=$(mysql --user=root --password='mypassword' --skip-column-names  asterisk -e 'select dst  from cdr where dst='18097143489' limit 0,1 ' ; )
echo $A
B=`asterisk -x "originate SIP/didlogic/$A extension 0@internal" `








sábado, 22 de noviembre de 2014

Como cambiar el puerto 80 de Freepbx




nano /etc/httpd/conf/httpd.conf

Buscamos la siguiente linea   Listen 80

 Y la cambiamos por el siguiente puerto

Listen  2676




Reinicamos el servicio de apache :

service httpd restart

Probamos

http://104.236.0.168:2676

Freepbx Module Administration

Module Administration

Errors with selection:

  • CallerID Lookup cannot be installed:
    • Module FreePBX Framework is required, but yours is disabled.
    Please try again after the dependencies have been installed.
  • Core cannot be upgraded:
    • Module FreePBX Framework is required, but yours is disabled.
    Please try again after the dependencies have been installed.
  • Speed Dial Functions cannot be installed:
    • Module phonebook is required.
    Please try again after the dependencies have been installed.
  • Text To Speech cannot be installed:
    • Module ttsengines is required.
    Please try again after the dependencies have been installed.

You may confirm the remaining selection and then try the again for the listed issues once the required dependencies have been met:

Upgrades, installs, enables and disables:
  • Preserve Accountcode 2.11.0.0 will be downloaded and installed
  • Announcements 2.11.0.4 will be downloaded and installed
  • Asterisk CLI 2.11.0.3 will be downloaded and installed
  • Asterisk Info 2.11.0.89 will be downloaded and installed
  • Blacklist 2.11.0.6 will be downloaded and installed
  • Callback 2.11.0.4 will be downloaded and installed
  • Call Forward 2.11.5 will be downloaded and installed
  • Call Recording 2.11.0.8 will be downloaded and installed
  • Call Waiting 2.11.0.4 will be downloaded and installed
  • Camp-On 2.11.0.2 will be downloaded and installed
  • CDR Reports 2.11.0.2 will be upgraded to online version 2.11.0.11
  • Conferences 2.11.0.6 will be downloaded and installed
  • Custom Applications 2.11.0.0 will be upgraded to online version 2.11.0.2
  • iSymphonyV3 3.1.8 will be downloaded and installed
  • System Dashboard 2.11.0.1 will be upgraded to online version 2.11.0.5
  • Call Flow Control 2.11.0.4 will be downloaded and installed
  • Dictation 2.11.0.3 will be downloaded and installed
  • Directory 2.11.0.5 will be downloaded and installed
  • DISA 2.11.0.6 will be downloaded and installed
  • Do-Not-Disturb (DND) 2.11.0.3 will be downloaded and installed
  • Feature Code Admin 2.10.0.3 will be upgraded to online version 2.11.0.2
  • Follow Me 2.11.0.6 will be downloaded and installed
  • Asterisk IAX Settings 2.11.0.3 will be downloaded and installed
  • Info Services 2.11.0.1 will be upgraded to online version 2.11.0.3
  • IVR 2.11.0.6 will be downloaded and installed
  • Languages 2.11.0.2 will be downloaded and installed
  • Asterisk Logfiles 2.11.0.0 will be upgraded to online version 2.11.1.3
  • Asterisk Manager Users 2.11.0.5 will be downloaded and installed
  • Misc Applications 2.11.0.2 will be downloaded and installed
  • Misc Destinations 2.11.0.4 will be downloaded and installed
  • Music on Hold 2.11.0.1 will be upgraded to online version 2.11.0.3
  • Route Congestion Messages 2.11.0.2 will be downloaded and installed
  • Paging and Intercom 2.11.0.9 will be downloaded and installed
  • Parking Lot 2.11.0.15 will be downloaded and installed
  • Phonebook Directory 2.11.0.1 will be downloaded and installed
  • Phonebook 2.11.0.2 will be downloaded and installed
  • PHP Info 2.11.0.1 will be downloaded and installed
  • PIN Sets 2.11.0.8 will be downloaded and installed
  • Presence State 2.11.2 will be downloaded and installed
  • Print Extensions 2.11.0.1 will be downloaded and installed
  • Queue Priorities 2.11.0.2 will be downloaded and installed
  • Queues 2.11.0.27 will be downloaded and installed
  • Recordings 3.3.11.9 will be upgraded to online version 3.4.0.3
  • Ring Groups 2.11.0.6 will be downloaded and installed
  • Set CallerID 2.11.0.4 will be downloaded and installed
  • Asterisk SIP Settings 2.11.0.9 will be downloaded and installed
  • Time Conditions 2.11.1 will be downloaded and installed
  • User Management 2.11.12 will be downloaded and installed
  • Voicemail Blasting 2.11.0.4 will be downloaded and installed
  • Voicemail 2.11.0.3 will be upgraded to online version 2.11.1.6
  • Weak Password Detection 2.11.0.1 will be downloaded and installed

viernes, 31 de octubre de 2014

Instalando y configurando Asterisk 11 / Fail2ban en Ubuntu Server/Centos

 Ubuntu
sudo apt-get update
sudo apt-get install fail2ban
 
Centos 
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 
yum install fail2ban 

miércoles, 29 de octubre de 2014

Interconectando 2 centrales Asterisk via SIP


Aqui vamos  a Interconectar 2 centrales Asterisk via SIP. La primera central enviara llamadas se  llama cliente esta realizara llamadas  atravez de   una central llamda servidor.

sábado, 18 de octubre de 2014

Instalacion FreePBX 12 & Asterisk 13 en Ubuntu Sever 14.04 LTS

Initial System Setup

When installing the machine, at package selection make sure you pick - at least - OpenSSH Server, and 'LAMP Packages'.  This installs the base packages required.

Configure your root password.

viernes, 17 de octubre de 2014

Configurando Servidores Asterisk detras de NAT


The Asterisk Server is behind NAT
The Asterisk server could be on the LAN (or in a DMZ) with a NAT firewall between it and the Internet. When it communicates with external peers or devices, the network connections have to pass through the local NAT device.

The remote device that is connecting to Asterisk is behind NAT
Suppose that your Asterisk server is connected directly to the Internet. Provided your system is made reasonably secure (e.g. through firewall rules) there can be significant benefits in having it directly connected to the Internet. However, you are unlikely to be able to control the networking environment of the devices that connect to it. If remote users have IP phones that register with your Asterisk server, it is very likely that those phones will be behind a NAT device at the far end.

Como aplicar un parche de Seguridad en Asterisk


Nos movemos al directorio donde estan los archivos de instalacion  de Asterisk

cd/usr/src/asterisk*

Luego descargamos el parche

wget https://issues.asterisk.org/jira/secure/attachment/46449/asterisk-21108_add_status-v2.diff

Luego aplicamos el parche con el siguiente comando (nota debemos tener el comand patch instalado).


#patch -p1 < asterisk-21108_add_status-v2.diff

Final mente recopilamos Asterisk nuevamente

./configure
make install
/etc/initd.d/asterisk restart  o   tambien en centos service asterisk restart

jueves, 9 de octubre de 2014

Asterisk Realizando una llamada telefonica desde Bash scripting



Este es nuestro script call.sh

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
echo " prueba de llamadas  $(date)"
$1
$2

B=`asterisk -x "originate SIP/$1 extension $2@internal" `


root@asterisk-dominicana:/home# ./call.sh  100 103


Donde 100  y  103 son las extensiones donde queremos llamar.

sábado, 4 de octubre de 2014

Crear Alerta Popup en nuestra pantalla al recibir una llamada entrante Asterisk/Freepbx/Elastix



Buscar en el archivo /etc/asterisk/extensions_additional.conf  y  cargar el siguiente codigo ejemplo.

exten => s,1,System(mysql --user=root --password='123456' asteriskcdrdb -e 'INSERT INTO `pop`(`ID`, `NUMBER`, `FECHA`) VALUES
(NULL,'${CALLERID(num)}',NOW())')

Nota este archivo puede ser sobre escrito por la  la GUI

domingo, 21 de septiembre de 2014

Usando el Cisco/Linksys SPA-504G con Asterisk y Freepbx

Using a Cisco/Linksys SPA-504G with Asterisk and FreePBX

 

Below is a quick start guide for getting a Cisco/Linksys SIP handset up and running with Asterisk/FreePBX.
Both Linksys & Cisco phones have almost identical web admin setup pages but the layout and design differ slightly, setup procedures are identical for both.
Login
Firstly plug the phone into the network via cat5 network cable (If you have 2 switch ports beneath the phone you want to use the port marked “SW”, don’t bother routing through the PC…it wont work well) and connect the power supply and plug in.
The phones get configured via a web interface, to do this you must first know the IP address of the phone. Shown below.
cisco spa504g config button
  •  Then Press “9” for network options
  • See where it says “Current IP” and type it into your web browser

Mejorando la segurirad en tu Freepbx y reseteando la clave de admin

 

5. Securing your PBX

Securing FreePBX
Work In Progress.  Outline:
Passwords (Generally):  Use Long passwords (30+ characters) for the root password, the FreePBX web interface, all trunks, and all extensions.
Change FreePBX Web Password:  In Admin -> Administrators, create a new user with a name other than "admin" with full privileges.  Delete "admin" user.  This will protect you against robots that are scanning port 80 for FreePBX installations and hacking the "admin" user.

miércoles, 17 de septiembre de 2014

A2Billing v2 Install Guide

The following 2 diagrams illustrate A2billing inbound and outbound call flow.


All commands are assuming you are at run level 3 running in a shell as root.  In other words, not in a Gnome/KDE GUI and not using a limited access account.

domingo, 14 de septiembre de 2014

Instalacion de Asterisk 11 & Freepbx v 2.11 en CENTOS 6.5 64 bit


Instalacion de  Asterisk + Freepbx

Actualizamos el Sistema

yum -y update
yum groupinstall core
yum groupinstall base

Desactivamos el Selinux
setenforce 0

Reiniciamos

reboot

domingo, 31 de agosto de 2014

Instalando y configurando el CDR ODBC en Asterisk


Installing and Configuring ODBC

The ODBC connector is a database abstraction layer that makes it possible for Asterisk to communicate with a wide range of databases without requiring the developers to create a separate database connector for every database Asterisk wants to support. This saves a lot of development effort and code maintenance. There is a slight performance cost, because we are adding another application layer between Asterisk and the database, but this can be mitigated with proper design and is well worth it when you need powerful, flexible database capabilities in your Asterisk system.
Before you install the connector in Asterisk, you have to install ODBC into Linux itself. To install the ODBC drivers, use one of the following commands.
On CentOS:

sábado, 23 de agosto de 2014

CISCO IP Phones 79XX con Asterisk

Recently we had a pack of cisco 7942G phones that we were required to get them up running with Asterisk. The good thing about 79XX series is that they all support SIP besides SCCP. Whereas, the bad thing is that they are by default running on SCCP and you have to upgrade them to SIP first. I spent a great deal of time trying to figure this out, as I were going to use SIP Version 8 and there is no to-the-point documentation (at least not that I could find!)

Here are the steps you need to get this up and running: 

sábado, 16 de agosto de 2014

Desintalando FreePBX

http://wiki.freepbx.org/display/HTGS/Uninstalling+FreePBX

Saltar al final de los metadatos
Ir al inicio de los metadatos

These Steps will completely erase your FreePBX settings. There is NO going back. Please make note of this and make the required backups

sábado, 2 de agosto de 2014

Bash Script para monitoreo de status de una extension o troncal en Asterisk



Estructura del Script

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
A=`asterisk -x " sip show peer 1018" | grep -i status | cut -d' ' -f11 `

if [ "$A" != "OK" ]; then


B=`asterisk -x "originate dahdi/g0/18097145874 extension
923@emergency" `


echo "Servidor no disponible  $(date)" >> /root/lg.log
else

echo "Server up"
fi
# echo $A




sábado, 12 de abril de 2014

SIP Retransmissions

What is the problem with SIP retransmits?

Sometimes you get messages in the console like these:
retrans_pkt: Hanging up call XX77yy  - no reply to our critical packet.
retrans_pkt: Cancelling retransmit of OPTIONs
The SIP protocol is based on requests and replies. Both sides send requests and wait for replies. Some of these requests are important. In a TCP/IP network many things can happen with IP packets. Firewalls, NAT devices, Session Border Controllers and SIP Proxys are in the signalling path and they will affect the call.

jueves, 13 de marzo de 2014

Instalando Asterisk en Raspberry Pi

Asterisk for Raspberry Pi Image


I have installed vanilla Asterisk onto a Raspberry Pi and have created an image for all to use. The Asterisk install is not a bundalled install like raspbx which uses FreePBX. Asterisk is configured with all deafults straight from a new build/compile.

jueves, 9 de enero de 2014

Driver should be 'wctdm' but is actually 'netjet'


Blacklist the evil netjet driver.

 doing something like
echo "blacklist netjet" >> /etc/modprobe.d/dahdi.blacklist.conf
reboot