Asterisk Summary - 2

上一篇介绍了asterisk的基本特性和架构,为了搭建属于自己的call center,跟住要做的事就是配置asterisk的config。

 

基本上来讲,主要有三个配置文件一定要搞懂:iax.conf,sip.conf,extensions.conf。 iax.conf是配置iax2 client的,sip.conf是配置sip协议的,extensions.conf就是为了让sip和iax协议通信连接。由此可以看到,asterisk其实是一个网关,转换iax和sip协议。

 

sip.conf

 

sip.conf可以注册sip用户,用法如下:

;register => username:secret@host/callbackextension

;register => 1234:[email protected]

 

eg:

[general]

register => 87654321@2b_111001/111001    ; 2b_111001 is a context in bellow and 111001 is the call back extension

.....

.....

[2b_111001]

username=87654321hk
secret=xxxxxxxx
fromuser=87654321hk

context=from_sip                   ;这个context将在extension.conf中定义

 

到这里我们注册了一个87654321的sip用户,具体的用户名,你可以向你的sip provider索取。当有电话打87654321是,它将进入extensions.conf的from_sip context,并根据该context的设定来进行一步一步的处理

 

iax.conf

 

iax.conf可以注册asterisk的iax用户,用法如下:

; We can register with another IAX server to let him know where we are
; in case we have a dynamic IP address for example
;
; Register with tormenta using username marko and password secretpass
;
;register => marko:[email protected]
;
; Register joe at remote host with no password
;
;register => joe@remotehost:5656
;
; Register marko at tormenta.linux-support.net using RSA key "torkey"
;
;register => marko:[torkey]@tormenta.linux-support.net
;
; Sample Registration for iaxtel
;
; Visit http://www.iaxtel.com to register with iaxtel.  Replace "user"
; and "pass" with your username and password for iaxtel.  Incoming
; calls arrive at the "s" extension of "default" context.
;
;register => user:[email protected]
;
; Sample Registration for IAX + FWD
;
; To register using IAX with FWD, it must be enabled by visiting the URL
; http://www.fwdnet.net/index.php?section_id=112
;
; Note that you need an extension in you default context which matches
; your free world dialup number.  Please replace "FWDNumber" with your
; FWD number and "passwd" with your password.
;
;register => FWDNumber:[email protected]

请大家注意以上注册的iax用户是不属于本地asterisk的用户的,而是remote asterisk的用户,这在asterisk与asterisk之间的通信将发挥用处。

如果要在本地asterisk注册iax用户,只需要配置一个section,eg:

 

[111001]
type=friend
context=from_iax
secret=xxxxx

host=dynamic
disallow=all
allow=gsm

以上配置注册了一个111001的iax用户,可以从允许任何ip连接注册该用户。当使用该iax用户打电话是,它将执行extensions.conf的from_iax的配置。

 

extensions.conf

 

跟住最重要的就是extensions.conf文件啦,它完成iax与sip协议的转换和链接。在这个配置文件里,最重要的概念就是context啦,以下内容摘自extensions.conf的说明:

; Any category other than "General" and "Globals" represent
; extension contexts, which are collections of extensions.
;
; Extension names may be numbers, letters, or combinations
; thereof. If an extension name is prefixed by a '_'
; character, it is interpreted as a pattern rather than a
; literal.  In patterns, some characters have special meanings:
;
;   X - any digit from 0-9
;   Z - any digit from 1-9
;   N - any digit from 2-9
;   [1235-9] - any digit in the brackets (in this example, 1,2,3,5,6,7,8,9)
;   . - wildcard, matches anything remaining (e.g. _9011. matches
;       anything starting with 9011 excluding 9011 itself)
;   ! - wildcard, causes the matching process to complete as soon as
;       it can unambiguously determine that no other matches are possible
;
; For example, the extension _NXXXXXX would match normal 7 digit dialings,
; while _1NXXNXXXXXX would represent an area code plus phone number
; preceded by a one.
;
; Each step of an extension is ordered by priority, which must always start
; with 1 to be considered a valid extension.  The priority "next" or "n" means
; the previous

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值