Instalação do Asterisk 11 no Debian Wheezy
E ai galera, aqui eu vou abordar a instalação do Asterisk 11 no Debian Wheezy.
O que vamos instalar:
- Asterisk: Contém aplicações, funções, canais de comunicação e todas as funcionalidades que formam o Asterisk. É o software propriamente dito
- DAHDI: Digium Asterisk Hardware Device Interface: Contém os drivers para todas as placas de comunicação da Digium, ou seus clones
- LibPRI: Biblioteca responsável pela sinalização ISDN/PRI. Só é necessária a sua instalação caso seja utilizada uma placa de comunicação digital E1/T1 e sinalização ISDN/PRI
OBS:
- O pacote Asterisk-AddOns foi incorporado ao pacote principal do Asterisk
- O pacote LibSS7 foi incorporado ao código do Asterisk em 2010, a partir da versão 1.6.2
- O pacote LibOpenR2 Foi incorporado ao código do Asterisk em 2010, a partir da versão 1.6.2
Prepare o seu sistema com o seguinte script http://wiki.douglasqsantos.com.br/doku.php/confinicialwheezy_en para que não falte nenhum pacote ou configuração.
Agora vamos acessar o diretório que vai armazenar os fontes
cd /usr/src
Agora vamos os fontes necesários
wget -c http://wiki.douglasqsantos.com.br/Downloads/Asterisk/dahdi-linux-complete-current.tar.gz wget -c http://wiki.douglasqsantos.com.br/Downloads/Asterisk/libpri-1.4-current.tar.gz wget -c http://wiki.douglasqsantos.com.br/Downloads/Asterisk/asterisk-11-current.tar.gz
A partir da versão 1.6.1.0 do Asterisk, um script que verifica e/ou instala as dependências necessárias para o seu sistema operacional acompanha o pacote de arquivos do Asterisk. O script está localizado na pasta contrib/scripts.
Vamos então desempacotar o Asterisk
tar -xzvf asterisk-11-current.tar.gz
Agora vamos mandar instalar as suas dependências, se for questionado sobre algo somente pressione ENTER
/usr/src/asterisk-11.6.0/contrib/scripts/install_prereq install
Agora vamos instalar alguns pacotes adicionais para o nosso Asterisk
aptitude install libgmime-2.6-0 libgmime-2.6-dev libsrtp0 libsrtp0-dev libkqueue-dev libkqueue0 libiksemel-dev \ libbison-dev flex linux-headers-$(uname -r) subversion -y
Agora vamos acessar o diretório dos fontes
cd /usr/src
Agora vamos desempacotar o dahdi
tar -xzvf dahdi-linux-complete-current.tar.gz
Agora vamos acessar o diretório para a instalação
cd dahdi-linux-complete*
Agora vamos mandar compilar e instalar ele
make && make install && make config && make clean
Agora vamos acessar o diretório dos fontes
cd /usr/src
Agora vamos desempacotar o libpri
tar -xzvf libpri-1.4-current.tar.gz
Agora vamos acessar o diretório dos fontes
cd libpri-*
Agora vamos mandar compilar e instalar
make && make install && make clean
Agora vamos acessar o diretório fonte do asterisk
cd /usr/src/asterisk-*
Agora vamos chegar os pre-requisitos para a compilação
./configure
Agora vamos mandar compilar e instalar o asterisk e arquivos de configuração e inicialização
make && make install && make config && make install-logrotate && make samples && make clean
Agora vamos inicializar controlador de módulos para as placas Digium
/etc/init.d/dahdi start
Agora vamos inicializar o Asterisk
/etc/init.d/asterisk start
Agora vamos consultar o status do Asterisk
/etc/init.d/asterisk status [ ok ] asterisk is running.
Agora vamos inserir o Asterisk e o Dahdi na inicialização do sistema
insserv -f -v asterisk insserv -f -v dahdi
Command Line
Agora vamos acessar o console do Asterisk
rasterisk -Tvvv [Dec 11 22:21:43] Asterisk 11.6.0, Copyright (C) 1999 - 2013 Digium, Inc. and others. [Dec 11 22:21:43] Created by Mark Spencer <markster@digium.com> [Dec 11 22:21:43] Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. [Dec 11 22:21:43] This is free software, with components licensed under the GNU General Public [Dec 11 22:21:43] License version 2 and other licenses; you are welcome to redistribute it under [Dec 11 22:21:43] certain conditions. Type 'core show license' for details. [Dec 11 22:21:43] ========================================================================= [Dec 11 22:21:43] Connected to Asterisk 11.6.0 currently running on asterisk-centos (pid = 950) asterisk-centos*CLI> asterisk-centos*CLI> quit [Dec 11 22:22:02] Asterisk cleanly ending (0). [Dec 11 22:22:02] Executing last minute cleanups
Agora vamos listar as aplicações disponíveis para serem usadas no plano de discagem do asterisk
rasterisk -rx "core show applications" -= Registered Asterisk Applications =- AddQueueMember: Dynamically adds queue members. ADSIProg: Load Asterisk ADSI Scripts into phone AELSub: Launch subroutine built with AEL AgentLogin: Call agent login. AgentMonitorOutgoing: Record agent's outgoing call. AGI: Executes an AGI compliant application. AlarmReceiver: Provide support for receiving alarm reports from a burglar or fire alarm panel. AMD: Attempt to detect answering machines. Answer: Answer a channel if ringing. Authenticate: Authenticate a user BackGround: Play an audio file while waiting for digits of an extension to go to. BackgroundDetect: Background a file with talk detect. Bridge: Bridge two channels. Busy: Indicate the Busy condition. CallCompletionCancel: Cancel call completion service CallCompletionRequest: Request call completion service for previous call CELGenUserEvent: Generates a CEL User Defined Event. ChangeMonitor: Change monitoring filename of a channel. ChanIsAvail: Check channel availability ChannelRedirect: Redirects given channel to a dialplan target ChanSpy: Listen to a channel, and optionally whisper into it. ClearHash: Clear the keys from a specified hashname. ConfBridge: Conference bridge application. Congestion: Indicate the Congestion condition. ContinueWhile: Restart a While loop. ControlPlayback: Play a file with fast forward and rewind. DAHDIRAS: Executes DAHDI ISDN RAS application. DAHDIScan: Scan DAHDI channels to monitor calls. DAHDISendCallreroutingFacility: Send an ISDN call rerouting/deflection facility message. DAHDISendKeypadFacility: Send digits out of band over a PRI. DateTime: Says a specified time in a custom format. DBdel: Delete a key from the asterisk database. DBdeltree: Delete a family or keytree from the asterisk database. DeadAGI: Executes AGI on a hungup channel. Dial: Attempt to connect to another device or endpoint and bridge the call. Dictate: Virtual Dictation Machine. Directory: Provide directory of voicemail extensions. DISA: Direct Inward System Access. DumpChan: Dump Info About The Calling Channel. EAGI: Executes an EAGI compliant application. Echo: Echo media, DTMF back to the calling party EndWhile: End a while loop. Exec: Executes dialplan application. ExecIf: Executes dialplan application, conditionally. ExecIfTime: Conditional application execution based on the current time. ExitWhile: End a While loop. ExtenSpy: Listen to a channel, and optionally whisper into it. ExternalIVR: Interfaces with an external IVR application. Festival: Say text to the user. Flash: Flashes a DAHDI Trunk. FollowMe: Find-Me/Follow-Me application. ForkCDR: Forks the Call Data Record. GetCPEID: Get ADSI CPE ID. Gosub: Jump to label, saving return address. GosubIf: Conditionally jump to label, saving return address. Goto: Jump to a particular priority, extension, or context. GotoIf: Conditional goto. GotoIfTime: Conditional Goto based on the current time. Hangup: Hang up the calling channel. HangupCauseClear: Clears hangup cause information from the channel that is available through HANGUPCAUSE. IAX2Provision: Provision a calling IAXy with a given template. ICES: Encode and stream using 'ices'. ImportVar: Import a variable from a channel into a new variable. Incomplete: Returns AST_PBX_INCOMPLETE value. JabberJoin: Join a chat room JabberLeave: Leave a chat room JabberSend: Sends an XMPP message to a buddy. JabberSendGroup: Send a Jabber Message to a specified chat room JabberStatus: Retrieve the status of a jabber list member Log: Send arbitrary text to a selected log level. Macro: Macro Implementation. MacroExclusive: Exclusive Macro Implementation. MacroExit: Exit from Macro. MacroIf: Conditional Macro implementation. MailboxExists: Check to see if Voicemail mailbox exists. MessageSend: Send a text message. Milliwatt: Generate a Constant 1004Hz tone at 0dbm (mu-law). MinivmAccMess: Record account specific messages. MinivmDelete: Delete Mini-Voicemail voicemail messages. MinivmGreet: Play Mini-Voicemail prompts. MinivmMWI: Send Message Waiting Notification to subscriber(s) of mailbox. MinivmNotify: Notify voicemail owner about new messages. MinivmRecord: Receive Mini-Voicemail and forward via e-mail. MixMonitor: Record a call and mix the audio during the recording. Use of StopMixMonitor is required to guarantee the audio file is available for processing during dialplan execution. Monitor: Monitor a channel. Morsecode: Plays morse code. MP3Player: Play an MP3 file or M3U playlist file or stream. MSet: Set channel variable(s) or function value(s). MusicOnHold: Play Music On Hold indefinitely. NBScat: Play an NBS local stream. NoCDR: Tell Asterisk to not maintain a CDR for the current call NoOp: Do Nothing (No Operation). ODBC_Commit: Commits a currently open database transaction. ODBC_Rollback: Rollback a currently open database transaction. ODBCFinish: Clear the resultset of a sucessful multirow query. Originate: Originate a call. Page: Page series of phones Park: Park yourself. ParkAndAnnounce: Park and Announce. ParkedCall: Retrieve a parked call. PauseMonitor: Pause monitoring of a channel. PauseQueueMember: Pauses a queue member. Pickup: Directed extension call pickup. PickupChan: Pickup a ringing channel. Playback: Play a file. PlayTones: Play a tone list. PrivacyManager: Require phone number to be entered, if no CallerID sent Proceeding: Indicate proceeding. Progress: Indicate progress. Queue: Queue a call for a call queue. QueueLog: Writes to the queue_log file. RaiseException: Handle an exceptional condition. Read: Read a variable. ReadExten: Read an extension into a variable. ReceiveFAX: Receive a FAX and save as a TIFF/F file. Record: Record to a file. RemoveQueueMember: Dynamically removes queue members. ResetCDR: Resets the Call Data Record. RetryDial: Place a call, retrying on failure allowing an optional exit extension. Return: Return from gosub routine. Ringing: Indicate ringing tone. SayAlpha: Say Alpha. SayDigits: Say Digits. SayNumber: Say Number. SayPhonetic: Say Phonetic. SayUnixTime: Says a specified time in a custom format. SendDTMF: Sends arbitrary DTMF digits SendFAX: Sends a specified TIFF/F file as a FAX. SendImage: Sends an image file. SendText: Send a Text Message. SendURL: Send a URL. Set: Set channel variable or function value. SetAMAFlags: Set the AMA Flags. SetMusicOnHold: Set default Music On Hold class. SIPAddHeader: Add a SIP header to the outbound call. SIPDtmfMode: Change the dtmfmode for a SIP call. SIPRemoveHeader: Remove SIP headers previously added with SIPAddHeader SMS: Communicates with SMS service centres and SMS capable analogue phones. SoftHangup: Hangs up the requested channel. SpeechActivateGrammar: Activate a grammar. SpeechBackground: Play a sound file and wait for speech to be recognized. SpeechCreate: Create a Speech Structure. SpeechDeactivateGrammar: Deactivate a grammar. SpeechDestroy: End speech recognition. SpeechLoadGrammar: Load a grammar. SpeechProcessingSound: Change background processing sound. SpeechStart: Start recognizing voice in the audio stream. SpeechUnloadGrammar: Unload a grammar. StackPop: Remove one address from gosub stack. StartMusicOnHold: Play Music On Hold. StopMixMonitor: Stop recording a call through MixMonitor, and free the recording's file handle. StopMonitor: Stop monitoring a channel. StopMusicOnHold: Stop playing Music On Hold. StopPlayTones: Stop playing a tone list. System: Execute a system command. TestClient: Execute Interface Test Client. TestServer: Execute Interface Test Server. Transfer: Transfer caller to remote extension. TryExec: Executes dialplan application, always returning. TrySystem: Try executing a system command. UnpauseMonitor: Unpause monitoring of a channel. UnpauseQueueMember: Unpauses a queue member. UserEvent: Send an arbitrary event to the manager interface. Verbose: Send arbitrary text to verbose output. VMAuthenticate: Authenticate with Voicemail passwords. VMSayName: Play the name of a voicemail user VoiceMail: Leave a Voicemail message. VoiceMailMain: Check Voicemail messages. VoiceMailPlayMsg: Play a single voice mail msg from a mailbox by msg id. Wait: Waits for some time. WaitExten: Waits for an extension to be entered. WaitForNoise: Waits for a specified amount of noise. WaitForRing: Wait for Ring Application. WaitForSilence: Waits for a specified amount of silence. WaitMusicOnHold: Wait, playing Music On Hold. WaitUntil: Wait (sleep) until the current time is the given epoch. While: Start a while loop. Zapateller: Block telemarketers with SIT. -= 178 Applications Registered =-
Agora vamos mostrar a descrição e a sintaxe de uma aplicação especifica
rasterisk -Tvvv [Dec 11 22:23:04] Asterisk 11.6.0, Copyright (C) 1999 - 2013 Digium, Inc. and others. [Dec 11 22:23:04] Created by Mark Spencer <markster@digium.com> [Dec 11 22:23:04] Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. [Dec 11 22:23:04] This is free software, with components licensed under the GNU General Public [Dec 11 22:23:04] License version 2 and other licenses; you are welcome to redistribute it under [Dec 11 22:23:04] certain conditions. Type 'core show license' for details. [Dec 11 22:23:04] ========================================================================= [Dec 11 22:23:04] Connected to Asterisk 11.6.0 currently running on asterisk-centos (pid = 950) asterisk-centos*CLI> core show application answer -= Info about application 'Answer' =- [Synopsis] Answer a channel if ringing. [Description] If the call has not been answered, this application will answer it. Otherwise, it has no effect on the call. [Syntax] Answer([delay][,nocdr]) [Arguments] delay Asterisk will wait this number of milliseconds before returning to the dialplan after answering the call. nocdr Asterisk will send an answer signal to the calling phone, but will not set the disposition or answer time in the CDR for this call. [See Also] Hangup() asterisk-centos*CLI>
Para mostar a lista de canis de comunicação ativos podemos executar o seguinte comando
asterisk-centos*CLI> core show channels Channel Location State Application(Data) 0 active channels 0 active calls 0 calls processed asterisk-centos*CLI>
Para obter mais informações sobre um canal de comunicação especifico podemos fazer da seguinte forma
asterisk*CLI> core show channel SIP/9003/094f83e1 [...]
Mostrar informações sobre o tempo de transcoficação entre os codecs habilitados no Asterisk podemos fazer da seguinte forma
asterisk*CLI> core show translation Translation times between formats (in microseconds) for one second of data Source Format (Rows) Destination Format (Columns) gsm ulaw alaw g726 adpcm slin lpc10 speex speex16 ilbc g726aal2 g722 slin16 testlaw speex32 slin12 slin24 slin32 slin44 slin48 slin96 slin192 gsm - 15000 15000 15000 15000 9000 15000 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 ulaw 15000 - 9150 15000 15000 9000 15000 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 alaw 15000 9150 - 15000 15000 9000 15000 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 g726 15000 15000 15000 - 15000 9000 15000 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 adpcm 15000 15000 15000 15000 - 9000 15000 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 slin 6000 6000 6000 6000 6000 - 6000 6000 14000 6000 6000 8250 8000 6000 14000 8000 8000 8000 8000 8000 8000 8000 lpc10 15000 15000 15000 15000 15000 9000 - 15000 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 speex 15000 15000 15000 15000 15000 9000 15000 - 23000 15000 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 speex16 23500 23500 23500 23500 23500 17500 23500 23500 - 23500 23500 15000 9000 23500 23000 17500 17000 17000 17000 17000 17000 17000 ilbc 15000 15000 15000 15000 15000 9000 15000 15000 23000 - 15000 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 g726aal2 15000 15000 15000 15000 15000 9000 15000 15000 23000 15000 - 17250 17000 15000 23000 17000 17000 17000 17000 17000 17000 17000 g722 15600 15600 15600 15600 15600 9600 15600 15600 15000 15600 15600 - 9000 15600 23000 17500 17000 17000 17000 17000 17000 17000 slin16 14500 14500 14500 14500 14500 8500 14500 14500 6000 14500 14500 6000 - 14500 14000 8500 8000 8000 8000 8000 8000 8000 testlaw 15000 15000 15000 15000 15000 9000 15000 15000 23000 15000 15000 17250 17000 - 23000 17000 17000 17000 17000 17000 17000 17000 speex32 23500 23500 23500 23500 23500 17500 23500 23500 23500 23500 23500 23500 17500 23500 - 17500 17500 9000 17000 17000 17000 17000 slin12 14500 14500 14500 14500 14500 8500 14500 14500 14000 14500 14500 14000 8000 14500 14000 - 8000 8000 8000 8000 8000 8000 slin24 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 14000 8500 - 8000 8000 8000 8000 8000 slin32 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 6000 8500 8500 - 8000 8000 8000 8000 slin44 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 14500 8500 8500 8500 - 8000 8000 8000 slin48 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 14500 8500 8500 8500 8500 - 8000 8000 slin96 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 14500 8500 8500 8500 8500 8500 - 8000 slin192 14500 14500 14500 14500 14500 8500 14500 14500 14500 14500 14500 14500 8500 14500 14500 8500 8500 8500 8500 8500 8500 - asterisk*CLI>
Para parar o asterisk podemos fazer da seguinte forma
asterisk-centos*CLI> core stop now asterisk-centos*CLI> Disconnected from Asterisk server [Dec 11 22:24:07] Asterisk cleanly ending (0). [Dec 11 22:24:07] Executing last minute cleanups
Podemos utilizar o restart da seguinte forma
asterisk*CLI> core restart now asterisk*CLI> Disconnected from Asterisk server [Dec 11 22:25:37] Asterisk cleanly ending (0). [Dec 11 22:25:37] Executing last minute cleanups
Podemos utilizar tambem ao invés de now no comando restart utilizarmos o gracefully que vai reiniciar o parar o asterisk depois de todas as chamadas terem sido encerradas e não permite o início de nenhuma nova chamada
asterisk*CLI> core restart gracefully
Asterisk-GUI
Vamos acessar o diretório que vai armazenar os fontes
cd /usr/src
Agora vamos obter os fontes
svn checkout http://svn.asterisk.org/svn/asterisk-gui/branches/2.0/ asterisk-gui
Agora vamos acessar o diretório dos fontes
cd /usr/src/asterisk-gui
Agora vamos checar os pre-requisitos do sistema
./configure
Agora vamos mandar compilar e instalar ele
make && make install
Agora vamos ajustar o acesso a interface web
vim /etc/asterisk/http.conf [...] [general] [...] enabled=yes [...] bindaddr=0.0.0.0 [...] bindport=8088 [...] prefix=asterisk [...] enablestatic=yes
Agora vamos ajutar o usuário administrador da interface web
vim /etc/asterisk/manager.conf [...] [general] enabled = yes webenabled = yes port = 5038 bindaddr = 0.0.0.0 [...] [admin] secret = admin read = system,call,log,verbose,command,agent,config,read,write,originate write = system,call,log,verbose,command,agent,config,read,write,originate
Agora vamos reiniciar o Asterisk
/etc/init.d/asterisk restart
Agora vamos mandar checar a configuração
cd /usr/src/asterisk-gui && make checkconfig --- Checking Asterisk configuration to see if it will support the GUI --- * Checking for http.conf: OK * Checking for manager.conf: OK * Checking if HTTP is enabled: OK * Checking if HTTP static support is enabled: OK * Checking if manager is enabled: OK * Checking if manager over HTTP is enabled: OK --- Everything looks good --- * GUI should be available at http://asterisk:8088/asterisk/static/config/index.html * Note: If you have bindaddr=127.0.0.1 in /etc/asterisk/http.conf you will only be able to visit it from the local machine. Example: http://localhost:8088/asterisk/static/config/index.html * The login and password should be an entry from /etc/asterisk/manager.conf which has 'config' permission in read and write. For example: [admin] secret = mysecret49323 read = system,call,log,verbose,command,agent,config write = system,call,log,verbose,command,agent,config --- Good luck! ---
Agora vamos acessar a interface http://ip_servidor:8088/asterisk/static/config/index.html aqui logue com o usuário admin e a senha admin, aqui vamos ser questionados sobre algumas configurações somente confirme elas.
Depois de logar vamos ter algo como abaixo:
Configuração básica de ramais e plano de discagem
Vamos configurar 2 ramais SIP e 2 IAX2 para testes.
OBS: Os comentários nestes arquivos são o ;
Vamos fazer um backup do arquivo sip.conf e do iax.conf e já vamos fazer do extensions.conf aonde vamos criar o nosso plano de discagem.
cp -Rfa /etc/asterisk/sip.conf{,.bkp} cp -Rfa /etc/asterisk/iax.conf{,.bkp} cp -Rfa /etc/asterisk/extensions.conf{,.bkp}
Agora vamos zerar estes arquivos
> /etc/asterisk/sip.conf > /etc/asterisk/iax.conf > /etc/asterisk/extensions.conf
Vamos configurar os nossos ramais SIP
vim /etc/asterisk/sip.conf [general] ;#Aonde o sip vai trabalhar ou seja qualquer interface do servidor udpbindaddr = 0.0.0.0 ;#Porta default do sip bindport = 5060 ;#Idioma que vamos utilizar por padrão language = en ;#Desabilitando todos os codecs disallow = all ;#Configurando os tamplates para os nossos ramais definimos um template utilizando o (!) [opcoes-basicas](!) ;#Definindo o canal de comunicacao configurado. host = dynamic ;#Especifica como que o asterisk vai pesquisar pelo cliente type = friend ;#Contexto que vamos utilizar(plano de discagem) context = ramais ;#Template para o uso dos codecs alaw e ilbc [codecs](!) ;#Desabilitando todos os codecs disallow = all ;#Habilitando os codecs alaw e ilbc não pode haver espaço depois da virgula allow = alaw,ilbc ;#Template para a utilização somente do codec alaw herdando as configurações do template opcoes-basicas [somente-alaw](!,opcoes-basicas) ;#Desabilita todos os codecs disallow = all ;#Habilita o protocolo alaw allow = alaw ;#Configuração do ramal 9001 herdando as configurações dos templates opcoes-basicas e codecs [9001](opcoes-basicas,codecs) ;#Definição de senha para o nosso ramal 9001 secret = senha01 ;#Identificação deste ramal em uma ligação callerid = Secretaria <9001> ;#Configuração do ramal 9002 herdando a configuração do template somente-alaw [9002](somente-alaw) ;#Definição de senha para o nosso ramal 9002 secret = senha02 ;#Identificação deste ramal em uma ligação callerid = Diretoria <9002>
Agora vamos configurar os ramais IAX2
vim /etc/asterisk/iax.conf [general] ;#Idioma que vamos utilizar por padrão language = en ;#Desabilitando todos os codecs disallow = all ;#Configurando os tamplates para os nossos ramais definimos um template utilizando o (!) [opcoes-basicas](!) ;#Definindo o canal de comunicacao configurado. host = dynamic ;#Aqui vamos definir se o cliente IAX pode efetuar chamadar ser peer ou pode receber user ou ambos friend type = friend ;#Contexto que vamos utilizar(plano de discagem) context = ramais ;#Template para o uso dos codecs [codecs](!) ;#Desabilitando todos os codecs disallow = all ;#Habilitando os codecs alaw e ilbc não pode haver espaço depois da virgula allow = alaw,ilbc ;#Template para a utilização somente do codec alaw herdando as configurações do template opcoes-basicas [somente-alaw](!,opcoes-basicas) ;#Desabilita todos os codecs disallow = all ;#Habilita o protocolo alaw allow = alaw ;#Configuração do ramal 9003 herdando as configurações dos templates opcoes-basicas e codecs [9003](opcoes-basicas,codecs) ;#Definição de senha para o nosso ramal 9003 secret = senha03 ;#Identificação deste ramal em uma ligação callerid = Director <9003> ;#Configuração do ramal 9004 herdando a configuração do template somente-alaw [9004](somente-alaw) ;#Definição de senha para o nosso ramal 9004 secret = senha04 ;#Identificação deste ramal em uma ligação callerid = Secretary <9004>
Agora no Asterisk vamos mandar ler as nossas novas configurações de SIP e do IAX
rasterisk -Tvvv [Dec 15 11:21:07] Asterisk 11.6.0, Copyright (C) 1999 - 2013 Digium, Inc. and others. [Dec 15 11:21:07] Created by Mark Spencer <markster@digium.com> [Dec 15 11:21:07] Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. [Dec 15 11:21:07] This is free software, with components licensed under the GNU General Public [Dec 15 11:21:07] License version 2 and other licenses; you are welcome to redistribute it under [Dec 15 11:21:07] certain conditions. Type 'core show license' for details. [Dec 15 11:21:07] ========================================================================= [Dec 15 11:21:07] Connected to Asterisk 11.6.0 currently running on asterisk (pid = 41650) asterisk*CLI> sip reload Reloading SIP == Parsing '/etc/asterisk/sip.conf': Found == Parsing '/etc/asterisk/users.conf': Found == Using SIP CoS mark 4 == Parsing '/etc/asterisk/sip_notify.conf': Found asterisk*CLI> iax2 reload == Parsing '/etc/asterisk/iax.conf': Found == Parsing '/etc/asterisk/users.conf': Found asterisk*CLI>
Agora vamos mandar listar os nossos ramais SIP
asterisk*CLI> sip show peers Name/username Host Dyn Forcerport ACL Port Status Description 9001 (Unspecified) D a 0 Unmonitored 9002 (Unspecified) D a 0 Unmonitored 2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 2 offline]
Agora vamos mandar listar os nossos ramais IAX2
asterisk*CLI> iax2 show peers Name/Username Host Mask Port Status Description 9004 (null) (D) 255.255.255.255 0 Unmonitored 9003 (null) (D) 255.255.255.255 0 Unmonitored 2 iax2 peers [0 online, 0 offline, 2 unmonitored] asterisk*CLI>
Se precisarmos obter mais informações de um determinado peer podemos fazer da seguinte forma se for SIP
asterisk*CLI> sip show peer 9001 * Name : 9001 Description : Secret : <Set> MD5Secret : <Not set> Remote Secret: <Not set> Context : ramais Record On feature : automon Record Off feature : automon Subscr.Cont. : <Not set> Language : en Tonezone : <Not set> AMA flags : Unknown Transfer mode: open CallingPres : Presentation Allowed, Not Screened Callgroup : Pickupgroup : Named Callgr : Nam. Pickupgr: MOH Suggest : Mailbox : VM Extension : asterisk LastMsgsSent : 0/0 Call limit : 0 Max forwards : 0 Dynamic : Yes Callerid : "Secretaria" <9001> MaxCallBR : 384 kbps Expire : -1 Insecure : no Force rport : Auto (No) Symmetric RTP: No ACL : No DirectMedACL : No T.38 support : No T.38 EC mode : Unknown T.38 MaxDtgrm: -1 DirectMedia : Yes PromiscRedir : No User=Phone : No Video Support: No Text Support : No Ign SDP ver : No Trust RPID : No Send RPID : No Subscriptions: Yes Overlap dial : Yes DTMFmode : rfc2833 Timer T1 : 500 Timer B : 32000 ToHost : Addr->IP : (null) Defaddr->IP : (null) Prim.Transp. : UDP Allowed.Trsp : UDP Def. Username: SIP Options : (none) Codecs : (alaw|ilbc) Codec Order : (alaw:20,ilbc:30) Auto-Framing : No Status : Unmonitored Useragent : Reg. Contact : Qualify Freq : 60000 ms Keepalive : 0 ms Sess-Timers : Accept Sess-Refresh : uas Sess-Expires : 1800 secs Min-Sess : 90 secs RTP Engine : asterisk Parkinglot : Use Reason : No Encryption : No asterisk*CLI>
Se precisarmos obter mais informações de um determinado peer podemos fazer da seguinte forma se for IAX2
asterisk*CLI> iax2 show peer 9004 * Name : 9004 Description : Secret : <Set> Context : ramais Parking lot : Mailbox : Dynamic : Yes Callnum limit: 0 Calltoken req: No Trunk : No Encryption : No Callerid : "Secretary" <9004> Expire : -1 ACL : No Addr->IP : (Unspecified) Port 0 Defaddr->IP : 0.0.0.0 Port 4569 Username : Codecs : (alaw) Codec Order : (alaw) Status : Unmonitored Qualify : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off) asterisk*CLI>
Agora vamos configurar o nosso plano de discagem
vim /etc/asterisk/extensions.conf [general] ;#Para o Asterisk não terminar a ligação automáticamente autofallthrough=no ;#Contexto ramais é o que referenciamos na configuração do sip.conf e do iax.conf [ramais] ;#Ramais SIP ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9001 e 9001 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9001 e 9002 a efetuar e receber chamadas utilizando o protocolo SIP com uma espera de no máximo 30 segundos exten => 9001,1,Dial(SIP/9001,30) exten => 9002,1,Dial(SIP/9002,30) ;#Ramais IAX2 ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9003 e 9004 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9003 e 9004 a efetuar e receber chamadas utilizando o protocolo IAX2 com uma espera de no máximo 30 segundos exten => 9003,1,Dial(IAX2/9003,30) exten => 9004,1,Dial(IAX2/9004,30)
Agora vamos recarregar o nosso plano de discagem no asterisk
asterisk*CLI> dialplan reload Dialplan reloaded. == Parsing '/etc/asterisk/extensions.conf': Found -- Registered extension context 'ramais'; registrar: pbx_config -- Added extension '9001' priority 1 to ramais -- Added extension '9002' priority 1 to ramais -- Added extension '9003' priority 1 to ramais -- Added extension '9004' priority 1 to ramais == Parsing '/etc/asterisk/users.conf': Found -- Registered extension context 'demo'; registrar: pbx_lua -- merging incls/swits/igpats from old(demo) to new(demo) context, registrar = pbx_config -- Including switch 'Lua/' in context 'demo' -- Added extension '1001' priority -1 to demo -- Added extension '1000' priority -1 to demo -- Registered extension context 'default'; registrar: pbx_lua -- merging incls/swits/igpats from old(default) to new(default) context, registrar = pbx_config -- Including switch 'Lua/' in context 'default' -- Added extension '1234' priority -1 to default -- Registered extension context 'parkedcalls'; registrar: features -- merging incls/swits/igpats from old(parkedcalls) to new(parkedcalls) context, registrar = pbx_config -- Added extension '700' priority 1 to parkedcalls -- Registered extension context 'ael-builtin-h-bubble'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-builtin-h-bubble) to new(ael-builtin-h-bubble) context, registrar = pbx_config -- Added extension 'h' priority 9996 to ael-builtin-h-bubble -- Added extension 'h' priority 9995 to ael-builtin-h-bubble -- Added extension 'h' priority 9994 to ael-builtin-h-bubble -- Added extension 'h' priority 9993 to ael-builtin-h-bubble -- Added extension 'h' priority 9992 to ael-builtin-h-bubble -- Added extension 'h' priority 9991 to ael-builtin-h-bubble -- Added extension 'h' priority 1 to ael-builtin-h-bubble -- Registered extension context 'ael-default'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-default) to new(ael-default) context, registrar = pbx_config -- Including context 'ael-demo' in context 'ael-default' -- Registered extension context 'ael-demo'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-demo) to new(ael-demo) context, registrar = pbx_config -- Added extension 'i' priority 1 to ael-demo -- Added extension 't' priority 1 to ael-demo -- Added extension '#' priority 2 to ael-demo -- Added extension '#' priority 1 to ael-demo -- Added extension '8500' priority 2 to ael-demo -- Added extension '8500' priority 1 to ael-demo -- Added extension '_1234' priority 1 to ael-demo -- Added extension '600' priority 4 to ael-demo -- Added extension '600' priority 3 to ael-demo -- Added extension '600' priority 2 to ael-demo -- Added extension '600' priority 1 to ael-demo -- Added extension '500' priority 4 to ael-demo -- Added extension '500' priority 3 to ael-demo -- Added extension '500' priority 2 to ael-demo -- Added extension '500' priority 1 to ael-demo -- Added extension '1000' priority 1 to ael-demo -- Added extension '3' priority 2 to ael-demo -- Added extension '3' priority 1 to ael-demo -- Added extension '2' priority 2 to ael-demo -- Added extension '2' priority 1 to ael-demo -- Added extension 's' priority 12 to ael-demo -- Added extension 's' priority 11 to ael-demo -- Added extension 's' priority 10 to ael-demo -- Added extension 's' priority 9 to ael-demo -- Added extension 's' priority 8 to ael-demo -- Added extension 's' priority 7 to ael-demo -- Added extension 's' priority 6 to ael-demo -- Added extension 's' priority 5 to ael-demo -- Added extension 's' priority 4 to ael-demo -- Added extension 's' priority 3 to ael-demo -- Added extension 's' priority 2 to ael-demo -- Added extension 's' priority 1 to ael-demo -- Registered extension context 'ael-std-exten-ael'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-std-exten-ael) to new(ael-std-exten-ael) context, registrar = pbx_config -- Including context 'ael-builtin-h-bubble' in context 'ael-std-exten-ael' -- Added extension 'sw_1_BUSY' priority 11 to ael-std-exten-ael -- Added extension 'sw_1_BUSY' priority 10 to ael-std-exten-ael -- Added extension 'sw_1_' priority 10 to ael-std-exten-ael -- Added extension '_sw_1_.' priority 11 to ael-std-exten-ael -- Added extension '_sw_1_.' priority 10 to ael-std-exten-ael -- Added extension 'a' priority 2 to ael-std-exten-ael -- Added extension 'a' priority 1 to ael-std-exten-ael -- Added extension '~~s~~' priority 8 to ael-std-exten-ael -- Added extension '~~s~~' priority 7 to ael-std-exten-ael -- Added extension '~~s~~' priority 6 to ael-std-exten-ael -- Added extension '~~s~~' priority 5 to ael-std-exten-ael -- Added extension '~~s~~' priority 4 to ael-std-exten-ael -- Added extension '~~s~~' priority 3 to ael-std-exten-ael -- Added extension '~~s~~' priority 2 to ael-std-exten-ael -- Added extension '~~s~~' priority 1 to ael-std-exten-ael -- Registered extension context 'ael-local'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-local) to new(ael-local) context, registrar = pbx_config -- Including context 'ael-default' in context 'ael-local' -- Including context 'ael-trunklocal' in context 'ael-local' -- Including context 'ael-iaxtel700' in context 'ael-local' -- Including context 'ael-trunktollfree' in context 'ael-local' -- Including context 'ael-iaxprovider' in context 'ael-local' -- Registered extension context 'ael-longdistance'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-longdistance) to new(ael-longdistance) context, registrar = pbx_config -- Including context 'ael-local' in context 'ael-longdistance' -- Including context 'ael-trunkld' in context 'ael-longdistance' -- Registered extension context 'ael-international'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-international) to new(ael-international) context, registrar = pbx_config -- Including context 'ael-longdistance' in context 'ael-international' -- Including context 'ael-trunkint' in context 'ael-international' -- Registered extension context 'ael-trunktollfree'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-trunktollfree) to new(ael-trunktollfree) context, registrar = pbx_config -- Added extension '_91866NXXXXXX' priority 1 to ael-trunktollfree -- Added extension '_91877NXXXXXX' priority 1 to ael-trunktollfree -- Added extension '_91888NXXXXXX' priority 1 to ael-trunktollfree -- Added extension '_91800NXXXXXX' priority 1 to ael-trunktollfree -- Registered extension context 'ael-trunklocal'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-trunklocal) to new(ael-trunklocal) context, registrar = pbx_config -- Added extension '_9NXXXXXX' priority 1 to ael-trunklocal -- Registered extension context 'ael-trunkld'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-trunkld) to new(ael-trunkld) context, registrar = pbx_config -- Including context 'ael-dundi-e164-lookup' in context 'ael-trunkld' -- Added extension '_91NXXNXXXXXX' priority 2 to ael-trunkld -- Added extension '_91NXXNXXXXXX' priority 1 to ael-trunkld -- Registered extension context 'ael-trunkint'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-trunkint) to new(ael-trunkint) context, registrar = pbx_config -- Including context 'ael-dundi-e164-lookup' in context 'ael-trunkint' -- Added extension '_9011.' priority 2 to ael-trunkint -- Added extension '_9011.' priority 1 to ael-trunkint -- Registered extension context 'ael-iaxprovider'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-iaxprovider) to new(ael-iaxprovider) context, registrar = pbx_config -- Registered extension context 'ael-iaxtel700'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-iaxtel700) to new(ael-iaxtel700) context, registrar = pbx_config -- Added extension '_91700XXXXXXX' priority 1 to ael-iaxtel700 -- Registered extension context 'ael-dundi-e164'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164) to new(ael-dundi-e164) context, registrar = pbx_config -- Including context 'ael-builtin-h-bubble' in context 'ael-dundi-e164' -- Added extension '~~s~~' priority 3 to ael-dundi-e164 -- Added extension '~~s~~' priority 2 to ael-dundi-e164 -- Added extension '~~s~~' priority 1 to ael-dundi-e164 -- Registered extension context 'ael-dundi-e164-lookup'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-lookup) to new(ael-dundi-e164-lookup) context, registrar = pbx_config -- Including context 'ael-dundi-e164-local' in context 'ael-dundi-e164-lookup' -- Including context 'ael-dundi-e164-switch' in context 'ael-dundi-e164-lookup' -- Registered extension context 'ael-dundi-e164-switch'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-switch) to new(ael-dundi-e164-switch) context, registrar = pbx_config -- Including switch 'DUNDi/e164' in context 'ael-dundi-e164-switch' -- Registered extension context 'ael-dundi-e164-local'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-local) to new(ael-dundi-e164-local) context, registrar = pbx_config -- Including context 'ael-dundi-e164-canonical' in context 'ael-dundi-e164-local' -- Including context 'ael-dundi-e164-customers' in context 'ael-dundi-e164-local' -- Including context 'ael-dundi-e164-via-pstn' in context 'ael-dundi-e164-local' -- Registered extension context 'ael-dundi-e164-via-pstn'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-via-pstn) to new(ael-dundi-e164-via-pstn) context, registrar = pbx_config -- Registered extension context 'ael-dundi-e164-customers'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-customers) to new(ael-dundi-e164-customers) context, registrar = pbx_config -- Registered extension context 'ael-dundi-e164-canonical'; registrar: pbx_ael -- merging incls/swits/igpats from old(ael-dundi-e164-canonical) to new(ael-dundi-e164-canonical) context, registrar = pbx_config -- Time to scan old dialplan and merge leftovers back into the new: 0.003173 sec -- Time to restore hints and swap in new dialplan: 0.000007 sec -- Time to delete the old dialplan: 0.000400 sec -- Total time merge_contexts_delete: 0.003580 sec asterisk*CLI>
Agora vamos listar o que temos em nosso contexto ramais
asterisk*CLI> dialplan show ramais [ Context 'ramais' created by 'pbx_config' ] '9001' => 1. Dial(SIP/9001,30) [pbx_config] '9002' => 1. Dial(SIP/9002,30) [pbx_config] '9003' => 1. Dial(IAX2/9003,30) [pbx_config] '9004' => 1. Dial(IAX2/9004,30) [pbx_config] -= 4 extensions (4 priorities) in 1 context. =- asterisk*CLI>
Agora precisamos somente configurar os ATAs ou softphones para efetuarmos os testes.
Eu vou abordar a configuração do softphone SFLphone que pode ser obtido em http://sflphone.org/
Inicie o softphone:
- Vai ser iniciado um Wizard para a configuração selecione Continue
- Agora precisamos selecionar o nosso tipo de conta vamos selecionar Register an existing SIP or IAX2 account e selecione Continue
- Agora vamos selecionar o tipo de protocolo vamos selecionar SIP (Session Initiation Protocol) e selecione Continue
- Agora vamos preencher a nossa conta:
- Em alias informe: Secretaria
- Em host name informe: ip_do_voip
- Em User name informe: 9001
- Em Password informe: senha01
- Agora selecione Continue
- Agora selecione Apply
- E por fim selecione Close
No console do Asterisk vamos receber uma informação como abaixo
-- Registered SIP '9001' at 192.168.1.2:5060
Agora vamos listar os ramais logados
asterisk*CLI> sip show peers Name/username Host Dyn Forcerport ACL Port Status Description 9001/9001 192.168.1.2 D a 5060 Unmonitored 9002 (Unspecified) D a 0 Unmonitored 2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 1 offline] asterisk*CLI>
Agora vamos obter mais informações do nosso ramal
asterisk*CLI> sip show peer 9001 * Name : 9001 Description : Secret : <Set> MD5Secret : <Not set> Remote Secret: <Not set> Context : ramais Record On feature : automon Record Off feature : automon Subscr.Cont. : <Not set> Language : en Tonezone : <Not set> AMA flags : Unknown Transfer mode: open CallingPres : Presentation Allowed, Not Screened Callgroup : Pickupgroup : Named Callgr : Nam. Pickupgr: MOH Suggest : Mailbox : VM Extension : asterisk LastMsgsSent : 0/0 Call limit : 0 Max forwards : 0 Dynamic : Yes Callerid : "Secretaria" <9001> MaxCallBR : 384 kbps Expire : 64 Insecure : no Force rport : Auto (No) Symmetric RTP: No ACL : No DirectMedACL : No T.38 support : No T.38 EC mode : Unknown T.38 MaxDtgrm: -1 DirectMedia : Yes PromiscRedir : No User=Phone : No Video Support: No Text Support : No Ign SDP ver : No Trust RPID : No Send RPID : No Subscriptions: Yes Overlap dial : Yes DTMFmode : rfc2833 Timer T1 : 500 Timer B : 32000 ToHost : Addr->IP : 192.168.1.2:5060 Defaddr->IP : (null) Prim.Transp. : UDP Allowed.Trsp : UDP Def. Username: 9001 SIP Options : (none) Codecs : (alaw|ilbc) Codec Order : (alaw:20,ilbc:30) Auto-Framing : No Status : Unmonitored Useragent : SFLphone Reg. Contact : sip:9001@192.168.1.2:5060 Qualify Freq : 60000 ms Keepalive : 0 ms Sess-Timers : Accept Sess-Refresh : uas Sess-Expires : 1800 secs Min-Sess : 90 secs RTP Engine : asterisk Parkinglot : Use Reason : No Encryption : No asterisk*CLI>
Eu configurei outro softphone com o IAX a configuração é a mesma bastando somente selecionar o protocolo IAX
Agora vamos listar os ramais IAX
asterisk*CLI> iax2 show peers Name/Username Host Mask Port Status Description 9004 192.168.1.8 (D) 255.255.255.255 4569 Unmonitored 9003 (null) (D) 255.255.255.255 0 Unmonitored 2 iax2 peers [0 online, 0 offline, 2 unmonitored]
Agora vamos obter informações do nosso ramal 9004
asterisk*CLI> iax2 show peer 9004 * Name : 9004 Description : Secret : <Set> Context : ramais Parking lot : Mailbox : Dynamic : Yes Callnum limit: 0 Calltoken req: No Trunk : No Encryption : No Callerid : "Secretary" <9004> Expire : -1 ACL : No Addr->IP : (Unspecified) Port 0 Defaddr->IP : 0.0.0.0 Port 4569 Username : Codecs : (alaw) Codec Order : (alaw) Status : Unmonitored Qualify : every 60000ms when OK, every 10000ms when UNREACHABLE (sample smoothing Off) asterisk*CLI
Agora configure mais um cliente e teste a ligação entre os ramais, ligue do ramal IAX2 para o SIP
No console do Asterisk vamos ter algo como abaixo
-- Accepting AUTHENTICATED call from 192.168.1.8: -- > requested format = speex, -- > requested prefs = (), -- > actual format = alaw, -- > host prefs = (alaw), -- > priority = mine -- Executing [9001@ramais:1] Dial("IAX2/9004-8500", "SIP/9001,30") in new stack == Using SIP RTP CoS mark 5 -- Called SIP/9001 -- SIP/9001-00000001 is ringing -- SIP/9001-00000001 answered IAX2/9004-8500 == Spawn extension (ramais, 9001, 1) exited non-zero on 'IAX2/9004-8500' -- Hungup 'IAX2/9004-8500'
Agora ligue do SIP para o IAX2
== Using SIP RTP CoS mark 5 -- Executing [9004@ramais:1] Dial("SIP/9001-00000002", "IAX2/9004,30") in new stack -- Called IAX2/9004 -- Call accepted by 192.168.1.8 (format alaw) -- Format for call is (alaw) -- IAX2/9004-1535 is ringing -- IAX2/9004-1535 answered SIP/9001-00000002 -- Hungup 'IAX2/9004-1535' == Spawn extension (ramais, 9004, 1) exited non-zero on 'SIP/9001-00000002'
Note que o output dos duas ligações são diferentes.
Configuração Básica de URA
Vamos criar alguns ramais para gravarmos as mensagens da URA.
vim /etc/asterisk/extensions.conf [general] ;#Para o Asterisk não terminar a ligação automáticamente autofallthrough=no ;#Contexto ramais é o que referenciamos na configuração do sip.conf e do iax.conf [ramais] ;#Ramais SIP ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9001 e 9001 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9001 e 9002 a efetuar e receber chamadas utilizando o protocolo SIP com uma espera de no máximo 30 segundos exten => 9001,1,Dial(SIP/9001,30) exten => 9002,1,Dial(SIP/9002,30) ;#Ramais IAX2 ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9003 e 9004 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9003 e 9004 a efetuar e receber chamadas utilizando o protocolo IAX2 com uma espera de no máximo 30 segundos exten => 9003,1,Dial(IAX2/9003,30) exten => 9004,1,Dial(IAX2/9004,30) ;#RAMAIS PARA GRAVAÇÃO DE AUDIO PARA URA ;#Recebe a ligação exten => 2001,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo boasvindas.gsm same => n,Record(boasvindas.gsm) ;#Reproduz o audio boasvindas que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(boasvindas) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2002,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo saldo.ulaw same => n,Record(saldo.ulaw) ;#Reproduz o audio saldo que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(saldo) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2003,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo atendimento.alaw same => n,Record(atendimento.alaw) ;#Reproduz o audio atendimento que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(atendimento) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2004,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo telefonista.gsm same => n,Record(telefonista.gsm) ;#Reproduz o audio telefonista que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(telefonista) ;#Finaliza a ligação same => n,Hangup
Agora vamos carregar a nossa nova configuração do Asterisk
asterisk*CLI> dialplan reload Dialplan reloaded. == Parsing '/etc/asterisk/extensions.conf': Found -- Registered extension context 'ramais'; registrar: pbx_config [...] -- Time to scan old dialplan and merge leftovers back into the new: 0.005485 sec -- Time to restore hints and swap in new dialplan: 0.000008 sec -- Time to delete the old dialplan: 0.000144 sec -- Total time merge_contexts_delete: 0.005637 sec
Agora o que precisamos é ligar para os ramais e gravar os nossos audios.
Ex:
- Ligue para o ramal 2001, ao ouvir o beep, pronuncie “Bem-vindo a Minha Empresa S/A, tecle 1 para SALDO, 3 para ATENDENTES ou 11 para falar com a TELEFONISTA” e pressione # para encerrar a gravação
- Liguei para o 2002 e ao ouvir o beep, pronuncie “SALDO” e pressione # para encerrar a ligação
- Ligue para o 2003 e ao ouvir o beep, pronuncie “ATENDIMENTO” e pressione # para encerrar a ligação
- Ligue para o 2004 e ao ouvir o beep, pronuncie “TELEFONISTA” e pressione # para encerrar a ligação.
Agora que já temos os audios vamos ajustar a localização deles acesse
cd /var/lib/asterisk/sounds
Agora vamos criar um diretório chamado ura
mkdir ura
Agora vamos mover todos os audios para o nosso diretório ura
mv atendimento.alaw boasvindas.gsm saldo.ulaw telefonista.gsm ura
Agora vamos configurar a nossa URA
vim /etc/asterisk/extensions.conf [general] ;#Para o Asterisk não terminar a ligação automáticamente autofallthrough=no ;#Contexto ramais é o que referenciamos na configuração do sip.conf e do iax.conf [ramais] ;#Ramais SIP ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9001 e 9001 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9001 e 9002 a efetuar e receber chamadas utilizando o protocolo SIP com uma espera de no máximo 30 segundos exten => 9001,1,Dial(SIP/9001,30) exten => 9002,1,Dial(SIP/9002,30) ;Ramais IAX2 ;#Aqui funciona EXTENÇÃO,PRIORIDADE,APLICAÇÃO(OPÇÕES DA APLICAÇÃO) ;#Aqui temos os ramais 9003 e 9004 com prioridade 1, utilizando a aplicação DIAL: Conecta dois canais de comunicação de acordo com as opções especificadas ;#Aqui habilitamos o 9003 e 9004 a efetuar e receber chamadas utilizando o protocolo IAX2 com uma espera de no máximo 30 segundos exten => 9003,1,Dial(IAX2/9003,30) exten => 9004,1,Dial(IAX2/9004,30) ;#RAMAIS PARA GRAVAÇÃO DE AUDIO PARA URA ;#Recebe a ligação exten => 2001,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo boasvindas.gsm same => n,Record(boasvindas.gsm) ;#Reproduz o audio boasvindas que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(boasvindas) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2002,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo saldo.ulaw same => n,Record(saldo.ulaw) ;#Reproduz o audio saldo que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(saldo) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2003,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo atendimento.alaw same => n,Record(atendimento.alaw) ;#Reproduz o audio atendimento que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(atendimento) ;#Finaliza a ligação same => n,Hangup ;#Recebe a ligação exten => 2004,1,Answer ;#Inicia a gravação da mensagem e armazena no arquivo telefonista.gsm same => n,Record(telefonista.gsm) ;#Reproduz o audio telefonista que gravamos acima não precisamos passar a extesão caso tenhamos somente um com este nome same => n,Playback(telefonista) ;#Finaliza a ligação same => n,Hangup ;#Configuracao da URA exten => 9000,1,Goto(uraprincipal,s,1) ;# Contexto para o processamento da URA [uraprincipal] ;#Recebe a nossa ligação exten => s,1,Answer ;#Vamos definir um contador para a execução da ura, vamos definir um timeout para ela tambem e a mensagem de boasvindas same => n,Set(CONTA=1) same => n,Set(TIMEOUT(digit)=1) same => n,Set(TIMEOUT(response)=4) same => n(inicioura),BackGround(ura/boasvindas) ;# Usuario digitou 1 ;# - Reproduz o conteudo do arquivo de som saldo ;# e pronuncia a data e hora correntes exten => 1,1,PlayBack(ura/saldo) same => n,DateTime() same => n,HangUp ;# Usuario digitou 3 ;# - Reproduz o conteudo do arquivo de som atendimento ;# e encaminha a chamada para o cliente IAX2/9003 exten => 3,1,PlayBack(ura/atendimento) same => n,Dial(IAX2/9003) same => n,HangUp ;# Usuario digitou 11 ;# Reproduz o conteudo do arquivo de som telefonista ;# e encaminha a chamada para o cliente SIP/9002 exten => 11,1,PlayBack(ura/telefonista) same => n,Dial(SIP/9001) same => n,HangUp ;#Entrada Invalida exten => i,1,PlayBack(invalid) same => n,Goto(contador,1) ;#Fim do tempo para a digitacao exten => t,1,PlayBack(tt-allbusy) same => n,Goto(contador,1) ;#Extensao que verifica se o limite de tentativas da URA foi atingido exten => contador,1,Set(CONTA=$[${CONTA} + 1]) same => n,GotoIf($[${CONTA} < 3]?s,inicioura) same => n,HangUp
Agora vamos recarregar a nossa configuração
asterisk*CLI> dialplan reload Dialplan reloaded. [...]
Agora podemos ligar para o ramal 9000 e testar a nossa ura, não esqueça de configurar os ramais 9001 e 9003 que vai ser utilizado na URA.