Asterist搭建步骤

环境:

# cat /proc/version 
Linux version 2.6.18-308.el5 (mockbuild@x86-010.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Fri Jan 27 17:21:15 EST 2012

步骤:
1、下载安装文件
asterisk-11-current.tar.gz
地址:http://www.asterisk.org/downloads
http://downloads.asterisk.org/pub/telephony/asterisk/
相关解释:
Asterisk Downloads
Download the currently supported versions of Asterisk and various Asterisk-related open source projects.
Asterisk Communications Framework • AsteriskNOW Software PBX • DAHDI • LIBPRI

Asterisk Communications Framework
Asterisk is an open source toolkit for building communications applications. For a more detailed explanation, check out the Get Started section.  
For more information on how to use Asterisk, see the Configuration and Operation section of the wiki.
 
What is LIBPRI?
LIBPRI is an open source library that encapsulates the protocols used to communicate over ISDN Primary Rate Interfaces (T1, E1, J1). 
LIBPRI is a dependency for Asterisk and DAHDI if PRI signaling is used.

http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
 
What is DAHDI?
DAHDI (Digium/Asterisk Hardware Device Interface) is the open source device interface technology used to control Digium and other legacy telephony interface cards.

DAHDI Linux / DAHDI Tools
DAHDI Linux is the open source device driver framework used to interface Asterisk with telephony hardware.
DAHDI Tools is a package of utilities for managing and monitoring DAHDI devices.  
The download on this page provides a combined package of the latest DAHDI Linux with the latest DAHDI Tools.
http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
 
2、安装过程
asterisk-11-current.tar.gz放到目录/opt/asterisk/(这个路径可以随意指定,只要空间足够即可)下
解压缩:tar –xzvf asterisk-11-current.tar.gz
进行源文件目录asterisk-11.5.1
执行下列命令
./configure
执行结果的最后几行:
 
 
make 
执行结果的最后几行:
tline/libedit.a  -> asterisk
Building Documentation For: channels pbx apps codecs formats cdr cel bridges funcs tests main res addons 
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +
 +-------------------------------------------+
 
make install 
执行结果的最后几行:
for x in images/*.jpg; do \
                /usr/bin/install -c -m 644 $x "/var/lib/asterisk/images" ; \
        done
make -C sounds install
make[1]: Entering directory `/opt/drivers2/asterisk-11.5.1/sounds'
make[1]: Leaving directory `/opt/drivers2/asterisk-11.5.1/sounds'
 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 +                make samples               +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+
 
make samples
执行结果的最后几行:
                /usr/bin/install -c -m 644 "/etc/asterisk/asterisk.conf.tmp" "/etc/asterisk/asterisk.conf" ; \
                rm -f "/etc/asterisk/asterisk.conf.tmp" ; \
        fi ; \
        /usr/bin/install -c -d "/var/spool/asterisk/voicemail/default/1234/INBOX"
Updating asterisk.conf
build_tools/make_sample_voicemail "//var/lib/asterisk" "//var/spool/asterisk"
Installing file phoneprov/000000000000.cfg
Installing file phoneprov/000000000000-directory.xml
Installing file phoneprov/000000000000-phone.cfg
Installing file phoneprov/polycom_line.xml
Installing file phoneprov/polycom.xml
Installing file phoneprov/snom-mac.xml
 
make config
 
3、安装完成后asterisk进程也启起来了
/bin/sh /usr/sbin/safe_asterisk
 
4、修改sip.conf和extendsion.conf文件
 
sip.conf的最下方增加小节(添加用户,本例增加两个用户9001和9002):
[9001]
type=friend 
username=9001
secret=9001
host=dynamic
context=demo
disallow=all
allow=alaw;这个地方需要注意一定要和客户端(eyeBeam或X-Lite)保持一致,此例都设为alaw
dtmfmode=rfc2833 
canreinvite=no
maxcallbitrate=384
[9002] 
type=friend 
username=9002
secret=9002
host=dynamic 
context=demo 
disallow=all 
allow=alaw
dtmfmode=rfc2833 
canreinvite=no 
maxcallbitrate=384
 
 
extensions.conf的最下面增加一个小节:
[demo]//上面用到
exten => _9.,1,Dial(SIP/${EXTEN},20,r)
说明:
(1)规则就一条,使得9001 和9002 可以互相拨打。当中的格式简要讲述一下。更多的请参考
Asterisk 的手册,这里不详细展开。
(2)开头部分“exten =>”表示,也可以用“exten =”表示。并且在一个小节内可以定义多
条exten 语句。
(3)之后的“_9”表示匹配上所有“9”开头的拨号,“.”表示不限制长度的任意字符。
(4)然后的“1”表示优先级,我喜欢称作为“执行次序”。“1”表示第一步执行的意思,如果
后续还需要执行其他动作的话,可以继续写多条exten 语句,并且用递增执行次序依次设计下去。
(5)接着的“Dail()”表示“执行动作”,这里是表示拨号的执行动作。更规范的说,这个是
APP 应用程序。
(6)括号当中又分成3 个部分。第一个SIP 表示拨号动作中拨向的通道是SIP 协议的通道。$
{EXTEN}则一个变量,其值就是用户实际拨打的号码。如果你拨打9001 那么${EXTEN}的值就是
9001。
(7)括号内的“20”,表示等待时间单位秒,如果有多个执行次序,即一组拨号规则的话,如果
过了20 秒,就跳跃执行次序(跳跃的幅度是101 个优先级)。
(最后的“r”表示强行播放振铃。在拨打对方等待对方接通的时候,就能听到回振铃音。
 
4、进行asterist的控制台重新加载文件sip.conf,extensions.conf
asterisk –gcrvvvvvv 
直接启动后连接到Asterisk控制台 注意,启动脚本是“safe_asterisk”,当启动起来后察看进程也能看到这个名字的进程。
IVRServer*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
 
 
控制台相关命令:
; Useful CLI commands to check peers/users:
;   sip show peers               Show all SIP peers (including friends)
;   sip show registry            Show status of hosts we register with
;
;   sip set debug on             Show all SIP messages
;
;   sip reload                   Reload configuration file
;   sip show settings            Show the current channel configuration
 
5、然后使用eyeBeam或X-Lite注册sip,然后拨打电话即可
如果编码客户端和服务器设置的不一致,就会报错:
IVRServer*CLI> 
  == Using SIP RTP CoS mark 5
[Sep  4 16:52:47] NOTICE[2680][C-00000001]: chan_sip.c:10523 process_sdp: No compatible codecs, not accepting this offer!
  == Using SIP RTP CoS mark 5
    -- Executing [9002@demo:1] Dial("SIP/9001-00000002", "SIP/9002,20,r") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/9002
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'SIP/9001-00000002' status is 'CHANUNAVAIL'
 
 
解决办法就是将编码设置一致,本例中都设为G.711Alaw语音编解码
 




 
 
 

posted @ 2013-09-04 17:59  沧海一滴  阅读(1035)  评论(0编辑  收藏  举报