Lab 2 Cấu hình Extension và Softphone

root

Leader IT/Architect
Dec 31, 2012
1,153
72
48
Như ở bài Lab trước mình đã giới thiệu các bạn cách cài đặt tổng đài Asterisk. Bây giờ mình sẽ hướng dẫn các bạn tạo các extension (hiểu nôm na là các số điện thoại nội bộ trong 1 cty).
Sau đó mình sẽ hướng dẫn các bạn sử dụng các softphone để sử dụng các số nội bộ để gọi cho nhau. Vì nhà nghèo ko có tiền mua điện thoại nên mọi người dùng tạm softphone nhé. Nó còn xịn hơn cả Analog phone :D

Các bạn khởi động tổng đài Asterisk và sử dụng trình duyệt web login vào tổng đài để thực hiện cấu hình nhé. http://192.168.80.135 như bài trước mình có hướng dẫn.
Và đây là thông tin trạng thái hệ thống tổng đài Asterisk. Giao diện menu Server Status cho biết trạng thái tổng đài Asterisk đang hoạt động

2014-12-10_223141.jpg

- Tiếp theo là các bạn vào mục PBX ->PBX Setting -> Extension để thực hiện tạo các Extensions nhé

2014-12-10_223346.jpg

- Đầu tiên mình sẽ add thêm 1 Extension có số là 1001 sử dụng giao thức SIP

2014-12-10_223624.jpg


- Các bạn thực hiện cấu hình tên và password cho số extension 1001 nhé


2014-12-10_223929.jpg

- Tiếp theo các bạn thực hiện add thêm 1 extension 2002 sử dụng IAX2 nhé

2014-12-10_224239.jpg

- Đặt tên và pass cho extension 1002

2014-12-10_224407.jpg

- Sau khi config xong các bạn phải nhấp vào apply để nó áp phê những gì mình đã cấu hình nãy giờ

2014-12-10_224532.jpg


- Các bạn thực hiện tương tự add thêm 1 extension 1002 chuẩn SIP nhé

2014-12-10_224533.jpg
 
2. Cài đặt Softphone và đăng ký Extension
- Các bạn download các softphone sau nhé
- các bạn tiến hành cài đặt softphone 3CXPhone4 nhé


- Tiến hành đăng ký Extension 1001


- mình đã đăng ký Extension 1001 thành công


- Sau khi download Zoiper_Free xong các bạn tiến hành cài softphone này luôn nhé


- Tiến hành cấu hình add Extension 1002 cho softphone này



- Các bạn khai báo IP của tổng đài, username và password mà bạn đã cấu hình trên tổng đài ở trên


- Các bạn nhấn Register để đăng ký nhé


- Và mình đã đăng ký thành công cho số Extension 1002 này

 
- Bây giờ mình sẽ sử dụng số 1002 gọi đến số 1001 xem nhé


- Trên softphone extension 1001 các bạn thấy số 1002 đang gọi đến là thành công


- Màn hình softphone extension 1002 khi kết nối với 1001 thành công


3. Các file cấu hình trên Server
- Để thực hiện 1 cuộc gọi thông qua hệ thống tổng đài Asterisk các bạn cần phải cấu hình những file sau
  • Các số điện thoại Extension trong file cấu hình: sip.conf và iax.conf (Trong các file này sẽ chia ra các section. Mỗi section gọi là ngữ cảnh và đặt đặt trong dấu [], section chung [general] là phần cấu hình các thông số chung cho SIP và IAX)
  • Sau đó các bạn phải cấu hình Dial plane trong file extension.conf
- Các bạn có thể xem các file cấu hình này bằng cách sau




- Dial plane: Mặc định các extension có context name "from-internal" ( Các bạn có thể thay đổi ngữ cảnh này tùy bạn)




- Ví dụ như file extension của mình
Code:
[I][COLOR=#00ff00]//............. đã bỏ bớt vài chục dòng :)[/COLOR][/I]
;
; ############################################################################
; Inbound Contexts [from]
; ############################################################################

[B][COLOR=#ff0000][from-internal][/COLOR][/B]
include => from-internal-xfer
include => bad-number


;------------------------------------------------------------------------
; [macro-setmusic]
;------------------------------------------------------------------------
; CONTEXT:      macro-setmusic
; PURPOSE:      to turn off moh on routes where it is not desired
;
;------------------------------------------------------------------------
[macro-setmusic]
exten => s,1,NoOp(Setting Outbound Route MoH To: ${ARG1})
exten => s,2,SetMusicOnHold(${ARG1})
;------------------------------------------------------------------------


; ##########################################
; ## Ring Groups with Confirmation macros ##
; ##########################################
; Used by followme and ringgroups


;------------------------------------------------------------------------
; [macro-dial-confirm]
;------------------------------------------------------------------------
; This has now been incorporated into dialparties. It still only works with ringall
; and ringall-prim strategies. Have not investigated why it doesn't work with
; hunt and memory hunt.
;
;------------------------------------------------------------------------
[macro-dial-confirm]
; This was written to make it easy to use macro-dial-confirm instead of macro-dial in generated dialplans.
; This takes the same parameters, with an additional parameter of the ring group Number
; ARG1 is the timeout
; ARG2 is the DIAL_OPTIONS
; ARG3 is a list of xtns to call - 203-222-240-123123123#-211
; ARG4 is the ring group number


; This sets a unique value to indicate that the channel is ringing. This is used for warning slow
; users that the call has already been picked up.
;
exten => s,1,Set(DB(RG/${ARG4}/${CHANNEL})=RINGING)


; We need to keep that channel variable, because it'll change when we do this dial, so set it to
; fallthrough to every sibling.
;
exten => s,n,Set(__UNIQCHAN=${CHANNEL})


; The calling ringgroup should have set RingGroupMethod appropriately. We need to set two
; additional parameters:
;
; USE_CONFIRMATION, RINGGROUP_INDEX
;
; These are passed to inform dialparties to place external calls through the [grps] context
;
exten => s,n,Set(USE_CONFIRMATION=TRUE)
exten => s,n,Set(RINGGROUP_INDEX=${ARG4})
exten => s,n,Set(ARG4=) ; otherwise it gets passed to dialparties.agi which processes it (prob bug) 


exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3})


; delete the variable, if we are here, we are done trying to dial and it may have been left around
;
exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL})
exten => s,n,Set(USE_CONFIRMATION=)
exten => s,n,Set(RINGGROUP_INDEX=)
;------------------------------------------------------------------------




;------------------------------------------------------------------------
; [ext-local-confirm]
;------------------------------------------------------------------------
; If call confirm is being used in a ringgroup, then calls that do not require confirmation are sent
; to this extension instead of straight to the device.
;
; The sole purpose of sending them here is to make sure we run Macro(auto-confirm) if this
; extension answers the line. This takes care of clearing the database key that is used to inform
; other potential late comers that the extension has been answered by someone else.
;
; ALERT_INFO is deprecated in Asterisk 1.4 but still used throughout the FreePBX dialplan and
; usually set by dialparties.agi. This allows inheritance. Since no dialparties.agi here, set the
; header if it is set.
;
;------------------------------------------------------------------------
[ext-local-confirm]
exten => _LC-.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX})
exten => _LC-.,n,GotoIf($["x${ALERT_INFO}"="x"]?godial)
exten => _LC-.,n,SIPAddHeader(Alert-Info: ${ALERT_INFO})
exten => _LC-.,n(godial),dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS})


;------------------------------------------------------------------------
; [findmefollow-ringallv2]
;------------------------------------------------------------------------
; This context, to be included in from-internal, implements the PreRing part of findmefollow
; as well as the GroupRing part. It also communicates between the two so that if DND is set
; on the primary extension, and mastermode is enabled, then the other extensions will not ring
;
;------------------------------------------------------------------------
[findmefollow-ringallv2]
exten => _FMPR-.,1,Noop(In FMPR ${FMGRP} with ${EXTEN:5})
exten => _FMPR-.,n,Set(RingGroupMethod=)
exten => _FMPR-.,n,Set(USE_CONFIRMATION=)
exten => _FMPR-.,n,Set(RINGGROUP_INDEX=)
exten => _FMPR-.,n,Macro(simple-dial,${EXTEN:5},${FMREALPRERING})
exten => _FMPR-.,n,GotoIf($["${DIALSTATUS}" != "BUSY"]?nodnd)
exten => _FMPR-.,n,Set(DB(FM/DND/${FMGRP}/${FMUNIQUE})=DND)
exten => _FMPR-.,n(nodnd),Noop(Ending FMPR ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
exten => _FMPR-.,n,Hangup()


exten => _FMGL-.,1,Noop(In FMGL ${FMGRP} with ${EXTEN:5})
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(1)
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(1)
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,Wait(${FMPRERING})
exten => _FMGL-.,n,GotoIf($["${DB(FM/DND/${FMGRP}/${FMUNIQUE})}" = "DND"]?dodnd)
exten => _FMGL-.,n,DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
exten => _FMGL-.,n(dodial),Macro(dial,${FMGRPTIME},${DIAL_OPTIONS},${EXTEN:5})
exten => _FMGL-.,n,Noop(Ending FMGL ${FMGRP} with ${EXTEN:5} and dialstatus ${DIALSTATUS})
exten => _FMGL-.,n,Hangup()
exten => _FMGL-.,n+10(dodnd),DBDel(FM/DND/${FMGRP}/${FMUNIQUE})
exten => _FMGL-.,n,GotoIf($["${FMPRIME}" = "FALSE"]?dodial)
exten => _FMGL-.,n,Noop(Got DND in FMGL ${FMGRP} with ${EXTEN:5} in ${RingGroupMethod} mode, aborting)
exten => _FMGL-.,n,Hangup()


;------------------------------------------------------------------------
; [block-cf]
;------------------------------------------------------------------------
; This context is set as a target with FORWARD_CONTEXT when Call Forwarding is set to be
; ignored in a ringgroup or other features that may take advantage of this. Server side
; CF is done in dialparties.agi but if a client device forwards a call, it will be caught
; and blocked here.
;------------------------------------------------------------------------
[block-cf]
exten => _X.,1,Noop(Blocking callforward to ${EXTEN} because CF is blocked)
exten => _X.,n,Hangup()


;------------------------------------------------------------------------


; ############################################################################
; Extension Contexts [ext]
; ############################################################################


[ext-fax]
exten => s,1,Answer
exten => s,2,Goto(in_fax,1)
exten => in_fax,1,StopPlayTones  
exten => in_fax,2,GotoIf($["${FAX_RX}" = "system"]?3:analog_fax,1)
exten => in_fax,3,Macro(faxreceive)
exten => in_fax,4,Hangup
exten => analog_fax,1,GotoIf($["${FAX_RX}" = "disabled"]?4:2)  ;if fax is disabled, just hang up
exten => analog_fax,2,Set(DIAL=${DB(DEVICE/${FAX_RX}/dial)});
exten => analog_fax,3,Dial(${DIAL},20,d)
exten => analog_fax,4,Hangup
;exten => out_fax,1,wait(7)
exten => out_fax,1,txfax(${TXFAX_NAME},caller)
exten => out_fax,2,Hangup
exten => h,1,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --dest "${FROM_DID}" --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${FAXFILE});
exten => h,2,Hangup()


;this is where parked calls go if they time-out.  Should probably re-ring
[default]
include => ext-local
exten => s,1,Playback(vm-goodbye)
exten => s,2,Macro(hangupcall)
 
Rất tuyệt vời. Mong anh Root tiếp tục các bài viết tiếp theo để ae học hỏi nhé
 
anh ơi cho em hỏi khi cấu hình cùng một lúc 10 extension thì phải làm sao ạ.Em cám ơn!
 

About us

  • Securityzone.vn là một trang web chuyên về an ninh mạng và công nghệ thông tin. Trang web này cung cấp các bài viết, tin tức, video, diễn đàn và các dịch vụ liên quan đến lĩnh vực này. Securityzone.vn là một trong những cộng đồng IT lớn và uy tín tại Việt Nam, thu hút nhiều người quan tâm và tham gia. Securityzone.vn cũng là nơi để các chuyên gia, nhà nghiên cứu, sinh viên và người yêu thích an ninh mạng có thể trao đổi, học hỏi và chia sẻ kiến thức, kinh nghiệm và giải pháp về các vấn đề bảo mật trong thời đại số.

Quick Navigation

User Menu