[olive] sip trunk test

Sip trunk 관련 테스트 정리.

register 설정을 했다면, sip peer 설정시, 별도의 defaultuser 항목과 secret 항목은 설정하지 않아도 된다. 하지만 fromuser와 from domain 항목은 설정해야 한다. 하지만 모든 경우에 적용되는 것이 아니라, 이는 sip provider 에서 어떻게 지원하는지에 따른 부분이기 때문에 그때 그때 마다 설정을 맞춰야 한다.

가장 좋은 방법은 register 설정과 peer 설정 모두에 username 과 password 설정을 전부 하는 것.

Asterisk – sip.conf

/etc/asterisk/sip.conf 파일은 Asterisk 에서 sip 채널을 설정하는 파일이다. 즉, Asterisk 에서 관리하는 SIP 단말기 정보를 입력하는 설정파일이다.

/etc/asterisk/sip.conf 파일 예제

[general]
context = unauthenticated               ; default context for incoming calls
allowguest = no                 ; disable unauthenticated calls
srvlookup = no                  ; disable DNS SRV record lookup on outbound calls
                                ;   (unless you have a reliable DNS connection,
                                ;   in which case yes)
udpbindaddr = 0.0.0.0           ; listen for UDP requests on all interfaces
port = 5060
tcpenable = no                  ; disable TCP support
register => 123123123:123123123@192.168.0.1  ; External trunk register information
;tlsenable = yes
;tlsbindaddr = ::

[teset_phone_ibk87ns4gj]
type = friend
host = dynamic
secret = tb9hibvp9c
context = demo

[messagewaiting](!)             ; a template to handle the settings common
                                ; to all mailboxes
type=peer
subscribecontext = voicemailbox ; the dialplan context on the voicemail server
context = voicemailbox          ; the dialplan context on the voicemail server
host = 192.168.200.10           ; ip address of presence server

[office-phone](!)       ; create a template for our devices
type = friend           ;   the channel driver will match on username first,
                        ;   IP second
context = LocalSets     ; this is where calls from the device will enter
                        ; the dialplan
host = dynamic          ; the device will register with asterisk
nat = force_rport,comedia       ; assume device is behind NAT
                        ;   *** NAT stands for Network Address Translation,
                        ;   which allows multiple internal devices to share an
                        ;   external IP address.
dtmfmode = auto ; accept touch-tone from the devices, negotiated
                ; automatically
disallow = all  ; reset which voice codec this device will accept or offer
allow = g722    ; audio codecs to accept from, and request to, the device
allow = ulaw    ; in the order we prefer

; define a device name and use the office-phone template
[0000FFFF0001](office-phone)
secret = helloworld      ; a unique password for this device --
                        ; DON'T USE THE PASSWORD WE'VE USED IN THIS EXAMPLE!

; define another device name using the same template
[0000FFFF0002](office-phone)
secret = helloworld ; a unique password for this device --
                        ; DON'T USE THE PASSWORD WE'VE USED IN THIS EXAMPLE!

[0000FFFF0003](office-phone)
secret = helloworld   ; DON'T USE THE PASSWORD WE'VE USED IN THIS EXAMPLE!
allow = gsm

[0000FFF0004](messagewaiting)   ; this will need to match the subsriber
                                ; name on the proxy
mailbox = 0000FFFF0004@DIR1     ; must be in the form mailbox@mailboxcontext
defaultuser = 0000FFFF0004      ; this will need to match the subscriber
                                ; name on the proxy

[general] Section

가장 기본적인 섹션이며, Default 값들을 설정하는 곳이다.
모든 채널 모듈 설정시, 기본적으로 설정의 제일 앞부분에 [general] 섹션을 포함한다고 생각하면 되며,  [general] 섹션의 이름은 바뀌어서는 안된다.
[general] 섹션에서는 기본적인 프로토콜 연결 방식과 Default Parameter 들을 설정할 수 있다.

context=unauthenticated         ; default context for incoming calls

위의 예제에서는 default context 로 unauthenticated 를 설정했다. 이것은, 별도로 context를 설정하지 않은 sip 채널들에 대해서는 unauthenticated 방식으로 처리하겠다는 뜻이다.
참고로 unauthenticated 에 관한 설정 내용은 /etc/asterisk/extension.conf 에 설정할 되어있어야 한다.

allowguest=no                   ; disable unauthenticated calls

Guest call 허용 여부. 명시적으로 계정을 가진 사람들만 통화가 가능하도록 할지 말지에 관한 옵션이다. No 로 설정시, sip.conf 에 등록된 계정만 통화가 가능하게 된다.

srvlookup=no                    ; disable DNS SRV record lookup on outbound calls
;   (unless you have a reliable DNS connection,
;   in which case yes)

DNS lookup 설정 여부

udpbindaddr=0.0.0.0             ; listen for UDP requests on all interfaces

NIC 가 여러개 있을 경우, 어느 IP 주소로 Listen 소켓을 열어둘지를 설정하는 옵션. 0.0.0.0 으로 설정할 경우, 사용가능한 모든 IP 주소로 Listen Port 를 열어놓는다.
Asterisk 의 NIC 사용방식은 all-or-one 방식이다. 즉, 하나를 사용하거나 모두를 사용하거나 이다.
예를 들어, 만약 NIC가 3개가 있을 경우 이중 2개만 사용할 수는 없다는 것이다.

tcpenable=no                    ; disable TCP support

TCP 사용 여부를 설정한다.

[office-phone](!) 섹션

 [office-phone](!)       ; create a template for our devices

템플릿 섹션 설정. [office-phone] 뒤에 붙은 (!) 표시는 이 섹션은 템플릿로 사용된다는 것을 가리킨다. 템플릿으로 만들어진 섹션은 추후 device 추가시 적용하여 사용가능 하다.

type=friend             ;   the channel driver will match on username first,
;   IP second

peer, user, friend 로 설정가능하다. 각각의 의미는 다음과 같다.
peer : Source IP 와 Port number 로 요청을 확인한다.
user : SIP Request 에서 From header 안의 username 으로 요청을 확인한다. sip.conf 에서 설정된 내용중에서 일치하는 device 정보를 찾는다.
friend : peer/user 두가지 방식 모두 사용해서 요청을 확인한다.

host=dynamic            ; the device will register with asterisk

연결되는 SIP 장비의 IP 주소를 설정한다. dynamic 또는 직접 IP 주소 입력 방식이 있는데, 만약 SIP 단말기가 고정 IP 가 아니라면 dynamic 으로 설정해야 한다.

 nat=force_rport,comedia ; assume device is behind NAT
;   *** NAT stands for Network Address Translation,
;   which allows multiple internal devices to share an
;   external IP address.

단말장치가 NAT 안쪽에 있는 경우 설정한다.

dtmfmode=auto   ; accept touch-tone from the devices, negotiated
; automatically

Asterisk 가 DTMF(touch-tone)을 보낼 때, 어떤 형식의 Dial tone을 보낼지 설정한다. info, inband, rfc2833, auto 중 한가지를 설정할 수 있다. info 설정은 SIP INFO method 를 사용하고, inband는 inband audio tone 을 전달한다. 그리고 rfc2833은 RFC-2833 에서 제정된 out-of-band method 를 전달한다.

disallow=all    ; reset which voice codec this device will accept or offer
allow=g722      ; audio codecs to accept from, and request to, the device
allow=ulaw      ; in the order we prefer
allow=alaw

사용/불가능 audio codec 을 지정한다. 제일 첫라인 disallow=all  은 general 에서 이미 설정된 코덱 내용들을 모두 버린다른 뜻이며, 바로 아랫 줄 부터 어떤 코덱들을 사용할 것인지 하나씩 설정한다.
ulaw의 경우, Canada 와 US를 제외한 거의 대부분의 국가에서 사용하며, alaw 는 주로 Canada 와 US 에서 사용한다.

[0000FFFF0003](office-phone) 섹션

[0000FFFF0003](office-phone)

장비 이름(username) 0000FFFF0003 과 office-phone 템플릿을 사용한다고 선언한 부분이다.

secret=helloworld     ; DON’T USE THE PASSWORD WE’VE USED IN THIS EXAMPLE!

password 를 설정한다.