Está en la página 1de 5

22/03/2012

Trang chnh

Ci t v cu hnh Asterisk trn CentOS 4.0 - B 's Blog - Never give up! - Yahoo! 360plus
Blog ca ti Vit blog Hnh nh Kt ni

Trang ch 360plus

Love is like war ... Easy to start ... Difficult to end ... Impossible to forget...

Bi vit

Tm bi vit:

Tm

Ci t v cu hnh Asterisk trn CentOS 4.0


ng ngy: 14:09 13-03-2010 Th mc: Asterisk

Never give up!


Thao tc khc

Ci t Asterisk Bi vit kh hay mnh a vo blog cc Bn tham kho. Cm n Anh Bui su tm. Hng dn ci t ASTERISK Ci t v cu hnh Asterisk trn CentOS 4.0 I. Ci t Asterisk a. Get the software C hai cch chnh ci t h thng Asterisk IP PBX system. l ci t t cc file RPM hay ci t bng cch compile trc tip t source. Tc gi bi vit recommend cc bn nn ci t bng cch compile t source, nhm trnh cc li mi trng thng gp khi dng. C 2 cch chnh ly source ca Asterisk: 1. Download Source c ng gi trn website ca Digium ti URL http://ftp.digium.com/pub/asterisk/ . Source c test bi ngi s dng v cc developer rt k, v c th xem nh l mt stable version. Mt lnh WGET [url] n gin s gip bn iu ny. # wget http://ftp.digium.com/pub/asterisk/aste ... 2.7.tar.gz 1. Source c ly trc tip t h thng CVS ca project Asterisk. Ly source t h thng CVS/SVN s cho php bn c nhng tnh nng mi nht bi n lien tc cp nht khi cc developer commit code vo h thng, nhng iu cng ng ngha y l mt bn unstable version. c th ly source t CVS, bn phi c Subversion hoc cc chng trnh tng t ci sn (c th install nhanh bng lnh yum install subversion nu bn dng CentOS / Fedora Core / Linux). Dng lnh svn checkout download source v ng dn hin ti # svn checkout http://svn.digium.com/svn/asterisk/trunk asterisk

2012

thng 3
F 2 S 3 1

S M T W T 4 5 6 7 8

9 10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Th mc ring
Tng hp ( 1 ) Yahoo! 360plus ( 12 ) Music ( 55 ) TTO ( 8 ) Nht k ( 17 ) Ngh thut sng ( 60 ) Vn ha - X hi ( 13 ) Xc cm ( 120 ) IT ( 10 ) Game ( 7 ) Picture ( 4 ) Asterisk ( 16 )

Bi mi nht
4.5 nm - Mt chng ng Madagui 04/09/2011 When You Tell Me That You Love Me - Westlife with Diana Ross My heart will go on Hy l chnh bn Du th no i na Sng 24.01.11 Relax ;;) 12.12.10

# svn checkout http://svn.digium.com/svn/zaptel/trunk zaptel # svn checkout http://svn.digium.com/svn/libpri/trunk libpri Chi tit c th tham kho trang http://www.asterisk.org/download b.Compile Asterisk Bn cn GCC (hoc GNU GCC) compile Asterisk. Trong trng hp nu server ca bn khng c GCC, dng lnh yum install gcc ci t GCC. Sau khi download source Asterisk di dng .tar.gzip, chng ta gii nn v untar cho n: # tar xzvf asterisk-1.2.7.tar.gz Hoc #gzip d asterisk-1.2.7.tar.gz #tar xvf asterisk-1.2.7.tar.gz Folder asterisk-1.2.7 s c to, hy chuyn vo trong Folder asterisk-1.2.7
1/5

vn.360plus.yahoo.com/tanpb-1409/article?mid=570&fid=-1

22/03/2012

Ci t v cu hnh Asterisk trn CentOS 4.0 - B 's Blog - Never give up! - Yahoo! 360plus

#cd asterisk-1.2.7 Bn ch trong th mc asterisk-1.2.7 c mt file c bit l Makefile, khi bn ch cn compile thm module hay recompile mt module b hng, bn c th vo y edit option ca mnh. Bn c th compile ln mt asterisn instance ang chy m khng b nh hnh iu g. Compile source: # make # make install Bn c th dng lnh # make samples to file config mu. Trong cu trc th mc ca Asterisk, c 2 ni cn lu : /etc/asterisk/ : cha cc file configuration dng *.conf, bn c th thay i trc tip cc file config bng mt editor (vi) v reload asterisk thay i c hiu lc. /var/lib/asterisk/ : Cha cc file library, sound ..etc ca Asterisk etc Dng lnh # asterisk start process asterisk, v dng lnh # asterisk r kt ni vo Asterisk Console tip: trc khi ci Asterisk, bn nn chy cc command sau nng cp GCC, Kernel Core v Kernel source trnh b li: - yum update(install) gcc - yum update(install) kernel-devel - yum update kernel Hy kim tra li Kernel core v Kernel Source c version ging nhau, v nh th s gim thiu rt nhiu ri ro khi compile Asterisk. Kim tra kernel v source: - uname a - rpm -qa |grep -i kernel-devel II. Technical Indepth Asterick c th c cu hnh vi nhiu mc ch khc nhau, nhng m hnh thng thng nht l Client/Server. M hnh ny cho php cc client hay cn gi l UAC user agent client kt ni vo server l Asterisk hay cn gi l UAS User Agent Server. Cc UAC l ni sinh ra cc session trong khi UAS th x l th ng cc session nhn c da trn tp hp rule c sn. Phn IV s i r hn v cc dng ng dng ny. Ta c th cu hnh Asterisk trong console mode, hoc c mt cch tin li hn l edit trc tip cc file cu hnh trong /etc/asterisk. Mi ng dng ring ca Asterisk nh voicemail, zaptel, music-on-hold, meetme, conference, iax u c configuration ring ca mnh, tuy nhin c 2 file cu hnh quan trng nht l sip.conf v extension.conf: - Sip.conf : file cu hnh v cc thng tin ca cc UAC nh username, password, IP, type, security, codec, l thnh phn cn bn nht lu gi thng tin trong Asterisk. - Extension.conf: file cu hnh v cc lut nh tuyn cuc gi, lut quay s, cc extension trong ngoi v nhng tnh nng c bit khc. Extensions.conf l file quan trng nht trong bt k cu hnh Asterisk no Cc file cu hnh khc - Voicemail.conf: file cu hnh cho h thng voice-mail ca asterisk. Asterisk c th dng lnh Sendmail trn CentOS gi mail n cho cc a ch c lu trong file cu hnh ny. - Zaptel.conf: File ny nm ngoi /etc, l file cha thng s index, driver dnh cho Linux khi kch hot cc thit b Telephony cm trc tip vo Asterisk thng qua cng PCI - Zapata.conf: Cng thuc module zaptel, nhng l file kt ni cc thit b Telephony c khai bo vo h thng
vn.360plus.yahoo.com/tanpb-1409/article?mid=570&fid=-1 2/5

22/03/2012

Ci t v cu hnh Asterisk trn CentOS 4.0 - B 's Blog - Never give up! - Yahoo! 360plus

chnh ca Asterisk - Iax(2).conf: Cc thng s v IAX (inter-asterisk protocol) dng khi kt ni 2 asterisk box vi nhau - MeetMe.conf: Mt chc nng to room conference cn bn. v nhiu lm! Sau y chng ta th xem qua mt cu hnh cn bn vi 1 server Asterisk v 2 Client dng X-Lite (www.xten.com). Chng ta cn lm 2 vic: nh ngha trn sip.conf 2 hng mc tng ng vi 2 client nh ngha trn extension.con dial-plan v extension tng ng. Trn File sip.conf: [101] Type=friends Username=*** Secret=*** Disallow=all Allow=ulaw Host=dynamic Context=test-dialplan [102] Type=friends Username=jane Secret=jane Disallow=all Allow=ulaw Context=test-dialplan Host=dynamic Ch : Trng Context trong file sip.conf phi ng vi mt context c nh ngha bi k hiu [ ] trong file extensions.conf, nh th SIP Entry c th gi c cc dial-plan bn trong mt context. Trn File extensions.conf [test-dialplan] Exten => 101,1,Dial(SIP/101) Exten => 102,2,Dial(SIP/102) Config trn s cho php 2 end-point Dng X-ten softphone, tng t bn c th thm vo nhiu ID hn trong file SIP.conf v to dial-plan tng ng vi extensions.conf. Nu Asterisk Server c t trn mt a ch IP public, v cc client (softphone, phone) nm a ch Private, bn phi thm vo dng NAT=1 trong cc SIP ID c nh ngha ti file sip.conf. Host=Dynamic cho php cc client c IP ng bt k, tuy nhin ch p dng c trong trng hp cc UAC c kh nng register vo h thng. Chi tit v cc thng s ca sip.conf v exntesion.conf c th c tm thy ti y: http://www.voip-info.org/wiki-Asterisk+config+sip.conf http://www.voip-info.org/wiki-Asterisk+ ... nsion.conf III. Chi tit ng sau mt cuc gi SIP Bn thn Asterisk c th chy nhiu protocol khc nhau nh H323, Skinny (SCCP) v MGCP nhng khi nhc n *, ngi ta ngh ngay n SIP. Ngoi Asterisk, cu trc rt linh ng ca SIP cng l engine cho rt nhiu ng dng khc nhau: Instant Messaging (MSN, Jabber), Online Game, Session Control, WholeSale VoIP v cc ng dng ty bin khc vn i hi s kt ni linh hot gia cc bn tham gia.

vn.360plus.yahoo.com/tanpb-1409/article?mid=570&fid=-1

3/5

22/03/2012

Ci t v cu hnh Asterisk trn CentOS 4.0 - B 's Blog - Never give up! - Yahoo! 360plus

By gi chng ta s phn tch cu hnh ti phn II, Tun t cc bc din ra nh sau: 1. My tnh *** va bootup, chng trnh Xten t ng kch hot kt ni vo Asterisk (v Xten c cu hnh sn). Xten s gi 1 SIP Message Method REGISTER vo Asterisk vi SIP ID l ***@1.1.1.1 v location l 1.1.1.1 2. Asterisk s gi li cho *** 403 Unauthorized Message, thc cht l mt dng Challenge Message. 3. ***s Xten khi nhn c Message 403 s tin hnh MD5 hash ci secret m *** cu hnh trong Xten, sau n gi mt SIP REGISTER MESSAGE vi mt header c bit: www_authorization hoc proxy_authorization (ty loi UA, trong trng hp ny l www_authorization), trong cha gi tr Hash m n mi c c. Asterisk khi nhn REGISTER message th nh ca ***, kim tra v thy c header www_authorization c gi tr hash. Asterisk s check trong b nh ca mnh xem SIP ID l *** c secret khng, nu c, n s hash ci secret trong b nh v so snh vi hash string c gi t *** ln. Nu ging nhau, th tip tc sang bc 5, cn fail th lp li bc 2. Khi Asterisk start, n s ly c thng s trong cc File .conf mt ln duy nht, do khi thay i trong cc file config ca Asterisk, phi restart asterisk bng cch kt ni vo Asterisk CLI v dng lnh reload. Khi hash-check pass, Asterisk gi v cho *** mt SIP MESSAGE 200 OK (ging http) bo rng anh registered. ng thi n cng cp nht location-table ca mnh l : ***@1.1.1.1 4. Khi *** tin hnh gi Jane (vi SIP, ngi ta c th gi bng s, hoc bng tn cng c), Xten ca *** s gi mt INVITE MESSAGE vo Asterisk. Asterisk s look up trong Location Table ca mnh v tm thy Jane ti a ch 2.2.2.2 (bc 5.5), trong trng hp tm khng thy, Asterisk c th gi v cho *** mt SIP MESSAGE 404 NOT FOUND (quen qu T_T) 5. Asterisk forward SIP INVITE MESSAGE n Jane@2.2.2.2 , tt nhin cng add vo trong INVITE y a ch ca mnh. * 6. ng thi, Asterisk cng gi v cho *** mt SIP MESSAGE 180 RINGBACK, bo hiu l phone ca Jane@2.2.2.2 reng, ch i bt my. Jane bt my, v gi v cho Asterisk mt SIP MESSAGE 200 OK vi y thng s Voice ca phone ca Jane nh Codec, Timing .v.v. nm trong SIP Body (Session Description Protocol SDP) 7. Asterisk chuyn Message 200 OK v cho ***, v hon tt qu trnh kim sot tn hiu SIP gia 2 UAC. ng thi cp nht cc thng tin v Billing nu c cu hnh. Lc ny, ***@1.1.1.1 v Jane@2.2.2.2 m mt RTP session trc tip n nhau hoc thng qua Asterisk ty thuc vo NAT setting gia 2 ngi. SIP nm thng tng ca Transport Layer, dng UDP 5060, trong khi RTP thng dng cc private port > 1024. Do SIP v RTP cng chy trn mt ng dng nhng li khc port, nn i khi chng ta gp tnh hung UAC s reng nhng RTP b block, gii chuyn mn gi l One-Way-Audio. * gia cc bc tht ra cn c mt dng Message ACK nh, tuy nhin n gin ha, ngi vit lc b phn ny. Chi tit v SIP c th c tm thy rt nhiu trn Internet, tuy nhin hiu su, k v chnh xc, RFC l 1 bt buc. SIP RFC: http://www.faqs.org/rfcs/rfc3261.html IV. Cc ng dng ca Asterisk Asterisk h tr rt nhiu cng ngh khc nhau nh H323, SIP, MCGP, SCCP cng nh nhiu loi giao tip mng khc nhau nh FXO, FXS, ISDN PRI, ISDN BRI, E3 thm ch SS7. Bn thn cu trc ngun m cng giao thc SIP linh hot, cho php developer ln ngi s dng c th customize ng dng Asterisk ca mnh ng k. c bit, phi k n giao tip Asterisk AGI v AsteriskRealtime cho php Asterisk kt hp vi cc ngn ng lp trnh thng dng nh C, C++, VBB, PHP, Shell-script, Python cng vi h c s d liu MySQL hoc Oracle pht trin nhng ng dng Voice-Application khc nhau. Sau y ngi vit xin gii thiu mt vi h thng m c kinh nghim lm qua: 1. SIP Registrar / IP PBX: ng dng cn bn nht ca Asterisk, nhng cng l mnh nht. Asterisk c cu hnh lm SIP proxy chnh cho cc Client kt ni vo. C th tch hp AsteriskRealTime v mt WEB GUI tin cho vic qun l (t vit hoc dng c sn). SIP Registrar c sn cc tnh nng hp dn nh voicemail, IVR, call-transfer, conference .v.v. 2. Conference Hub: Tn dng chc nng ca Asterisk v bin n tr thnh mt Conference Hub. Asterisk c dedicate s dng resource ca phn cng mirror cc dng RTP khc nhau t nhiu client gi n. Thng thng trong trng hp ny, Asterisk c s dng chung vi mt h thng Softswitch khc Asterisk tr thnh UAC ca h thng 3. Application Call Center: Tnh nng IVR (interactive voice respond) ca Asterisk c th c customize thnh nhiu lp khc nhau (khng c gii hn), cho php to ra mt danh mc tr li t ng khng l. ng dng ny c dng nhiu nht trong cc trung tm h tr khch hng c tr li t ng, tit kim c rt nhiu thi gian v chi ph. Chng ta cng c th to ra mt chng trnh tng tc DATA/PHONE khi dng vi Asterisk AGI v mt ngn ng lp trnh khc. 4. Class 5 Features box: Asterisk c s dng nh mt thit b cung cp dch v cng thm cho cc softswitch khc. Rt nhiu SIP proxy (nht l ca Telco) c cu trc kh n gin v gn nhm tng tc x l, do thng thiu nhng tnh nng nh voicemail, calling-card .v.v.. Asterisk lp vo ch trng mt cch hon ho, v c rt nhiu cc start-up VoIP provider s dng 5. Codec Transformer: Dn VoIP chuyn nghip hn s rt au u vi cc h thng Codec khc nhau ca voice, c bit khi kt ni n 1 nh cung cp khc. Thng th t ai chu thay i Codec mc nh ca mnh, nu ni l khng th. C nhiu gii php work-around nh back-to-back TDM trn cc Media Gateway. Asterisk c th lm IP-to-IP codec
vn.360plus.yahoo.com/tanpb-1409/article?mid=570&fid=-1 4/5

22/03/2012

Ci t v cu hnh Asterisk trn CentOS 4.0 - B 's Blog - Never give up! - Yahoo! 360plus

transformation mt cch hon ho, c bit vi license ca g729a. 6. Media (PSTN/ISDN/E3) Gateway: Bn thn Asterisk s dng chung vi cc module Zaptel ISDB PRI , FXO, FXS cho php Asterisk gi cuc gi ra ngoi cc h thng mng in thoi cng cng hay ISDN, y cng l mt gii php gi r. V on kt Tc gi khng c tham vng thuyt phc bn vt b h thng VoIP ca mnh hin ti, m ch khuyn khch bn download vi ci t Asterisk, bit u bn s cm thy c nhng tnh nng hay trn Asterisk c th tch hp hon ton thoi mi vo h th thng Integrate Phone Computer ca bn. ng thi, tc gi cng khuyn khch cc nhm, cc cng ty lp trnh nhn thy c tim nng ca Asterisk tin hnh nghin cu, pht trin n, v c th l con ng kh thi cho chng ta c hi bt kp c trnh cng ngh VoIP ca th gii.
Ngun trch dn (0)

0 Bnh lun
Li bnh mi Trc Sau

Kt Qu Bo Tr: Cancer
Chnh sch Quyn Ring t Cc iu khon Tha thun v S dng Dch v

Alternative Cancer Treatment


Qui nh v cc Quyn S hu Tr tu Tr gip Nguyn tc Cng ng

Bn quyn 2012 Yahoo! Southeast Asia Pte. Ltd. (Co. Reg. No. 1999700735D). Gi ton quyn.

vn.360plus.yahoo.com/tanpb-1409/article?mid=570&fid=-1

5/5