Showing posts with label asterisk running configuring managing install how to ubuntu. Show all posts
Showing posts with label asterisk running configuring managing install how to ubuntu. Show all posts

Tuesday, August 5, 2008

Setting Up Outbound Settings

Setting Up Outbound Settings
Registering lets the remote server know where we are. Thus, it will start sending telephone calls to us. By default, Asterisk will use the settings specified in the [general] section of sip.conf.
Example: using a DeFuniac Telephone we can create a section that will route incoming telephone calls from them to their own special context in your dial plan and allow the Dial() command to omit the username and password.

[defuniactelephone]
type=peer
secret=mondal
username=aurobindo
host=voip.worldtelephone.com
fromuser=mgaribaldi
fromdomain=voip.defuniactelephone.com
context=incoming_world


After you add this, issue a reload command. What this specifically does is create an account on the system for the connection.This account will match any phone calls coming into the server voip.worldtelephone.com with the username aurobindo and the password mondal, and route those phone calls into the context incoming_world in your dial plan.

Step 17: Setting Up an SIP Server

[sipclient]
type=friend
context=internal
username=sipclient
secret=password
mailbox=201
host=dynamic
callerid="SIP Client" <3115552368>
dtmf=inband


It will set up an account for a channel called “sipclient” that is identified via the username “sipclient” and the ultra-secure password “password”.We
specify it is a dynamic host, which means the client can connect from anywhere so it
will be registering with us.The client will sit in the internal context where the appropriate dial strings should be. Also, we assign the voice-mail box 201 to the client so they can be notified about waiting messages.We also specify that outbound calls from the client will have the caller ID string SIP CLIENT <3115552368>.

After a reload, the system is now ready to accept an SIP client connection. Point an SIP phone to the server with the correct username and password and you will be ready to dial away.

Step 18: Configuring Voice Mail

Voice-mail settings are listed within voicemail.conf in the Asterisk configuration directory. There are a lot of bits to configure in voice mail, such as time zone settings, voice mail to e-mail settings, and options on how to pronounce time, among others. Unless you want to get fancy, most of the defaults should work fine.A common option that may need to be adjusted is the maxmsg option which limits the number of messages a user can have in their mailbox. Another option that may need to be adjusted is the tz option that controls what time zone the messages will be based in.This is commonly used if the server’s time zone is different than the time zone the company is based in. The tz option, by default, can only be set to options specified in the [zonemessages] section, which by default is set to the following:

[zonemessages]
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Copenhagen|'vm-received' a d b 'digits/at' HM


The syntax for this is

ZONENAME=TIMEZONE|DATESTRING

where ZONENAME is the name you want to give the setting, TIMEZONE is the Linux time-zone name you want the system to use for the setting, and DATESTRING is a string of Unix date variables and sound files. Not the most elegant solution, but it is very customizable. Let’s say we wanted to add a Pacific time zone, we would just add the following line:

pacific=America/Los_Angeles|'vm-received' Q 'digits/at' IMp


which would make a pacific zone based on the America/Los_Angeles time zone and would play the standard voice-mail envelope string.

Step 19: Configuring Mailboxes
Mailboxes are in the [default] section. A typical run-of-the-mill mailbox for Auro would look like this:

867 => 5309,Aurobindo Mondal,auro@company.com

This sets up mailbox 867 for Aurobindo Mondal, with a password of 5309. Any messages left in the mailbox would be attached to an e-mail sent to auro@socal.com, allowing him to listen to the message without calling the server.This setup is suitable for most users; however, there are other options as well. Asterisk has the ability to send a second message without the attachment that is more suitable for text messages or mobile phone e-mail as well:

867 => 5309,Aurobindo Mondal,aurobindo@company.com,3115552368@worldtelephone.com

This is handy since it allows the user to receive a notification on their mobile device about a voicemail message without having to download a possibly large audio file over a slow mobile data link. If we want to attach the voice-mail messages to the e-mail messages, but still wants to receive a notification.This is done with the attach option:

867 => 5309,Aurobindo Mondal,auro@company.com,,|attach=no

If he is in a separate time zone from the company and wants to have his mailbox say the time in the Central time zone. We would then adjust the mailbox like this:

867 => 5309,Aurobindo Mondal,steve@example.net,,|attach=no|tz=central

Step 20: Leaving and Retrieving Message
All of the voice-mail functions are contained in two applications: Voicemail(), which handles the portions of a user leaving a message on the system; and VoicemailMain(), which handles the users of the PBX to access their voice mail.We briefly touched upon VoiceMail()

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-conglomocorp)
exten => s,3,Background(conglomocorp-mainmenu)
exten => 100,1,Voicemail(u100)
exten => 200,1,Voicemail(b200)
exten => 300,1,VoicemailMain()
exten => 400,1,VoicemailMain(${CALLERID(num)})

Extension 100 sends you to voice mail to leave a message for mailbox 100. The u preceding the mailbox number tells Asterisk to use that mailbox’s “unavailable” greeting. Extension 200 does the same thing, except this time the b preceding the mailbox number tells Asterisk to use that mailbox’s “busy” greeting. Besides the greetings, both of these do the same thing: they take a message for the mailbox they are given. Extension 300 sends you to the voicemail system as if you are a user of the system. In this case, the system will prompt you for a mailbox number and password and if you give it valid credentials, it will let you listen to messages for that mailbox. Extension 400 does the same thing, except it attempts to find a mailbox corresponding to the caller’s caller ID number. If it does, it will prompt just for the password. If it does not, it will behave as if there was no number given to it.

The default keys are “1” to play messages, “6” to skip to the next message, “4” to go to the previous message, and “7” to delete the current message.

Step 20: Configure Music On Hold
The musiconhold.conf comes with a music on hold class ready for files, so often all you need to do is put some ulaw encoded files of your favorite songs in the moh/ subdirectory of your Asterisk sounds directory, usually /var/lib/
musiconhold.conf generally looks like

[default]
mode=files
directory=/var/lib/asterisk/moh

If you want to add another class for the support department.
Just add:

[support]
mode=files
directory=/var/lib/asterisk/moh/support

Then create the directory and add ulaw encoded files to /var/lib/asterisk/moh/support.
Once this is done, you will need to edit the support context and assign a new music
on hold class to it.You can do this via the SetMusicOnHold() command. Using the supportmenu
we would set the class like this:

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Background(conglomocorp-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)

This now assigns the caller to the support class until another command assigns it
to somewhere else. To configure your musiconhold.conf to support MP3s,
you will need to change the mode= to custom and specify the exact syntax of the MP3 player command:

[RiverBottomGang]
mode=custom
directory=/var/lib/asterisk/moh/RiverbottomNightmareBandMP3s
application=/usr/bin/mpg123 -q -r 8000 -f 8192 -b 2048 --mono -s

This example would create a new class called RiverBottomGang, which would then
use MPG123 to play all the songs in

/var/lib/asterisk/moh/RiverbottomNightmareBandMP3s.

This is somewhat less reliable than using ulaw encoded files because of the conversions involved.
N.B.: Sometimes, if your files are not encoded in a way that is just right, your music on hold will sound like it is playing a twice the speed.

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Background(conglomocorp-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)


Step 21: Configure Call Queues
In a call queue, all callers form a virtual line wait to be answered by a person answering a phone. When an “answerer” hangs up, the system takes the next person out of the queue and rings the answerer’s phone.
Call queues are managed by queues.conf.A typical call queue configuration would
look like this:

[supportqueue]
musicclass=support
strategy=ringall
timeout=10
wrapuptime=30
periodic-announce = conglomocorp-your-call-is-important
periodic-announce-frequency=60
member=>SIP/10
member=>SIP/20

Starting off each queue section is the queue’s name written in brackets. The next line defines the queue’s music on hold class—which, here, is the support class we defined in the last section. The strategy line defines the ringing strategy—in this case, ringall: ring all the phones until someone picks up. The system can be configured to use a roundrobin system that will ring the phones one by one starting from the first, or do a roundrobin with memory called rrmemory in which the system will start with the next phone after the phone it rang last. The timeout line specifies how long, in seconds, a phone should ring until the system determines that no one is there. The wrapuptime line specifies how long, also in seconds, after a call is completed that the system should wait before trying to ring that phone again. The periodic-announce and the periodic-announce-frequency specify a sound file the system should play for callers instead of the music on hold music and how long it should wait after playing a file until playing it again. Finally, each member line adds a member to the pool of phones that have people answering the queue.

[supportmenu]
exten => s,1,SetMusicOnHold(support)
exten => s,2,Playback(conglomocorp-welcome-to-support-queue)
exten => s,3,Queue(supportqueue)

Step 22: Setting Agents
agents.conf In this file, you can control the sounds the agents hear when they log on and off, whether or not you want to record the conversations they have with callers, and what music on hold class the agents should be assigned. The part in which you would control agents is at the bottom of the file at the end of the [agents] section. Each agent will be configured by an agent line. The agent line syntax is:

agent => AgentNumber,Password,AgentName

If we add some agents for our queue:

agent => 1001,867,Joe Random Agent
agent => 1002,5309,James Random Agent

Now edit the support queue:

[supportqueue]
musicclass=support
strategy=ringall
timeout=10
wrapuptime=30
periodic-announce = conglomocorp-your-call-is-important
periodic-announce-frequency=60
member=>SIP/10
member=>SIP/20
member=>Agent/1001
member=>Agent/1002

Step 22: Setting Up a Conference

The first step in setting up a conference is opening up meetme.conf and adding a conference room. Conference rooms are numbered, but these are only used when connecting to conferences from extensions.conf. Users should never have to interact with them.
In meetme.conf, the conference rooms are listed under the [rooms] section.The
syntax for rooms are

conf => RoomNumber,UserPIN,AdminPIN

In a conference room, both the User PIN and Admin PIN are optional. Let’s set
up a simple, un-PINed conference room.

conf => 1234

Now, let’s edit our extensions.conf. We are putting this in a separate context for the
same reason we put the agent login in a separate context: we don’t want regular users to stumble into the conference by accident.

[conference]
exten => s,1,MeetMe(1234)

Now, just set up a way to access this context and issue a reload command to the Asterisk CLI. You should be all set. When entering the context, you should hear two beeps and silence. Then, when someone else calls in, you should both hear the same two beeps and subsequently be connected to each other. This process repeats for each person who connects. Put yourself on the back.



AddThis Feed Button

Running and Managing Asterisk

Running and Managing Asterisk:

asterisk -vvvc

It will execute the server. These options tell the server not to run in the background and to run at a verbosity level of three, which means all the important messages will be displayed and enough less important ones and that the user will see all diagnostic messages. While many messages will quickly scroll by on the screen, most of these are simple initialization messages that can be ignored. If any fatal errors occur, Asterisk will stop and exit so the message remains on the screen. Asterisk will display “Asterisk Ready” when it has successfully run.

asterisk

The other way to run Asterisk is to start the daemon by running the command without any arguments at the command prompt.This will start the server in the background. Starting in the background as opposed to the foreground has advantages and disadvantages. While the server won’t tie up a terminal or exit when the terminal is closed, it will not display any diagnostic messages to the terminal during startup either. Running Asterisk in the background is the most common way to run Asterisk since normally an Asterisk process would be running at all times. One would want to run Asterisk in the foreground if diagnosis information is needed. To connect to an already running Asterisk process, run the command.

asterisk -vvvr

This will duplicate the verbosity settings to the above command.

You can issue the stop or restart command to Asterisk in three ways. When issuing the restart or stop command, you can tell Asterisk to do it now, gracefully, or when convenient.These control how the server will go about shutting down.

now : The server process is shut down immediately, without any concerns for activity.Any active calls are terminated and all active threads are killed.This is not normally the way to shut down the server in a production environment.


gracefully: it is a much cleaner way to shut down or restart. After the command is issued, Asterisk stops answering all new calls.

convenient: continues functioning normally, the server restarts or stops when there are no active calls within the system. While this is the best when talking in terms of lost productivity, if the system constantly has active calls on it, the system will never stop or restart.

reload : reloads all the configuration files on-the-fly without interrupting system activity.

Configuring Asterisk:
If you enter into your Asterisk configuration directory, /etc/asterisk, you’ll see 65 files.
Asterisk Configuration Files:
adsi.conf Controls Asterisk Analog Display Services Interface settings.
adtranvofr.conf Contains settings related to Voice over Frame Relay and AdTran equipment.
agents.conf Contains settings for call agents that work call queues.
alarmreceiver.conf Contains settings for the Alarm Receiver application.
alsa.conf Contains settings for the CLI sound system if using ALSA sound drivers.
amd.conf Contains settings for answering machine detection on outbound calls.
asterisk.adsi Asterisk Analog Display Services Interface script.
cdr.conf Contains settings for Call Detail Records (CDRs).
cdr_custom.conf Contains settings for custom Call Detail Record mappings.
cdr_manager.conf Contains settings for sending CDRs to the Asterisk Management Interface.
cdr_odbc.conf Contains settings for storing your CDRs into a database connected via ODBC.
cdr_pgsql.conf Contains settings for storing your CDRs into a PostgreSQL SQL database.
cdr_tds.conf Contains settings for storing your CDRs into a FreeTDS database.
CODECs.conf Contains CODEC settings.
dnsmgr.conf Contains settings about Domain Name System (DNS) lookups done by Asterisk.
dundi.conf Controls Distributed Universal Number Discovery connections and settings.
enum.conf Controls Telephone Number Mapping/E164 connections and settings.
extconfig.conf Contains mappings for external database connections for configuration settings.
extensions.ael Contains the dial plan settings, written in Asterisk Extension Language.
extensions.conf Contains the dial plan settings.
Features.conf Contains settings for call parking.
festival.conf Contains settings for the connection between Asterisk and the Festival TTS Engine.
followme.conf Contains settings for the FollowMe application.
func_odbc.conf Contains settings for template-based SQL functions accessed via ODBC.
gtalk.conf Controls Google Talk connections and settings.
h323.conf Controls H323 Protocol connections and settings.
http.conf Contains settings for Asterisk’s integrated HTTP server.
iax.conf Controls Inter Asterisk eXchange Protocol Connections and Settings.
iaxprov.conf Contains settings for IAXy provisioning.
indications.conf Contains settings for the system’s Ring, Busy, Reorder, and Special Information tones.
jabber.conf Controls Jabber Protocol connections and settings.
logger.conf Contains settings about where and what to log.
manager.conf Contains settings for the Asterisk Management Interface.
meetme.conf Contains settings for the MeetMe conferencing system.
mgcp.conf Controls Media Gateway Control Protocol connections and settings.
misdn.conf Controls Integrated Serial Digital Networks (ISDNs) connections and settings.
modem.conf Controls ISDN modem settings.
modules.conf Controls which applications and modules are loaded when the server is started.
musiconhold.conf Contains Music on Hold settings.
muted.conf Contains settings for the Mute Daemon.
osp.conf Controls settings and connections for the Open Settlement Protocol.
oss.conf Contains settings for the CLI sound system if using OSS sound drivers.
phone.conf Contains settings for Linux Telephony devices.
privacy.conf Contains settings for the PrivacyManager application.
queues.conf Contains settings for call queues.
res_odbc.conf Contains settings for external database connections for configuration settings.
res_snmp.conf Contains Simple Network Management Protocol settings for the SNMP application.
rpt.conf Controls settings of the app_rpt application, which enables radio systems to be linked via VoIP.
rtp.conf Contains Real-time Transport Protocol settings.
say.conf Contains string settings for the various say_* applications.
sip.conf Controls Session Initiation Protocol (SIP) connections and settings.
sip_notify.conf Contains settings for SIP’s NOTIFY command.
skinny.conf Controls Skinny Client Control Protocol connections and settings.
sla.conf Controls Shared Line Appearance connections and settings.
smdi.conf Contains settings for the Simplified Message Desk Interface.
telcordia-1.adsi Default Telcordia Analog Display Services Interface script.
udptl.conf Contains settings for UDPTL, one of the transports for Faxing over IP Networks.
users.conf A file that controls a combination of settings, allowing for easier user maintenance.
voicemail.conf Contains voice mail settings and mailbox details.
vpb.conf Contains settings for VoiceTronix hardware.
zapata.conf Controls settings for Zapata hardware.

Step 10: Configuring Dial Plan
The dial plan is the logic behind how phone calls are routed through your Asterisk installation. Asterisk runs every incoming call, every outgoing call, and every call in between extensions through the dial plan logic in order to determine where it should go and whether or not it should be completed. The dial plan is contained in extensions.conf, and therefore it can be said that extensions.conf is easily the most important configuration file in Asterisk. Removing extensions.conf is similar to removing a traffic light at a complicated intersection; cars will want to enter and cars will want to leave, but there will be no way to direct them. extensions.conf can be broken down into three major parts: 1. Contexts, 2. Extensions, and 3. Variables. Each has their own unique and important function and needs to work together for a good dial plan to function.

1. Contexts : A context is a simple way for grouping extension commands based on what the user has dialed.To begin a context, put the name of a context by itself in square brackets. Each context then contains a list of commands. In extensions.conf there are two special contexts called [general] and [globals] in which certain settings can be set. general has a few special settings that define how extensions.conf behaves. First off is the static setting.This, can be set to either yes or no, but for some reason, only yes has been implemented.This will eventually control Asterisk from rewriting the extensions.conf every time an extension is added or deleted.The next setting is writeprotect. This can also be set to either yes or no, and this controls the ability of someone at the CLI to rewrite your dial plan via the save dialplan command.This may seem handy, but doing so will delete all comments in the file. Each extension follows a similar syntax. exten => EXTENSION,PRIORITY,COMMAND(ARGS). exten => precedes every extension.This is a directive that tells Asterisk to define an extension, as opposed to a context.The next three parts of an extension are 1) EXTENSION, 2) PRIORITY, and 3) COMMAND(). Let’s cover these three portions.

1) EXTENSION--- Extensions can be broken down into three types: a constant extension, a wildcard extension, and a special extension. A constant extension is an extension that when coded to a literal constant is the dial plan. A wildcard extension is a context that uses wildcards to match multiple possibilities for the extension.Wildcards can be either internal Asterisk wildcards or RegEx-like patterns given below:

[0126-9]--- Any digit within the pattern. (In this case: 0,1,2,6,7,8, and 9).
X ---Any number 0 through 9. The equivalent of [0-9].
Z --- Numbers between 1 through 9. The equivalent of [1-9].
N -- Numbers between 2 through 9. The equivalent of [2-9]. This scheme is used most commonly in Area Code and Prefix assignments.
.(dot)--- Any number, one or more times.

Example: Let’s say a department in your building, the ever-important Chemical department, have moved to another division and wanted to leave a message at their old extensions informing callers that they had moved.They previously occupied Extensions 300 through 329 on your PBX. Rather than rewrite 30 lines; you can add a single extension of
exten => 3[0-2]X,1,Playback(ChemicalDeptHasMoved)
This will have any caller dialing the department’s former extensions greeted by a message informing them of the move.

N.B. - Playback is a command that plays back a sound file stored on the system.

In addition to wildcard and literal extensions, there are also special extensions that correspond to special events in the dial plan:

S --> Start --> Used when a caller is put in a context before dialing a number.
I --> Invalid --> Used when a caller dials an extension not defined in the current context.
H --> Hangup --> Used when a caller hangs up.
T --> Time Out --> Used when a caller does not respond within the response timeout period.
T --> Absolute
Time Out --> Used when a caller does not respond within the about timeout period.
O --> Operator.

2) PRIORITY--- it controls the flow in which commands are executed. For each extension, this is either controlled by an increasing number or a special n syntax.The n syntax tells Asterisk to execute the extension one line after the other:

[incomingcall]
exten => s,1,Answer()
exten => s,n,Playback(mainmenu)
exten => s,n,Hangup()

In this example, any call being routed to the “incomingcall” extension in Asterisk would have its call answered, a menu would then play, and then the call would be terminated. After Asterisk finishes executing one line, the next line would be executed. Numbering the steps provides greater flexibility with the dial plan since it is possible to control the flow logically rather than line by line. For example, the extension shown earlier could be rewritten with a numbered sequence

[incomingcall]
exten => s,2,Playback(mainmenu)
exten => s,1,Answer()
exten => s,3,Hangup()

Asterisk still answers, plays the menu, and hangs up because it executes by line number rather than by the order in which the lines appear. It executes step 1, followed by steps 2, and then 3.These steps could be scattered throughout the context and intertwined with hundreds of extensions. As long as they are numbered correctly, Asterisk will execute them in order for that context.

3) COMMAND()----The commands are the heart of any dial plan.They are what actually cause Asterisk to answer the call, ring the phone, transfer the call, play the menu, and do numerous other things.

Dial(CHANNEL) ---> Dials a channel
Answer() ---> Answers a ringing channel
Playback(FILE) ---> Plays a sound file in the foreground
Background(FILE) ---> Plays a sound file in the background, while waiting for the user to input an extension
Hangup() ---> Hangs up the call
SayDigits(NUMBER) ---> Says a number, digit by digit

N.B: Extensions are the physical numbers assigned to a device, while channels, on the other hand, are the connections to the devices themselves.
For example, you can have a phone at your desk set up to ring on three separate extensions; however, each of these extensions will ring the same
channel—namely, your phone.

2. Extensions: Variables in extensions.conf are nothing special.They act like variables in any other language.Variables are set via the Set() command and are read via the variable name encased in ${}:

[example]
exten => s,1,Set(TEST=1)
exten => s,2,NoOp(${TEST})

Variables are common in simple dial-plan applications and Asterisk uses certain variables for internal functions, but their use is somewhat uncommon in regular dial plan usage.

Now a very extensions.conf looks like:

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => s,4,Hangup()
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


Now what it mean is : When a call enters the [default] context, it is answered by Asterisk. Asterisk then starts playing the mainmenu sound file while waiting for the caller to enter digits. At this point, the caller can either enter 100 and be connected to the channel SIP/10 or 20 and be connected to the channel SIP/20. If the menu finishes playing and the user has not entered any digits, the call will be hung up on.

Now we try to take the file we had before and use some special extensions to have the menu replay if the user hasn’t entered an extension and inform them if the extension they entered is invalid.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


Creating submenu: Now to have a support menu that allows customers to direct their questions to the appropriate support group. We can accomplish this by creating a second context that contains the appropriate menu and extensions. Let’s build on the previous example again and add a second menu that allows callers to be connected to the Technical, Widget, or Chemical support lines.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-socal)
exten => s,3,Background(socal-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 3,1,Goto(s,1,supportmenu)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)
[supportmenu]
exten => s,1,Background(socal-supportmenu)
exten => 1,1,Dial(SIP/technicalsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/chemicalsupportline)
exten => #,1, Goto(s,2,default)
exten => t,1,Goto(s,1)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,1)


Now here If a caller dials 3, they are connected to the [supportmenu] context with a Goto() statement. Goto() can be called many different ways.You can jump between priorities in the same extension by just specifying Goto(priority) or you can jump between extensions in the same context by specifying Goto(priority,extension). Lastly, you can switch contexts by specifying Goto(context, extension, priority).

N.B: For example: Goto(supportmenu,s,1) will behave differently than Goto(supportmenu, s, 1). In the first example, Goto will behave as expected and jump to the “s” extension, priority 1. However, in the second example, Goto will jump to the “s” extension, priority 1. Note how there is a space that precedes the “s”. This can be a source of frustration if you don’t know to look for it.

Asterisk permits other contexts to be joined together via the include => directive.This allows other contexts to be include-ed into the current context and act as one giant context.

Creating Voice Mail Support for Existing Extensions:
[default]
include => specialextensions
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-socalLabs)
exten => s,3,Background(
socalLabs-mainmenu)
exten => 3,1,Goto(supportmenu,s,1)
exten => 100,1,Dial(SIP/10,20)
exten => 100,2,Goto(s-100-${DIALSTATUS},1)
exten => s-100-NOANSWER,1,Voicemail(u100)
exten => s-100-NOANSWER,2,Hangup()
exten => s-100-BUSY,1,Voicemail(b100)
exten => s-100-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-100-NOANSWER,1)
exten => 200,1,Dial(SIP/20)
exten => 200,2,Goto(s-200-${DIALSTATUS},1)
exten => s-200-NOANSWER,1,Voicemail(u200)
exten => s-200-NOANSWER,2,Hangup()
exten => s-200-BUSY,1,Voicemail(b200)
exten => s-200-BUSY,2,Hangup()
exten => _s-.,1,Goto(s-200-NOANSWER,1)
[supportmenu]
include => specialextensions
exten => s,1,Background(
socalLabs-supportmenu)
exten => 1,1,Dial(SIP/blivetsupportline)
exten => 2,1,Dial(SIP/widgetsupportline)
exten => 3,1,Dial(SIP/frobsupportline)
exten => #,1,Goto(s,2)
[specialextensions]
exten => t,1,Goto(s,1)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,1)

Step 11: Configuring extensions.ael :
The alternative to extensions.conf is extensions.ael. extensions.ael is extensions.conf written in a scripting language called Asterisk Extensions Language (AEL). AEL is language maintained by Digium solely for writing dial plans in Asterisk. While it is functionally equivalent to extensions.conf, AEL is syntactically much more powerful and allows for greater flexibility in simple scripting and logical operations.

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-)
exten => s,3,Background(-mainmenu)
exten => s,4,Hangup()
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)

is written in extensions.conf the same thing we can write in extensions.ael like this,

context default {
s => {
Answer();
Background(thank-you-for-calling-conglomocorp);
Background(conglomocorp-mainmenu);
Hangup();
};
100 => Dial(SIP/10);
200 => Dial(SIP/20);
};

And this

[default]
exten => s,1,Answer()
exten => s,2,Background(thank-you-for-calling-conglomocorp)
exten => s,3,Background(conglomocorp-mainmenu)
exten => t,1,Goto(s,2)
exten => i,1,Playback(sorry-thats-not-valid)
exten => i,2,Goto(s,2)
exten => 100,1,Dial(SIP/10)
exten => 200,1,Dial(SIP/20)


can be this

context default {
s => {
Answer();
restart:
Background(thank-you-for-calling-conglomocorp);
Background(conglomocorp-mainmenu);
Hangup();
};
100 => Dial(SIP/10);
200 => Dial(SIP/20);
t => { goto s|restart;}
i => {
Playback(sorry-thats-not-valid);
goto s|restart;
}
};


Step 12: Protocols Support :
SIP --> Session Initiation
Protocol --> Most common VoIP protocol. Used in numerous devices.
IAX --> Inter Asterisk
eXchange Protocol --> Used primarily in connections between Asterisk servers.
SCCP --> Skinny Client
Control Protocol --> Used in Cisco devices.
MGCP --> Media Gateway Control Protocol --> Used in some VoIP devices, notably D-Link.
H323 --> H.323 Protocol --> Used in some older VoIP devices.

Each protocol is controlled by a different file. Multiple connections can be set up in a single file, or the files can be broken down and linked via include statements. Each file has certain specific configuration options that are used only for the protocol the file governs, and they also have options that are common across all files. Let’s go over some of the conventions:

Have a look at iax.conf

[my_iax_server]
type=peer
auth=md5
notransfer=yes
host=10.0.23.232
disallow=all
allow=ulaw


Asterisk uses some peculiar classifications for its VoIP connections.They are classified by the type= setting, which is either set to user, friend, or peer.
A user is a connection that will be used to make telephone calls to the local server; a peer is a connection that will be used to make telephone calls from the local server; and a friend is a connection that will be used to make telephone calls both to, and from, the local server.


Step 13: Allowing and Disallowing Codecs
Asterisk supports numerous codecs for audio. Codecs can save bandwidth and allow for more simultaneous phone calls on a data link.

Codecs Speed Simultaneous Calls
ยต-Law---> 64 Kbps -------> 24
G.723.1 --->5.3/6.3 Kbps -->289/243
G.726 --->16/24/32/40 Kbps --->96/64/48/38
G.729 ----->8 Kbps ------------> 192----------> Requires license
GSM ------->13 Kbps ----------->118
iLBC -------->15 Kbps ----------->102
LPC-10 ------>2.5 Kbps ---------->614
Speex ------->2.15 to 44.2 Kbps -->714 to 34----> “Open” codec

Say your shiny new Asterisk server has a connection to your telephone provider via the IAX2 protocol. However, whenever a phone call is made through the provider, the GSM codec is used, rather than the ulaw codec that is used when you call between extensions in the office.This needs to be fixed. So opening up the iax.conf configuration file you add the following line to the section controlling the connection:

disallow=gsm
Then issue a reload command to Asterisk.

The correct way to ensure ulaw is used as the codec would be to add the following lines to iax.conf.
disallow=all
allow=ulaw


Step 14: Configuring SIP Connections

SIP is the most common VoIP protocol in use today. It is an official Internet standard and is supported by almost every VoIP device and service on the market. SIP connections are configured in the sip.conf file in the system’s configuration directory, usually /etc/asterisk.

To address the firewall issue, you need to open up the firewall to allow connections from external sources to the Asterisk server on a massive amount of ports.This is a bit of an issue if the server is accepting connections from all over the Internet since there is no way to lock the access down to specific address blocks.A way to limit the amount of ports you need to open up is to edit rtp.conf in the Asterisk configuration directory:

;
; RTP Configuration
;
[general]
;
; RTP start and RTP end configure start and end addresses
;
rtpstart=10000
rtpend=20000


In sip.conf, there are three settings: the externip setting, the localnet setting, and the nat setting.The nat setting determines whether or not the server is behind a NAT.This can be set to four different settings: yes, no, never, and route.The yes setting is the straightforward setting. It informs Asterisk that we are behind a NAT and it should assume so whenever it sends SIP messages.The no setting is a bit more complicated than “No, the server is not behind a NAT.”The no setting tells Asterisk it should use RFC3581 to determine whether or not there is a NAT between the local server and the remote server.The next setting, route, is a bit of a kludge to help NAT work with certain phones that do not completely support RFC3581; you likely will never use this, and hopefully this behavior will be moved to another setting in future versions. Finally, there is never, which informs Asterisk to never think the server is behind a NAT.
For example, let’s say we have a server at our office on a 196.168.42.0/24 network that is NATed behind a gateway with an external IP address of 118.23.45.76.This is how we would make our NAT settings:

[general]
nat=yes
externip=118.23.45.76
localnet=192.168.42.0/24


Step 15: Connecting to an SIP Server
1) Registering Your Connection: Most providers do not have your account tied to a specific IP address since it’s becoming less and less common to have static IP addresses in most situations and it’s less of a hassle for you to come to them. So how do we let the provider know where to route the incoming calls? We register with them. Registering is a way of checking in with a remote server, letting them know where to route calls and that the local server is still alive.A typical register line in sip.conf would look like this:

register => auro:mondal@voip.globaltelephone.com/3115552368

In which, after a reload, we would be registering the phone number “311-555-2368” with the server voip.globaltelephone.com using the username karthik and the password reddy.
N.B: Asterisk doesn’t have any security on its configuration files by default, so before you add any sensitive information, you may want to make sure the file permissions are locked down enough that the only nonprivileged user that can read them is the user Asterisk is running under.



AddThis Feed Button