Asterisk dialplan configuration: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
m (Pchero moved page Asterisk-dialplan to Asterisk-extensions.conf without leaving a redirect)
No edit summary
Line 51: Line 51:
<pre>
<pre>
exten => name, priority, application()
exten => name, priority, application()
</pre>
==  Pattern Matching ==
원문은 이곳<ref>https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching</ref>에서 확인할 수 있다.
패턴 매칭은 항상 "_" 기호로 시작한다. 해당 기호로 시작해야지만 Asterisk 에서 패턴 매칭을 사용한다는 것을 인식할 수 있기 때문이다.
=== X, Z, N ===
X, Z, N 은 가장 흔히 사용하는 패턴 매칭 기호이다.
* '''X'''
: X/x 대/소문자 구분이 없다. 0 ~ 9 까지의 하나의 숫자를 의미한다.
* '''Z'''
: Z/z 대/소문자 구분이 없다. 1 ~ 9 까지의 하나의 숫자를 의미한다.
* '''N'''
: N/n 대/소문자 구분이 없다. 2 ~ 9 까지의 하나의 숫자를 의미한다.
* '''Example'''
: 예제를 들어보자. 다음은 6400 부터 6499 까지 의 번호를 매칭하는 패턴이다.
<pre>
exten => _64XX,1,SayDigits(${EXTEN})
</pre>
=== Character Sets ===
만약 특정 숫자의 범위를 지정하고자 한다면, "[]" 기호안에 숫자의 범위를 입력하여 지정할 수 있다. 예를 들어, 6300 번 부터 6400 번까지의 번호를 지정하고 싶다면 어떻게 해야 할까? (_64XX, _63XX) 과 같이 두개의 번호를 지정하여 사용할 수 있다. 하지만 범위지정 방식으로 사용할 경우 (_6[34]XX) 으로 설정이 가능하다.
만약 [1-468] 과 같이 지정을 했다면, 이는 1 부터 468 까지의 숫자가 아니라, 4, 6, 8 의 숫자를 의미하는 것이다.
=== Other Special Characters ===
Within Asterisk patterns, we can also use a couple of other characters to represent ranges of numbers. The period character (.) at the end of a pattern matches one or more remaining characters. You put it at the end of a pattern when you want to match extensions of an indeterminate length. As an example, the pattern _9876. would match any number that began with 9876 and had at least one more character or digit.
The exclamation mark (!) character is similar to the period and matches zero or more remaining characters. It is used in overlap dialing to dial through Asterisk. For example, _9876! would match any number that began with 9876 including 9876, and would respond that the number was complete as soon as there was an unambiguous match.
<pre>
Asterisk treats a period or exclamation mark as the end of a pattern. If you want a period or exclamation mark in your pattern as a plain character you should put it into a character set: [.] or [!].
</pre>
</pre>



Revision as of 00:17, 17 March 2015

개요

Asterisk Dialplan 설정 법 설명.

Dialplan syntax

Asterisk 에서 Dialplan 을 설정하는 파일 이름은 extensions.conf 이다.

  • extensions.conf
    • 보통은 /etc/asterisk/extensions.conf 에 위치해 있다.
    • 하지만 소스로 설치를 하거나 다른 방법으로 설치하게 되면 다른곳에 파일이 위치할 수도 있다.
    •  ex) /usr/local/etc/asterisk, /opt/etc/asterisk 

Dialplan 은 크게 4가지 컨셉으로 구성되어 있다.

contexts, extensions, priorities, applications

Context

Context 는 쉽게 말해서 객체지향의 Class 와 비슷한 개념으로 볼 수 있다.

Context 를 생성할 때는 Context 이름을 중괄호([])로 감싸야한다. 이름에 사용할 수 있는 문자는 A-Z, a-z, 0-9, -, _ 이다.

[incoming]
  • Context 생성시 사용가능한 문자 길이는 최대 79 자 이다. (80 characters - 1 terminating null).

Context 에는 특별히 사용되는 특수 Context 두 가지가 있는데, [general] 과 [globals] 이다. [general] 섹션은 일반적인 Dialplan 설정들, [globals] 섹션에는 전역 Dialplan 설정들이 있는 Context 이다. 새로운 Context 생성시 [general], [globals], [default] 이름은 피하도록 하자. 이 외의 다른 이름은 전부 사용 가능하다.

채널을 설정할 경우(sip.conf, iax.conf, chan_dahdi.conf 등등..) 필수 입력 항목중에 context 항목이 있다. Context 는 호간의 연결 성립시, 채널이 동작하게되는 Dialplan 의 시작점이다. 즉, Asterisk 에 등록된 채널 A 가 있을 경우, 만약 A 로 전화가 걸려왔을 때, 어떤 방식으로 전화가 흘러가게끔 할 것인지를 결정하게 되는 것이다.

  • 전화(Connection)가 걸려왔을 경우 정해진 수순에 따라 전화가 흘러가게끔 하는 것, 이것이 Dialplan 이다.
  • ex) 10초동안 응답이 없을 경우 자동 IVR 연결, 10초 동안 연결이 없을 경우 휴대폰 전화로 연결 등등..

Context 사용시 주의해야 할 점은 보안이다. 정확한 방법으로 Context 을 설정한다면 정해진 사용자에게 정해진 기능을 제공할 수 있다. 하지만 엉뚱한 방법으로 Context 를 설정하게 되면, 엉뚱한 기능들이 동작할 수 있다. 게다가 Asterisk 를 위시한 많은 IP-PBX 시스템은 주요 해킹 공격 대상이 된다. 일반적인 Web 과 달리 통화요금 과금과 같이 돈이 관련된 부분이기 때문이다. 때문에 Context 와 같은 Dialplan 설정시 많은 주의를 요한다.

  • ex) 국제전화 사용

Extensions

Extensions 흔히 전화번호로도 번역이 된다. 하지만 Asterisk 에서의 Extensions 는 더 강력한 기능을 가진다.

Asterisk 에서는 각각의 Context 마다 하나 혹은 다수의 Extensions 를 가질 수 있다. 해당 Extension 이 동작할 경우(전화가 걸려온 경우), Asterisk 는 해당 Extension 에 설정된 Dialplan 을 수행하는 것이다.

Extension 설정시, exten 구문으로 시작하게 된다.

exten =>

Extension 은 세가지 구성요소들을 가진다.

  • name(or number)
  • priority
  • application

이 구성 요소들은 쉼표(,)로 구분된다.

exten => name, priority, application()

Pattern Matching

원문은 이곳<ref>https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching</ref>에서 확인할 수 있다.

패턴 매칭은 항상 "_" 기호로 시작한다. 해당 기호로 시작해야지만 Asterisk 에서 패턴 매칭을 사용한다는 것을 인식할 수 있기 때문이다.

X, Z, N

X, Z, N 은 가장 흔히 사용하는 패턴 매칭 기호이다.

  • X
X/x 대/소문자 구분이 없다. 0 ~ 9 까지의 하나의 숫자를 의미한다.
  • Z
Z/z 대/소문자 구분이 없다. 1 ~ 9 까지의 하나의 숫자를 의미한다.
  • N
N/n 대/소문자 구분이 없다. 2 ~ 9 까지의 하나의 숫자를 의미한다.
  • Example
예제를 들어보자. 다음은 6400 부터 6499 까지 의 번호를 매칭하는 패턴이다.
exten => _64XX,1,SayDigits(${EXTEN})

Character Sets

만약 특정 숫자의 범위를 지정하고자 한다면, "[]" 기호안에 숫자의 범위를 입력하여 지정할 수 있다. 예를 들어, 6300 번 부터 6400 번까지의 번호를 지정하고 싶다면 어떻게 해야 할까? (_64XX, _63XX) 과 같이 두개의 번호를 지정하여 사용할 수 있다. 하지만 범위지정 방식으로 사용할 경우 (_6[34]XX) 으로 설정이 가능하다.

만약 [1-468] 과 같이 지정을 했다면, 이는 1 부터 468 까지의 숫자가 아니라, 4, 6, 8 의 숫자를 의미하는 것이다.

Other Special Characters

Within Asterisk patterns, we can also use a couple of other characters to represent ranges of numbers. The period character (.) at the end of a pattern matches one or more remaining characters. You put it at the end of a pattern when you want to match extensions of an indeterminate length. As an example, the pattern _9876. would match any number that began with 9876 and had at least one more character or digit.

The exclamation mark (!) character is similar to the period and matches zero or more remaining characters. It is used in overlap dialing to dial through Asterisk. For example, _9876! would match any number that began with 9876 including 9876, and would respond that the number was complete as soon as there was an unambiguous match.

Asterisk treats a period or exclamation mark as the end of a pattern. If you want a period or exclamation mark in your pattern as a plain character you should put it into a character set: [.] or [!].

관련 도서

Asterisk: The Definitive Guide, 4th Edition

References

<references />