Está en la página 1de 18

TNG I ASTERISK TRIXBOX I. TNG QUAN 1.

. Gii thiu Asterisk v Trixbox Asterisk l phn mm ngun m, c vit bng ngn ng C, ra i nm 1999 bi Mark Spencer, u tin c thit k v trin khai trn GNU/Linux nn x86 (ca Intel). Nhng hin nay Asterisk c th chy trn cc h iu hnh khc nh: Mac OS X, FreeBSD, OpenBSD v Microsoft Windows. Asterisk c xem nh l mt tng i PBX (Private Branch eXchange) v c thm nhiu tnh nng mi. Ngoi nhng tnh nng ca mt tng i PBX thng thng, Asterisk cn c tch hp c chuyn mch TDM v chuyn mch VoIP, c kh nng m rng p ng nhu cu cho tng ng dung nh m rng giao tip vi mng PSTN (Public Switched Telephone Network). Trixbox c pht trin t nhn ca ng dng Asterisk, c tng hp t mt s thnh phn chnh c pht trin bi cng ng pht trin ngun m Asterisk di bn quyn GPL. Trixbox bao gm nhng thnh phn chnh cho vic cu hnh ng dng, thng k tnh trng hot ng h thng, lu tr d phng, v nhn l h iu hnh CentOS, tt c kt hp vi nhau to thnh mt gi hon chnh. Khi ci gi ny vo my tnh th c th s dng nh mt tng i PBX. Bi nhng tin ch, d s dng, y cc tnh nng ca mt tng i v hn th nn c nhiu h thng Asterisk , Trixbox c ci t thnh cng trn th gii. Hin nay h thng Asterisk, Trixbox ang c pht trin mnh, nhiu doanh nghip, cng ty v ang trin khai h thng to lin lc bn trong v ra c mng ngoi thng qua mng my tnh, gi in thoi.
2. Kin trc

Trixbox l thit b trung gian dng lin kt cng ngh in thoi v Internet. Trixbox c ng dng kt ni in thoi, ng dy in thoi hoc gi thoi n mt kt ni dch v khc. Trixbox c tin cy cao v d dng trin khai cho cc h thng ( t h thng nh n cc h thng ln). Trixbox h tr cho nhiu loi in thoi c cng ngh khc nhau. Cc cng ngh in thoi: VoIP, SIP, H.323, IAX v BGCP (dng cho in thoi i quc t). Asterisk c th kt ni vi hu ht loi in thoi truyn thng mng ISDN qua lung T1 v E1. Cc ng dng cho in thoi: chuyn mch cuc gi, cuc gi hi ngh, voicemail, chuyn hng cuc gi, Trixbox c kt ni ti mng ni ht s iu khin cc in thoi trong mng kt ni n mng khc, cc in thoi trong mng c th thc hin cuc gi v kt ni Internet thng qua Trixbox Cng FXS dng Trixbox server iu khin cc in thoi tun t trong ni hat. Cng FXO v knh T , E c dng kt ni gia Trixbox vi mng PSTN. Thu bao trong mng PSTN thc hin cuc gi n cc thu bao c qun l bi Asterisk

server, cc thu bao ca Trixbox cng c th thc hin cuc gi n thu bao trong mng PSTN.

3. Mt s tnh nng c bn: 3.1 . Call Forwarding Call Forwarding: chuyn hng cuc gi. y l tnh nng thng c s dng trong h thng Asterisk. Chc nng cho php chuyn mt cuc gi n mt hay nhiu s my in thoi c nh trc. Mt s trng hp cn chuyn cuc gi nh : Chuyn cuc gi khi bn, chuyn cuc gi khi khng tr li, chuyn cuc gi tc thi, chuyn cuc gi vi thi gian nh trc. 3.2 . Caller ID Caller ID: cuc gi c hin th s. Vi chc nng ny th s thu bao gi n s c hin th. Ngoi ra Caller ID cng cho php chng ta xc nhn s thu bao gi n c ngha l da vo caller ID chng ta c tip nhn hay khng tip nhn cuc gi t pha h thng Asterisk. Ngn mt s cuc gi ngoi mun. 3.3 . Interactive Voice Response Interactive Voice Response (IVR)c dng ch chc nng tng tc thoi (tng i tr li t ng).

Chc nng tng tc thoi c rt nhiu ng dng trong thc t, khi gi in thoi n mt c quan hay x nghip thu bao thng c nghe thng ip nh:Xin cho mng bn gi n cng ty chng ti hy nhn phm 1 gp phng kinh doanh, phm 2 gp phng k thut, phm 3 gp phng h tr khch hng sau tu vo s tng tc ca thu bao gi n, h thng Asteisk , Trixbox s nh hng cuc gi theo mong mun. Dch v xem im thi, tin cc in thoi ca thu bao, t gi t i n t hin nay nh th no, hay kt qu s s, bn tin d bo thi tit tt cc nhng mong mun trn u c th thc hin qua chc nng tng tc thoi. 3.4. Time and Date Nhm ch nh cc khong thi gian c th cuc gi s nh hng n mt s in thoi hay mt chc nng c th khc, v d trong cng ty gim c mun ch cho php nhn vin s dng my in thoi trong gi hnh chnh cn ngoi gi th s hn ch hay khng cho php gi ra bn ngoi. 3.5. Queues Tnh nng ny cho php chung cng lc hoc chung ln lt nhng in thoi ng k s extension bn trong. iu ny gii quyt c trng hp nhiu ngi gi ti cng lc mt s in thoi. 3.6. Confenrences Tnh nng conferences trn trixbox cho php hp phng hi ngh t nhiu bn khi cch xa nhau. Mi ngi c th gi v mi nhau vo phng hi ngh cng trao i. 3.7. Backlist Backlist cm nhng my in thoi nm trong danh sch s khng gi c n my ca mnh (s dng trong tnh trng hay b quy ri in thoi). V cn rt nhiu tnh nng na m h thng asterisk c th cung cp cho ngi s dng, trn y ch l mt s tnh nng thng c s dng CU HNH TRIXBOX Phn ny m t cc cu hnh , t vic ng k s, gi ra, nhn cuc gi v cc tnh nng h tr trn Trixbox. Tt c cc cu hnh trn web page u c lu trong File Extension_Additional.conf 1. Cu hnh cc thnh phn Trixbox 1.1. Extensions : Ci t cc s ni b.
II.

Display Name : nhp tn user ngi dng User Extension : nhp s extension (101 hoc 102 ,103,104)

Secret : password (option) Nhng thng s khc mc nh. 1.2. Trunk

9|xxxxxxxxxx 9|Nxxxxxxx

Dial rules : nu trong Outbound Route phn Dial Pattern l 9|. Th trong Dial Rules phi cu hnh bt u phi l 9|xxx.

PEER Details :
username=0873000002(s phone ng k) type=peer secret=(phai ng k) qualify=yes insecure=very host=sia-HCM1CA146.fpt.net fromuser=0873000002(s phone ng k) fromdomain=sia-HCM1CA146.fpt.net dtmfmode=rfc2833 disallow=all context=from-pstn canreinvite=no authuser=0873000002(s phone ng k) allow=ulaw&alaw

Registration

username:secretpassword@sia-HCM1CA146.fpt.net/username

V d : 0873077476:brm4OEP1rf@sia-HCM1CA146.fpt.net/0873077476 Trong trng hp sip trunk :


type=peer qualify=yes insecure=very host=118.69.239.243 disallow=all canreinvite=no allow=ulaw&alaw

1.3. Outbound Route Phn ny cu hnh cuc gi ra. Edit trn 0 9_Outside : Phn Dial Patterns : mc nh l 9|.( ngha l cuc gi ra bt u bng s 9, nn but cu hnh trong dial rule phn trunk phi l 9|xxx.) ,nu ta config l . Th trong phn Dial Rules khng cn bt u l 9|

Phn Trunk Sequence : chon SIP/trunk_name

1.4 . Inbound Routes Phn ny cu hnh nhn cuc gi. Configure DID number l s ng k :

Nu hng cuc gi vo l mt s Extension th ta chn l phn Extensions, tu yu cu m chn cc option khc nhau. Nu hng cuc gi vo l mt dy cc s in thoi th ta cu hnh thm RingGroups, hoc l Queues, sau chn trong phn option. Trong trng hp dng IVR th chon IVR :

1.5. General Setting :

1.6. IVR Vo phn IVR : - To tn - Chn Announcement : phn ny vo System Recording to. - To cc kiu option IVR. Chng hn nhn 0 th vo c tr gip, 1 vo extension

1.7. Blacklist Nhp s in thoi khng mun b quy ri sau Submit.

1.8. Queues Nhp s v tn Queue, ri chn cc s extension nm trong Queue

Thm vo cc option cu hnh cho Queue bao gm : + Music on Hold : chn l nghe chung hay l nghe nhc ch + Thi gian i l khang bao lu + Kiu Ring Strategy : l chung tt c hay chung ln lt.

Khi khng thc hin c Queue th s y vo c ch bn di

* Ch : Trong qu trnh ci t phn Queue trn giao din web ,khi chn Ringall th n thc thi cn khi chn cc Option khc th khng thc thi . khc phc tnh trng ny vo phn Config File Editor chnh sa li file cu hnh. ** Qu trnh thc th ca Queues, vi s destination l 0873000003

Trong file Extension_Additional.conf : Khi thu bao gi ti s 0873000003 th u tin s thc th l option [ext-did]
[ext-did] include => ext-did-custom include => ext-did-0001 include => ext-did-0002 exten => fax,1,Goto(ext-fax,in_fax,1)

Sau s thc thi ln lt cc include , nu mun thay i th vo File Extension_Custom.conf to option [ext-did-custom] thay i, mc nh l
[ext-did-002]
[ext-did-0002] include => ext-did-0002-custom exten => fax,1,Goto(ext-fax,in_fax,1) exten => 0873000003,1,Set(__FROM_DID=${EXTEN}) exten => 0873000003,n,Gosub(app-blacklist-check,s,1) exten => 0873000003,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)})) exten => 0873000003,n,SetMusicOnHold(none) exten => 0873000003,n,Set(__MOHCLASS=none) exten => 0873000003,n,Set(__CALLINGPRES_SV=$ {CALLERPRES()}) exten => 0873000003,n,Set(CALLERPRES()=allowed_not_screened) exten => 0873000003,n,Goto(ext-queues,222,1)

Sau khi chy cc hm trn s goto n [exten-queues]


[ext-queues] include => ext-queues-custom exten => 222,1,Macro(user-callerid,) exten => 222,n,Answer exten => 222,n,Set(__BLKVM_OVERRIDE=BLKVM/${EXTEN}/$ {CHANNEL}) exten => 222,n,Set(__BLKVM_BASE=${EXTEN}) exten => 222,n,Set(DB(${BLKVM_OVERRIDE})=TRUE) exten => 222,n,ExecIf($["${REGEX("(M[(]auto-blkvm[)])" $ {DIAL_OPTIONS})}" != "1"]?Set(_DIAL_OPTIONS=$ {DIAL_OPTIONS}M(auto-blkvm))) exten => 222,n,Set(__NODEST=${EXTEN}) exten => 222,n,Set(MONITOR_FILENAME=/var/spool/asterisk/monitor/q$ {EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}) exten => 222,n,Set(__CWIGNORE=TRUE) exten => 222,n,Queue(222,t,,,60) exten => 222,n,dbDel(${BLKVM_OVERRIDE})

exten exten exten exten exten

=> => => => =>

222,n,Set(__NODEST=) 222,n,Set(__CWIGNORE=) 222,n,Goto(ext-queues,222,1) 222*,1,Macro(agent-add,222,) 222**,1,Macro(agent-del,222,222)

Trong phn ny ch dng exten => 222,n,Queue(222,t,,,60) v y l dng thc thi Queues. Sau s tham chiu thc thi Queue. Phn ny c cu hnh trong Queues.conf :
[My_Queue] musicclass = default maxlen=0 retry=5 strategy=roundrobin timeout=15 weight=0 wrapuptime=0 announce-frequency=0 announce-holdtime=no announce-position=no eventmemberstatus=yes eventwhencalled=yes joinempty=yes leavewhenempty=yes member => SIP/101 member => SIP/102 member => SIP/103 member => SIP/104

Queue trn s thc thi Ring Strategy l RoundRobin 1.9. Ring Group C ch thc thi cng gn tng t Queue nhng ch khc trong vi option phn RingStrategy phn hunting Nhp vo s v tn RingGroup, kiu RingStrategy, thi gian ch v cc extension bao gm trong Group

Trng hp nu Destination khng tr li s y vo cc option bn di

1.10. Conferences Cu hnh conferences trn Web Page kh n gin: + Vo phn Conferences to s v tn + To m pin cho user v admin, m Pin l mt khu tham gia hi ngh, trong trng hp nu trng th khi gi ti s destination hi ngh s c to ra m khng yu cu bt k iu kin no.

+ Chn cc option Conference thc hin.

Trong : Join Message : thng bo khi c ngi tham gia vo hi ngh Leader Wait : nu chn yes , th hi ngh ch c th bt u khi admin c trong hi ngh Quiet Mode : nu chn Yes, th trong qu trnh tham gia hi ngh ngoi tham gia s khng nghe cc on thng bo c ngi khc tham gia hay c ngi khc ri phng. UserCount : nu chn Y th s c thng bo s lng ngi hn ti tham gia phng Music On Hold : chn yes th khi tham gia vo hi ngh m cha c ai vo trc hoc phn LeaderWait chn yes m cha c admin th ngi tham gia s nghe nhc ch Allow Menu : phn ny nu chn Yes, th khi nhn phm * s nghe menu thng bo v tng gim m lng hi ngh Record Conference : Chn Yes s ghi li ton b Record trong hi ngh vo file

Tuy nhin nu c nhiu yu cu t ra trong phn Conference chng hn mi vo Room, v cc thay i trong phn thng bo th phi vo file cu hnh v thc hin thay i . Qu trnh thc thi bng dng lnh ca Conference, v d vi s destination l 0873000006, khi nghe thng bo nhp m pin, nu nhp chnh xc s c tham gia hi ngh, Khi tham gia, nu mun mi nhng thu bao khc th nhn s 0 , ri nhn s thu bao cn mi. Khi thu bao kia ng tham gia th ngi mi nhn tip ** , khi c 2 s tham gia vo hi ngh, v cch thc hin tng t cho nhng thu bao tham gia vo v mun mi nhng thu bao . Mc nh cu hnh nm trong file Extension_Additional.conf +C php khi thc to meetme l : MeetMe(s phng, option,m pin) Khi thu bao gi ti s 0873000006 th u tin s thc th l
[ext-did]
[ext-did] include => ext-did-custom include => ext-did-0001 include => ext-did-0002 exten => fax,1,Goto(ext-fax,in_fax,1) ; end of [ext-did]

option

Sau s thc thi ln lt cc include , nu mun thay i th vo File Extension_Custom.conf to option [ext-did-custom] thay i, mc nh l
[ext-did-002]

Vo file Extension_Custom.conf v to option [ext-did-custom]


[ext-did-custom] exten => STARTMEETME,1,MeetMe(${CONFNO},${MEETME_OPTS},$ {PIN}) exten => STARTMEETME,n,Hangup exten => h,1,Hangup exten => 0873000006,1,Set(__FROM_DID=${EXTEN}) exten => 0873000006,n,Macro(user-callerid,) exten => 0873000006,n,Set(DYNAMIC_FEATURES=nway-start) exten => 0873000006,n,Gosub(app-blacklist-check,s,1) exten => 0873000006,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)})) exten => 0873000006,n,Set(__CALLINGPRES_SV=$ {CALLERPRES()}) exten => 0873000006,n,Set(CALLERPRES()=allowed_not_screened) exten => 0873000006,n,Set(MEETME_EXIT_CONTEXT=dynamicnway-invite) exten => 0873000006,n,Set(CONFNO=0873000006)

exten => 0873000006,n,Set(MEETME_RECORDINGFILE=$ {ASTSPOOLDIR}/monitor/meetme-conf-rec-${CONFNO}-$ {UNIQUEID}) exten => 0873000006,n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?READPIN) exten => 0873000006,n,Answer exten => 0873000006,n,Wait(1) exten => 0873000006,n,Set(PINCOUNT=0) exten => 0873000006,n(READPIN),Read(PIN,enter-conf-pinnumber,,,,) exten => 0873000006,n,GotoIf($[x${PIN} = x0246800]?USER) exten => 0873000006,n,Set(PINCOUNT=$[${PINCOUNT}+1]) exten => 0873000006,n,GotoIf($[${PINCOUNT}>3]?h) exten => 0873000006,n,Goto(READPIN) exten => 0873000006,n(USER),Set(MEETME_OPTS=qcIMrpX) exten => 0873000006,n,Playback(custom/joinmessage) exten => 0873000006,n,Goto(STARTMEETME,1) exten => 0873000006,hint,MeetMe:0873000006 [roomstatic] exten => s,1,Set(DYNAMIC_FEATURES=nway-start) exten => s,n,Set(MEETME_EXIT_CONTEXT=dynamic-nway-invite) exten => s,n,Playback(custom/joinmessage) exten => s,n,MeetMe(0873000006,qcIMrpX,0246800) [dynamic-nway-invite] exten => 0,1,Read(DEST,dial,,i) exten => 0,n,Set(DYNAMIC_FEATURES=nway-inv#nway-noinv) exten => 0,n,Dial(Local/${DEST}@from-internal,,g) exten => 0,n,Set(DYNAMIC_FEATURES=) exten => 0,n,Goto(roomstatic,s,1) [macro-nway-ok] exten => s,1,ChannelRedirect(${BRIDGEPEER},roomstatic,s,1) [macro-nway-notok] exten => s,1,SoftHangup(${BRIDGEPEER})

Ri vo file Meetme.conf to :
[room] conf => 0873000006,0246800

Vo file features.conf to :
[applicationmap] nway-inv => **,caller,Macro,nway-ok nway-noinv => *#,caller,Macro,nway-notok

Trong cc cu lnh trn ch cc dng


exten => 0873000006,n,Set(CONFNO=0873000006)

set phng hi nghi l 0873000006


exten => 0873000006,n(READPIN),Read(PIN,enter-conf-pinnumber,,,,) exten => 0873000006,n,GotoIf($[x${PIN} = x0246800]?USER) exten => 0873000006,n,Set(PINCOUNT=$[${PINCOUNT}+1]) exten => 0873000006,n,GotoIf($[${PINCOUNT}>3]?h) exten => 0873000006,n,Goto(READPIN)

Nghe thng bo nhp m pin. Nu nhp m pin khc 0246800 3 ln s khng c vo hi ngh nu nhp ng th thc thi cu lnh k tip :
exten exten exten exten => => => => 0873000006,n(USER),Set(MEETME_OPTS=qcIMrpX) 0873000006,n,Playback(custom/joinmessage) 0873000006,n,Goto(STARTMEETME,1) 0873000006,hint,MeetMe:0873000006

khi s tham gia vo hi ngh vi c php meetme l: meetme(0873000006, qcIMrpX,0246800) , cc option q (khng nghe thng bo tham gia hay ri phng), c(thng bo s thu bao ang tham gia), M(nghe nhc ch khi tham gia), r ( ghi li ton b hi ngh ), p (thot hi ngh bng cch nhn #) X( enable ch MEETME_EXIT_CONTEXT)
Khi enable ch MEETME_EXIT_CONTEXT th conference s thc thi cu lnh :
exten => 0873000006,n,Set(MEETME_EXIT_CONTEXT=dynamic-nwayinvite)

cu lnh trn thc hin s gi option [dynamic-nway-invite] :


[dynamic-nway-invite] exten => 0,1,Read(DEST,dial,,i) exten => 0,n,Set(DYNAMIC_FEATURES=nway-inv#nway-noinv) exten => 0,n,Dial(Local/${DEST}@from-internal,,g) exten => 0,n,Set(DYNAMIC_FEATURES=) exten => 0,n,Goto(roomstatic,s,1)

=>khi nhn phm 0 v quay s thu bao cn mi v thot ra vo hi ngh bng cch nhn ** khi s thc hin dng lnh exten => 0873000006,n,Set(DYNAMIC_FEATURES=nway-start) v nhy vo file features.conf thc thi cu lnh : nway-inv => **,caller,Macro,nway-ok . Khi cu lnh ny s gi option [macronway-ok]
[macro-nway-ok] exten => s,1,ChannelRedirect(${BRIDGEPEER},roomstatic,s,1)

=> vo option [roomstatic] thc thi meetme MeetMe(0873000006,qcIMrpX,0246800)=> Cu lnh Meetme c gi s tham chiu vo file meetme.conf v thc thi conference. 2. Cc cu hnh trn Command line Trixbox 2.1 . Config sip.conf Thnh phn ny phi c ci t v thng s h thng hin ti ang chy thi gian expire l 3600
[general] defaultexpiry = 3600

2.2. To ip lookup domain Cmd : # vi /etc/hosts 118.69.239.250 sia-HCM1CA146.fpt.net Esc=> :wq 2.3. Mt vi cu lnh trong linux Lnh i pass root : # passwd Lnh i pass maint(truy cp ti khan admin trn web trixbox) :
passwd-maint

Xem ip : # ifconfig Setup ip cho card mng : #setup Restart network : # service network restart ( lnh ny thc hin sau khi i ip) Truy cp command line trn trixbox : # asterisk Debug asterisk : # sip set debug on Restart asterisk :
# amportal kill # amportal restart -r

2.4. Route n cc mng v cc host Route n mt a ch host : # route add host ipdest gw ipgw Route n mt mng : # route add net networkdest netmask
ipmask gw ipgateway

=> Nu route bng cu lnh th sau khi reboot li my s mt ht , do ta route vo file cu hnh Route tnh trn file cu hnh : route-eth0(nu cha c th to) Voi card eth0 :
# vi /etc/sysconfig/network-scripts/route-eth0

Thm cc dng lnh


default ipgateway dev tencardmang Ipdest/netmask via ipgateway dev tencardmang

Exam :

default 118.69.239.129 dev eth0 118.69.239.242/32 via 118.69.239.129 dev eth0 118.69.239.250/32 via 118.69.239.129 dev eth0 118.69.222.245/32 via 118.69.239.129 dev eth0 172.30.6.128/25 via 118.69.239.129 dev eth0 172.30.4.128/25 via 118.69.239.129 dev eth0

Thot ra v start li
# service network start

2.5 . To IPTABLES Nu dng cu lnh th :


#Iptables A INPUT s ipaddress j ACCEPT #service iptables save >> /etc/sysconfig/iptables

Thot ra v start li:


# service iptables start

=> Tuy nhin dng cu lnh khi reboot li s mt do ta thit lp trn file cu hnh Dng cu lnh :
# vi /etc/sysconfig/iptables

Edit :
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [583:160179] -A INPUT -s 127.0.0.1 -j ACCEPT -A INPUT -s 118.69.239.145 -j ACCEPT -A INPUT -s 118.69.239.245 -j ACCEPT -A INPUT -s 118.69.239.138 -j ACCEPT -A INPUT -s 118.69.239.242 -j ACCEPT -A INPUT -s 118.69.222.245 -j ACCEPT -A INPUT -s 118.69.239.250 -j ACCEPT -A INPUT -s 118.69.239.243 -j ACCEPT -A INPUT -s 172.30.6.133 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited COMMIT

That ra v start li
# service iptables start

Ch : Khi cu hnh trn web mi khi thay i cc thng s th cn submit v apply configure li . Nu cu hnh trn cc file .conf th vo server trixbox, g lnh :
#amportal kill #amportal restart