Project Manager: Susan S. Bradley Content Architect



Yüklə 207,34 Kb.
səhifə3/5
tarix14.10.2017
ölçüsü207,34 Kb.
#5063
1   2   3   4   5

Installation of Asterisk


There are a variety of ways to implement Asterisk, and its many flavors or subversions. In this example, we show one of the quickest ways to install and configure Asterisk.

To deploy Asterisk on a CentOS virtual machine, you must install the following modules:



  • gcc

  • gcc-c ++

  • kernel-devel

  • libtermcap-devel

  • bison

  • openssl-devel

  • ncurses-devel

On CentOS, you can install these modules by using Linux Yellowdog Updater Modified (Yum) as follows:

yum –y install gcc gcc-c++ libtermcap-devel kernel-devel bison openssl-devl ncurses-devel

Note. If you run an symmetric multiprocessing (SMP) kernel, you need kernel-smp-devel instead of kernel-devel.

The latest release of Asterisk 1.8 supports communication with Google Talk natively.

To install Asterisk, log on as root or if logging on as a regular user, use the sudo command. To download Asterisk on the CentOS server, change to the directory /usr/src and then run the wget command to download the package. After you download it, create a directory called /asterisk and untar the package. Run the commands as follows:

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8.2.3.tar.gz

mkdir asterisk

tar -zxvf asterisk-1.8.2.3.tar.gz –strip-components=1 –C asterisk

Move to the /asterisk directory that you created, and then install Asterisk by running the following commands:



./configure

make

make install

make samples

make config

Note. The make samples command creates a default set of configuration files for Asterisk. These can be a useful reference if you are unfamiliar with Asterisk config files.

Then, restart the server to complete the installation by using the following command:



shutdown –r now

To access the Asterisk console, run the following command:



asterisk -vvvvvvr

Note. The letter r is for remote. The number of v characters sets the verbose level of the Asterisk console, which is a verbose level 6 in this case.

Configuration


To help you setup direct SIP with Asterisk, step-by-step instructions for configuring Asterisk, Lync Server and the X-Lite SIP client for Asterisk are discussed in this section.

Configure Asterisk


To configure Asterisk, you must edit a series of configuration files. The following files are in a text format and are normally found in the /etc/asterisk directory:

  • sip.conf

  • extensions.conf

Configure sip.conf


The sip.conf file defines all SIP configurations for Asterisk. The first section in this text file is labeled [general]. In the [general] section, you define general SIP settings for the entire Asterisk server.

We recommend that you build a new sip.conf file and use the original for reference. This makes a cleaner configuration file. Create a directory under /etc/asterisk called "samples" and then copy all files into this directory as follows:



mkdir /etc/asterisk/samples

cp /etc/asterisk/*.* /etc/asterisk/samples

The following is an example of a [general] section from a sip.conf file.

[general]

context = default

bindport = 5060

bindaddr = 0.0.0.0

tcpbindaddr = 0.0.0.0

tcpenable = yes



Note. This example is only basic. For a detailed explanation of configuring the Asterisk sip.conf, see the Asterisk Wiki website at http://www.voip-info.org/wiki/view/Asterisk+config+sip.conf.

Following is an explanation of each field in this file:



  • [general]   Defines the name of this section.

  • context=default   Calls received from a SIP object (that is, Mediation Server) are routed based on the context of which name matches the SIP object’s name in the Asterisk dial plan (that is, the sip.conf file). If no context matching the SIP object name is found in the sip.conf, the default context is applied to the call.

  • bindport=5060   Defines the UDP port Asterisk listens on (in this case, port 5060).

  • bindaddr=0.0.0.0   Defines the IP address Asterisk listens on for UDP traffic. A value of 0.0.0.0 instructs Asterisk to use all available IP addresses on the Asterisk server, including the internal loopback address of 127.0.0.1.

  • tcpbindaddr=0.0.0.0   Defines the IP address Asterisk listens on for TCP traffic. A value of 0.0.0.0 instructs Asterisk to use all available IP addresses of the Asterisk server, including the internal loopback address of 127.0.0.1

  • tcpenable=yes   Indicates to Asterisk to enable TCP. Valid values are yes and no.

Next, we define a section in the sip.config file to instruct Asterisk how to connect to the Lync Server 2010, Mediation Server. In Contoso’s example, the administrator named this section, to_lync; however, you can call it anything you like in your sip.conf file, except general because that is a special section in the sip.conf file.

[to_lync]

type = peer

host =

qualify = yes

transport = tcp

Let’s examine each of these lines that define this SIP object:


  • [to_lync]   Tells Asterisk this is the start of a new section in the sip.conf file. Note the name is inside square brackets. You can name your SIP object anything you like.

  • type=peer   Set this field to peer. This indicates to Asterisk that this SIP object (that is, Mediation Server) can receive calls.

  • host=   Specify the IP address where Asterisk can find this SIP object (that is, the IP address of your Lync Server 2010, Mediation Server). In Contoso’s case, The IP address of the Mediation Server is 192.168.100.20.

  • qualify=yes   Instructs Asterisk to verify that this SIP object is reachable. Asterisk performs a check every 60 seconds.

  • transport=tcp   By default, Asterisk uses UDP. This instructs Asterisk to use TCP only for this SIP object.

Finally, we need to add a section to our sip.conf file to enable our X-Lite desktop client to connect to Asterisk. We add the following lines to the end of the sip.conf file.

[]

type = friend

callerid = caller_name

secret =

dtmfmode = rfc2833

disallow = all

allow = ulaw

transport = udp

Let’s examine each of these lines:



  • []   Tells Asterisk this is the start of a new section in the sip.conf file. Note the name is inside square brackets. This value identifies the client. You can name it anything you like.

  • type=friend   Set this option to friend. This tells Asterisk that this SIP object is capable of sending and receiving calls.

  • callerid= caller_name    Specifies the caller ID to show when placing calls out using this SIP object. You can specify any value you like for this caller ID.

  • secret=
       Provide the password for the user (that is, the one specified in the callerid field) to connect to the Asterisk server.

  • dtmfmode=rfc2833   Tells Asterisk how this client handles DTMF signaling.

  • disallow=all   Instructs Asterisk that NO codecs are to be used for this SIP object. This field is used in conjunction with the next instruction.

  • allow=ulaw   Following the disallow=all instruction, this tells Asterisk to use µ-law to communicate with this SIP object ( that is, the X-Lite client).

  • transport=udp   Instructs Asterisk to use UDP only for this SIP object ( that is, the X-Lite client).

Let’s put all of this together in one complete sip.conf file, using Contoso’s example.

[general]

context = default

bindport = 5060

bindaddr = 0.0.0.0

tcpbindaddr = 0.0.0.0

tcpenable = yes

[to_lync]

type = peer

host = 192.168.100.20

qualify = yes

transport = tcp

[1000]

type = friend



callerid = Test User 1000

secret = 1000

dtmfmode = rfc2833

disallow = all

allow = ulaw

transport = udp

In the previous example, only one context called default is defined in the [general] section. All calls that Asterisk receives, regardless of where they come from, are assigned a context. This context dictates which dial plan (that is, extensions.conf) Asterisk should use to process incoming calls.

Note. We are presenting a small view of how you can configure Asterisk. For details, see www.voip-info.org/wiki/view/Asterisk.

After you’ve modified and saved the sip.conf configuration file, you must reload it using the following commands:



asterisk -vvvvvvr

asterisk*CLI> sip reload

To view the configured SIP clients and devices, run the following command:



asterisk*CLI> sip show peers

Configure extensions.conf


This file defines the dial plan configuration in Asterisk. The dial plan dictates how calls flow in Asterisk. Every incoming call that Asterisk receives is processed depending on the instructions defined in the dial plan.

Note. A full and detailed explanation on dial plans in Asterisk would fill an entire book. The following information is enough to get started with a basic Asterisk dial plan. For details, see www.voip-info.org/wiki/view/Asterisk.

In the previous sip.conf section, we talked about using a context in Asterisk and how this context dictates where an incoming calls is processed in the dial plan. We are going to see how this context is used in the dial plan.

We are also going to examine two other concepts within an Asterisk dial plan, extensions and macros.

First, let’s look at how an extensions.conf file is structured.


Overview of the extensions.conf file


As with the previous section regarding the sip.conf file, the extensions.conf file has two special sections that must be present and must be named in a specific way. These are the [general] and [globals] section.

They must appear at the beginning of the extensions.conf file. You may choose to leave them empty, but the sections must be present as follows:

[general]

[globals]

Following these, you can define your own sections. Asterisk calls these sections contexts. This is the context (or contexts) where your incoming calls will be processed. Therefore, it is important that you name these contexts with the same name that you have referenced in your sip.conf file.

Contexts


Contexts are nothing more than a convenient container for grouping extensions. We'll look at extensions in the next section.

You name the context by placing the name between square brackets.

In our sip.conf file we put together in the previous section, we used only one context and called it default, so in our extensions.conf file, we'll define a context called [default] as follows:

[general]

[globals]

[default]

Inside this new [default] context, we'll add some instructions for dealing with calls. Asterisk refers to these instructions as extensions.

Extensions


Extension lines in an Asterisk dial plan are defined as:

Exten => ,,

For example:

exten => 1000,1,command

exten => 1000,2,command

exten => 1000,3,command

Extension lines are composed of the following components:


  1. The number pattern to match

  2. A number or character identifying the order in which this step should be processed

  3. An action to perform

While the exact number being called can be matched (for example, 1000), number patterns can be used to match a wider range of numbers (for example, _1XXX matches all numbers starting with 1 and containing three more numbers). For details about how to configure extension lines in Asterisk, see the Asterisk Wiki at http://www.voip-info.org/wiki/view/Asterisk.

Table 2 defines the special characters that you can use to define number patterns.



Table 2. Number Pattern Table

Character

Description

_

Underscore. Defines the start of a number pattern. Use at the start of every number pattern.

X

Matches any number 0 to 9.

Z

Matches any number 1 to 9.

N

Matches any number 2 to 9.

[12-9a]

Matches any number OR letter contained in the square brackets. In this case, numbers 1, 2, 9, and a lowercase letter a.

[a-z]

Matches any lowercase letter.

[A-Z]

Matches any uppercase letter.

s

Lowercase s. Matches anything if no other extensions match. Useful in macros.

.

Period. Matches one or more characters.

Let’s make things a little clearer with some examples.

Examples:

exten => 333

Matches calls to 333 only.

exten => _3XX

Matches all calls between 300 and 399.

exten => _1XXX

Matches all calls between 1000 and 1999. This number pattern does not match calls in the 100 to 199 range.

Let’s look at a simple example using three extension lines in a dial plan:

exten => 333,1,Answer

exten => 333,n,Playback(demo-moreinfo)

exten => 333,n,Hangup

Let’s examine each line:


  • Exten => 333,1,Answer   All three lines are for calls to the number 333, but the number 1 identifies this as the first instruction. The answer command tells Asterisk to answer the call.

  • Exten => 333,n,Playback(demo-moreinfo)   The letter n identifies this is the next instruction for calls to 333. The Playback command in this example is playing a default sound file that comes included with Asterisk (that is, demo-moreinfo). Note that we answered the incoming call first before playing the file.

  • Exten=>333,n,Hangup   The letter n identifies this is the next instruction for calls to 333. The Hangup command ends the call.

Note. If you are new to Asterisk, all of this may seem difficult to understand. We are covering only the basics to get your Lync Server working with Asterisk. For details, see www.voip-info.org/wiki/view/Asterisk

Constructing Your extensions.conf File


Let’s take a look at Bob’s example extensions.conf file and use this to help you construct your own. There are some new commands that we'll use in this file, but we'll examine each line to show you what is happening.

Here’s Bob’s extensions.conf file:

[general]

[globals]

[default]

exten => _+XX.,1,Set(CALLERID(num)=${CALLERID(num):1:11})

exten => _+XX.,n,Goto(${EXTEN:1},1)

exten => 1000,1,Dial(SIP/1000)

exten => 1000,n,Hangup

exten => 14255550150,1,Dial(sip/to_ocs/+${EXTEN})

exten => 14255550150,n,Hangup

Let’s examine each of these lines:



  • [general]   This section must be present in an extensions.conf file and must be first. In this example, we have left it empty.

  • [globals]   This section must be present in an extensions.conf file and must be second. In this example, we have left it empty.

  • [default]   This is our context we have defined to hold instructions for incoming calls. We have called it default. Note that the same name is used in our sip.conf file. This is where all incoming calls enter the dial plan and work through the instructions, trying to find patterns that match the numbers being called.

The following sections describe the exten=> lines in more detail.
exten=>_+XX.,1,Set(CALLERID(num)=${CALLERID(num):1:11})

Note the underscore character (that is, "_") indicates that this is a number matching pattern being used.

The +XX. matches any number starting with a + and having at least two more digits (that is, XX), followed by any other amount of digits (using the period character (that is, ".") as a wildcard). This matches numbers coming from Lync, starting with + and that are at least three digits long or longer.

Next, the number 1 indicates this is the first instruction for numbers that match this pattern.

Asterisk has a number of special variables that can be referenced from within a dial plan. On this line, we are referencing the number associated with caller ID.

The command is removing the + character from the caller ID of outgoing Lync calls, and replacing that caller ID with the last 11 digits from the original caller ID. For example, a caller ID coming from Lync of +14255550150 would be changed to 14255550150.

Note the placement of square brackets (that is, "[ ]") and the curly brackets (that is, "{ }"). It is important where you use these in an Asterisk command.


exten=>_+XX.,n,Goto(${EXTEN:1},1)

Again we see the same number matching pattern as the last command. In this case, it is followed by the letter n, which indicates that this is the next instruction for numbers that match this pattern.

The Goto command is telling Asterisk to move this call to another point in the dial plan. It is also referencing another special Asterisk variables, called EXTEN. This is the extension being called (that is, the number being called).

In this case, the outcome is to remove the first digit of the number being called. For example, if the number being called is +1000, this command removes the + sign and moves the call to the 1000 section of the dial plan. Note the 1 at the end of this command, which tells Asterisk to move to the first instruction for 1000.

This ends the instructions for numbers that match the number pattern of +XX., but we do not need to do anything to tell Asterisk this, we can just start a different set of extensions.


exten=>1000,1,Dial(SIP/1000)

This matches the number 1000 only. We can tell from the 1, after the number matching section, that this is the first instruction in this series.

Here we can see the dial command being used in an Asterisk dial plan. This particular example tells Asterisk to place a call out, using SIP, to the object called 1000. In the previous sip.conf example, we defined a SIP object in that file called 1000. That object was to be used by our X-Lite desktop client to connect to Asterisk. That object is being referenced here in the dial plan to place a call out to X-Lite.


exten=1000,n,Hangup

This matches the number 1000 only, and we can tell from the character n, that this is the next instruction for 1000.

It’s useful to understand that Asterisk will not move to this line until the call created by the Dial command is finished.

The Hangup command instructs Asterisk to end the call. It’s always a good idea to add an extra, final line using the Hangup command just to make sure all calls are terminated when they should be.

exten=>14255550150,1,Dial(sip/to_lync/+${EXTEN})

This line of instruction may seem a little daunting, but it's the same as the others. Let’s break it down.

We see that this instruction matches the number 14255550150 only. Then, we see a single number 1, showing this is the first instruction for this number matching pattern.

Finally we see a Dial command. In this example, it tells Asterisk to dial, using SIP, to the SIP object called to_lync. Remember the sip.conf file? We created a SIP object to link to the Mediation Server called to_lync.

It also adds the end section of +${EXTEN}. This instructs Asterisk to add a + character to the beginning of the number being called (that is, 14255550150), and pass that to the to_lync object (that is, the Mediation Server).

To explain this more simply, Asterisk pattern matches calls placed to the number 14255550150, adds a plus + to the front of that number, and dials +14255550150 to the Mediation Server (that is, defined in the sip.conf file as the to_lync object).

exten=>14255550150,n,Hangup

The final line on our dial plan again matches the number 14255550150 only. We can see from the n character that this is the next instruction for calls to this number.

The Hangup command instructs Asterisk to end the call. Remember that Asterisk will only reach this second line after the call created in the first line (that is, the Dial command) is finished.

Save changes to the extensions.conf file, and then reload the dial plan using the following commands:

asterisk -vvvvvvr

asterisk*CLI> dialplan reload

To view the dial plan in use, run the following command:



asterisk*CLI> dialplan show

Configuring the X-Lite Client


You can use X-Lite as a SIP soft client to connect to Asterisk. To install X-Lite, download the free version of X-Lite from http://counterpath.com/x-lite.html.

After you install it, run X-Lite and configure it by right-clicking the main panel to reach the menu. Click SIP Account Settings and fill in the relevant details of the user account with extension (for example, 1000) defined in the Asterisk sip.conf file (that is, the sip.conf file defined earlier in this chapter). The only other piece of information you need to add in the X-Lite client configuration is the IP address of your Asterisk server. In Bob’s example, his Asterisk server’s address is “192.168.100.10”.





Figure 8. Bob’s configuration of the X-Lite client

After you configure it, X-Lite automatically attempts to log on the user to Asterisk.


Troubleshooting Asterisk


During his research, Bob learned some helpful tips for trying to diagnose and troubleshoot issues.

To connect to the console of the Asterisk server, run the following command from the Linux prompt, where the number of v characters sets the verbose level and the r characters indicate a remote Asterisk console:



asterisk –vvvvvvr

To get help, run the following command:



asterisk*CLI> core show help

After you are connected to the Asterisk console, calls being processed will scroll up in the console in real time (that is, because the verbose level is set to 6). Individual instructions from the dial plan are shown in the console as they are processed in sequence and calls are routed.

This is can help you to determine whether calls are actually reaching the Asterisk server and whether they are being processed as expected.

The following command shows the SIP users and devices configured in Asterisk:



asterisk*CLI> sip show peers

You see results similar to the following:

Name/username Host Dyn Nat ACL Port Status

1000/1000 192.168.100.40 D 40108 Unmonitored

to_ocs 192.168.100.20 5060 OK (1 ms)

Note. Review the response time from the Mediation Server in the Status column. A high response time may be an indication of an issue.

To turn on the SIP debug mode, use the following command:



asterisk*CLI> sip set debug on

To debug only a single SIP user or device (called a peer), use the following command:



asterisk*CLI> sip set debug peer [peer-name]

To debug the Mediation Server only, use the following command to identify the Mediation Server as to_lync in the sip.conf file:



asterisk*CLI> sip set debug peer to_lync

To turn off SIP debugging, use the following command:



asterisk*CLI> sip set debug off

Yüklə 207,34 Kb.

Dostları ilə paylaş:
1   2   3   4   5




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə