Asterisk Setup

From MetaWiki

Jump to: navigation, search

Asterisk - Configuring as a SIP PBX

Introduction

Asterisk is an open source suite of PBX software which runs on Linux and can operate under MetaSwitch as a broadly-featured SIP PBX.


This article includes:
•	                     general installation and config information
•	                     configuring Asterisk with MetaSwitch
•	                     configuring an extension and an IAD to use this line
•	                     outgoing calls, including prefix dialling
•	                     incoming calls, including DID ranges
•	                     troubleshooting and common problems

Used throughout are NPA = 504, desired extension = 201, password = password, CA = itchyandscratchy, and server_IP represents the IP address of the Asterisk server. Change as desired.


General Information

Guidelines on installing Asterisk with the useful (but occasionally problematic) Asterisk Management Portal (AMP) web interface are available at:

           http://asteriskathome.sourceforge.net/handbook/

Installation should simply follow the below steps. • download the ISO image from http://sourceforge.net/projects/asteriskathome/ • burn onto CD, and boot from this CD on an unused workstation. All data on the selected hard drive will be deleted. The installation should proceed automatically. Configuration can now proceed either via the AMP interface by opening the server IP address in a web browser and following the “Asterisk Management Portal” link, or directly within an SSH session.

Using AMP, changes must be explicitly loaded in Maintenance -> Config Edit -> Re-Read Configs. The "Click Here To Apply Your Changes" link appears to have no effect.

It is recommended that all changes are made via the command line, as AMP has occasionally been found to have unpredictable and detrimental results. To do so, edit the config files in /etc/asterisk and execute the command asterisk.reload to update the server settings. However, for ease of use and reference, the AMP interface will be referenced throughout this article.

Note that changes to the *_additional.conf files may be overwritten by AMP if this is used subsequently, and AMP appears to maintain its own state of the .conf files so settings may be reverted to their values before changes were made at the command line!

At the time of writing, an Asterisk PBX is configured with the below configuration. • IP: 10.248.92.1 • DN: 504 203 0170 (itchy) • DN: 867 203 0171 (tippet) • SSH login: root/asterisk

Configuring Asterisk on MetaSwitch

First, create a Media Gateway Model (Call Agent -> Controlled Networks -> Remote Media Gateway Models).

     Category = SIP
     Restricted direct media = checked
     Cannot play ringback = checked
     Does not support out of band DTMF = checked

Now create a Configured SIP Binding (Call Agent -> Controlled Networks -> Configured SIP Bindings).

     Usage = Subscriber
     Use DN for identification = True
     SIP authentication required = False.
     SIP domain name = <empty>
     Contact IP address = server_IP
     Contact IP port = 5060
     Media Gateway Model = our_MGM (created above)

Finally, add a PBX subscriber for Asterisk (Call Agent -> Subscriber Configuration -> PBXs) with the DN you require, and add a PBX Line beneath this using the previously created SIP binding. Apply your changes and you should now be ready to configure incoming and outgoing calls.


Configuring MetaSwitch on Asterisk

Create a new SIP trunk in AMP -> Trunks -> Add SIP Trunk, with an Outgoing Dial Rule of the form:

           1504+NXXXXXX

Outgoing settings:

           Trunk name: itchyandscratchy

     host=itchyandscratchy.datcon.co.uk
     type=friend
     context=from-pstn
     username=5042030170 (your PBX DN including NPA)
     fromuser=5042030170

Incoming settings can be left blank, as outgoing and incoming calls are to be handled by the same host with authentication done purely by address. Register string must also remain empty.



Adding An Extension

To add an extension to Asterisk, either • go to AMP -> Extensions, select a number add a password to the default configuration, or • add an entry to sip_additional.conf as below.

           username=201
           type=friend
           secret=password
           port=5060
           host=dynamic
           context=from-internal
           callerid="" <201>

Configuring an IAD to use this extension is a matter of configuring the device to use the extension as its contact and authorization username (201 in this case), with the server IP as the SIP server and registration domain. Two example setups are given below.

           X-Lite
           In X-Lite, add a SIP proxy with all default settings except the below.

           Username: 201
           Authorization User: 201
           Password: password
           Domain/realm: server_IP
           SIP proxy: server_IP

Registration should proceed successfully. Check in X-Lite Diagnostic Log and Asterisk's log files (/var/log/asterisk/full by default) for registration confirmation.

           Vood IAD
           In the SIP section of the Vood web admin interface, set:

                       Registration: On
           Reg. Server: server_IP
           Reg. Interval: 3600
           Outbound Proxy: server_IP
           Username A: 201
           Password A: password

           Save changes. Now, hidden in the Dial Plan section, change the following setting:

           Phone Number A: 201

           Save changes again, and Activate.





Outgoing Calls

Add an outbound route in AMP: Setup -> Outbound Routing -> Add Route. Leave the password field blank, and set it to use the above trunk, with dial patterns set to change standard 1+10D, 10D and 7D numbers.

     1NXXNXXXXXX
     NXXNXXXXXX
     NXXXXXX

Route matching is done by comparing the dialled number to the patterns listed in each route, and using the first route to match. No other routes should exist at present, and so this trunk will be used for any outgoing calls matching the above patterns.

           Additional Trunks and Prefix Dialling

Asterisk supports multiple outgoing routes selected by specific pattern matching. To add an additional outgoing route in AMP: • add a new trunk using the same settings as in "Configuring MetaSwitch on Asterisk" but with the corresponding username, fromuser and host. • in Outbound Routing, add a new unpassworded route with dial patterns corresponding to the specific NPAs that are to be used by this route, eg:

           1867NXXXXXX
           867NXXXXXX 

• add the new trunk to this route • move the new route above the original (default) route, so that it will be selected for all calls using the above dial patterns • re-read the configuration files


Incoming Calls

To set the default destination extension for calls to Asterisk's PSTN number: • create a new extension in AMP -> Extensions or extensions_additional.conf, detailed in Adding An Extension (above). Now either: • select the appropriate extension to forward PSTN calls to, in AMP -> Incoming Calls, or • set the INCOMING variable in extensions_additional.conf to EXT-201

Incoming DID calls A DID range can be created on MetaSwitch to assign external numbers to internal extensions on an Asterisk PBX. To do so: • in the EMS entry for the PBX created earlier, go to Direct Inward Calling and add a sub-component of type "DID Range", with an appropriate size and DN range, and codes starting at (say) 200. • Set the following properties of the PBX element. PSTN_extension is the extension to which calls from the PSTN will now be forwarded.

           Default number of DID digits = 3
           Send DID sequence for Listed DN = True
           DNIS used in DID sequence for Listed DN = 001

• In AMP -> DID Routes, add a route for PSTN calls, which will override the configuration in "Incoming PSTN Calls":

           DID Number = 001
           Extension = 201

• Add any further DID routes, over the DID code range specified within the EMS. One is required for each external DID number that is to be routed to an extension.


Troubleshooting and Common Problems

The best source of Asterisk diags is the full log output, /var/log/asterisk/full. This can be viewed via the web interface at AMP -> Maintenance -> Log Files -> Asterisk Full Debug Log.

Call logs can also be viewed in AMP -> Reports.

Several persistent problems were encountered when configuring the current system.

• Delayed hangups and lost connections: experienced when two network interfaces were present on the test server. Resolved by disabling one with 'ifconfig eth0 down'. • Configuration changes reverting to previous settings: the AMP interface caches previous settings which can overwrite changes made at the command line. Carefully ensure that the settings displayed in AMP correspond to the actual state of the config files. • "Enter password" on outgoing calls: check that all outgoing routes are unpassworded by opening extensions_additional.conf and inspecting the third parameter to the dialout-trunk macro. AMP sometimes does not display a route password even when one is set. • "407 Proxy Authentication Required" sent from Asterisk to MetaSwitch: ensure that host is set correctly in the MS trunk, with insecure=very and no secret parameter present. • "403 From: URI not recognised" sent from MetaSwitch from Asterisk: ensure that Use DN for identification = True and SIP authentication required = False in EMS -> Call Agent -> Controlled Networks -> Configured SIP Bindings -> Asterisk SIP binding, and that fromuser=your_DN in the MS trunk on Asterisk.

Personal tools