ซื้อสินค้า VoIP คลิกไปที่ https://www.lazada.co.th/shop/adventek/

Tested on Debian 8 + Asterisk 11

1. คอนฟิกไฟล์ของ Asterisk จะอยู่ที่ /etc/asterisk โดยมีคอนฟิกไฟล์เบื้องต้น ดังนี้
     - /etc/dahdi/system.conf   เป็นคอนฟิกไฟล์เกี่ยวกับ driver ของการ์ดต่างๆ เช่น
          TDM400P, X100P เป็นต้น (แทน /etc/zaptel.conf)
     - /etc/asterisk/chan_dahdi.conf   เป็นคอนฟิกไฟล์ของ Asterisk ที่กำหนดพารามิเตอร์
          ต่างๆ ให้กับ channels ของการ์ดที่ติดตั้ง (แทน /etc/zapata.conf)
     - /etc/asterisk/sip.conf   เป็นคอนฟิกไฟล์สำหรับ sip protocol
     - /etc/asterisk/iax.conf   เป็นคอนฟิกไฟล์สำหรับ iax protocol
     - /etc/asterisk/extensions.conf เป็นคอนฟิกไฟล์ที่กำหนด dial plan ทำให้ระบบ
          ทำงานตาม flow ที่ต้องการ
     - /etc/asterisk/voicemail.conf   เป็นคอนฟิกไฟล์ที่กำหนด voicemail

     เนื่องจากระบบที่เราติดตั้งในตอนที่ 2 ไม่มีการ์ดใดๆ (TDM400P, X100P etc.) 
     เลย ดังนั้นเราไม่จำเป็นต้องคอนฟิก /etc/dahdi/system.conf และ /etc/asterisk/chan_dahdi.conf
     เราจะคอนฟิก 3 ไฟล์ คือ
          - /etc/asterisk/sip.conf
          - /etc/asterisk/extensions.conf
          - /etc/asterisk/voicemail.conf

2. ก่อนลงมือให้ backup ไฟล์เดิมไว้ก่อน
     #cd /etc/asterisk                    ; ไปที่ directory ที่ต้องการ
     #mv sip.conf sip.conf.bak        ; เปลี่ยนชื่อไฟล์ต้นฉบับ
     #touch sip.conf                      ; สร้างไฟล์ใหม่ ขณะนี้ยังเป็นไฟล์ที่ว่างเปล่า
     แล้ว edit ไฟล์ sip.conf ดังนี้

[general]

register=adventekvoip:This email address is being protected from spambots. You need JavaScript enabled to view it.     ; Register to provider
port=5060                                                         ; Port to bind to (SIP is 5060)
bindaddr=0.0.0.0                                               ; Address to bind to (all addresses on machine)
allow=all                                                           ; Allow all codecs
match_auth_username=yes

[voip]                                         ; This is for SIP trunk

defaultuser=adventekvoip            ; Username that you get from provider
type=friend
secret=xxxxxxx                           ; Password
nat=force_rport,comedia
host=77.72.174.128
fromuser=adventekvoip                ; Username that you get from provider
fromdomain=77.72.174.128          ; SIP server
dtmfmode=rfc2833
disallow=all
defaultexpirey=20
canreinvite=no
qualify=yes
allow=g729
allow=ulaw
allow=alaw

[2000]                                 ; This is our extension number

type=friend                          ; This device takes and makes calls
defaultuser=2000                  ; Username on device

qualify=yes
secret=1234                         ; Password for device
host=dynamic                      
context=from-sip                 
mailbox=100@default            ; Define voicemail for extension 2000

[2001]                                  ; Same patterm as of extension 2000

type=friend
defaultuser=2001

qualify=yes
secret=1234
host=dynamic
context=from-sip
mailbox=101@default

3. edit /etc/asterisk/extensions.conf ดังนี้ (อย่าลืม backup ไฟล์ต้นฉบับ)

[general]

static=yes            ; These two lines prevent the command-line interface
writeprotect=yes   ; from overwriting the config file. Leave them here.

[from-sip]

;
; If the number dialed by the calling party was "2000", then
; Dial the user "2000" via the SIP channel driver. Let the number
; ring for 20 seconds, and if no answer, proceed to priority 2.
;

exten => 2000,1,Dial(SIP/2000,20)

exten => 2000,2,Voicemail(100@default)
exten => 2000,3,PlayBack(vm-goodbye)
exten => 2000,4,Hangup

;
; Now, what if the number dialed was "2001"?
;

exten => 2001,1,Dial(SIP/2001,20)
exten => 2001,2,Voicemail(101@default)
exten => 2001,3,PlayBack(vm-goodbye)
exten => 2001,4,Hangup

;
; Define a way so that users can dial a number to reach
; voicemail. Call the VoicemailMain application with the
; number of the caller already passed as a variable, so
; all the user needs to do is type in the password.
;

exten => 2999,1,VoicemailMain()

;
; According to SIP in sip.conf - sip outbound to mm
;

exten => _0Z.,1,Dial(SIP/voip/${EXTEN},30)     ; Dial fixed or mobile phone
exten => _0Z.,2,Hangup                                  ; in Thailand
                                                       

4. edit /etc/asterisk/voicemail.conf ดังนี้ (อย่าลืม backup ไฟล์ต้นฉบับ)

[general]

format=wav|gsm

;
; format: password, name, email address for attached voicemail msgs
;

[default]
100 => 1234,Vitaya P, This email address is being protected from spambots. You need JavaScript enabled to view it.
101 => 1234,Vitaya P, This email address is being protected from spambots. You need JavaScript enabled to view it.

5. หลังจากคอนฟิกไฟล์เรียบร้อยแล้วให้ reload Asterisk ดังนี้

เข้าสู่ Asterisk CLI interface

root@debian:/etc/asterisk# asterisk -rvvv

Connected to Asterisk 11.13.1~dfsg-2+deb8u2 currently running on debian (pid = 662)
debian*CLI>

แล้วใช้คำสั่ง reload ดังนี้

debian*CLI>reload

ถึงตอนนี้ Asterisk ก็ run ด้วยคอนฟิกใหม่เรียบร้อยแล้ว ให้คอนฟิก softphone
2 เครื่อง เบอร์ 2000 และ 2001 ต่อเข้าระบบ Asterisk แล้วเริ่มทดสอบได้เลย