1. 檢查依賴的包是否安裝:依賴的包有
gcc--libpri, zaptel asterisk ncurses-devel
libtermcap-devel kernel-devel kernel-smp-devel gcc-c++ openssl-devel newt-devel zlib-devel unixODBC-devel libtool make 利用 rpm -q 名稱 進行查詢看是否安裝,無時進行安裝,當然用源安裝快!
2.asterisk 的安裝和環(huán)境的搭建
首先在FTP上(自己Google)得到壓縮包,或者ssh 遠程得到 命令為 get 名稱 自己的主機名稱:放置目錄 安裝到/usr/src目錄下
解壓縮、切換目錄(/usr/src/asterisk-xxx)、執(zhí)行(sudo ./configure)、sudo make、sudo make install 、sudo make samples、sudo make progdocs 修改配置: 1.1 在/etc/asterisk/sip.conf 中添加用戶:
[1001]
type=friend secret=test host=dynamic [1002] type=friend secret=test host=dynamic 1.2 /etc/asterisk/extensions.conf 中添加: [test]
exten => 1001,1,Dial(SIP/1001) exten => 1002,1,Dial(SIP/1002) ===============================各項講解===================================
sip環(huán)境的簡易配置:(所有的配置文件都在/etc/asterisk目錄下,其它地方的配置無效) sip.conf
[general] 所有用戶和對端的默認選項 allowoverlap=no bindport=5060 監(jiān)聽端口 bindaddr=0.0.0.0 監(jiān)聽所有過來的電話 srvlookup=yes 使用 DNS 服務 qualify=yes context=test 撥號方案 [1001] type=friend 類型 用戶類型的用于認證呼入呼叫 端Peer是用于呼出呼叫 朋友類型兩者都有 secret=test 密碼 host=dynamic 動態(tài)IP [1002] type=friend secret=test host=dynamic extensions.conf
在文檔的最后添加: [test] exten => 1001,1,Dial(SIP/1001) 呼叫超時秒數(shù) exten => 1002,1,Dial(SIP/1002) =========================================================================
運行asterisk的命令為:asterisk & or sudo /usr/sbin/asterisk -vvvvvvcg 停止命令為:stop now 連接到命令行:asterisk -rvvv dialplan reload sip reload 顯示支持的通信類型: show channeltypes 打開調試信息: sip set debug 現(xiàn)在astersik下的sip環(huán)境就搭建完成了,開啟astersik ==================================
sudo /usr/sbin/asterisk -vvvvvvcg ================================= 登錄到Astersk服務器運行控制臺: asterisk -crvvv 查看登錄用戶 : sip shwo peers *CLI> sip show peers
Name/username Host Dyn Nat ACL Port Status 1004 (Unspecified) D 0 UNKNOWN 1003 (Unspecified) D 0 UNKNOWN 1002 (Unspecified) D 0 UNKNOWN 1001/1001 192.168.123.58 D 39478 OK (101 ms) 4 sip peers [Monitored: 1 online, 3 offline Unmonitored: 0 online, 0 offline] *CLI> 查看詳細記錄: sip show peer 1001
*CLI> sip show peer 1002 ////注意與查看全部的區(qū)別 peers peer
* Name : 1002 Secret : <Set> MD5Secret : <Not set> Context : test Subscr.Cont. : <Not set> Language : AMA flags : Unknown Transfer mode: open CallingPres : Presentation Allowed, Not Screened Callgroup : Pickupgroup : Mailbox : VM Extension : asterisk LastMsgsSent : 32767/65535 Call limit : 0 Dynamic : Yes Callerid : "" <> MaxCallBR : 384 kbps Expire : -1 Insecure : no Nat : RFC3581 ACL : No T38 pt UDPTL : No CanReinvite : Yes PromiscRedir : No User=Phone : No Video Support: No Trust RPID : No Send RPID : No Subscriptions: Yes Overlap dial : No DTMFmode : rfc2833 LastMsg : 0 ToHost : Addr->IP : (Unspecified) Port 0 Defaddr->IP : 0.0.0.0 Port 5060 Def. Username: SIP Options : (none) Codecs : 0x8000e (gsm|ulaw|alaw|h263) Codec Order : (none) Auto-Framing: No Status : UNKNOWN Useragent : Reg. Contact : *CLI>
重新加載撥號方案:dialplan reload *CLI> dialplan reload
== Parsing '/etc/asterisk/extensions.conf': Found == Setting global variable 'CONSOLE' to 'Console/dsp' == Setting global variable 'IAXINFO' to 'guest' == Setting global variable 'TRUNK' to 'Zap/G2' == Setting global variable 'TRUNKMSD' to '1' -- Registered extension context 'dundi-e164-canonical' -- Registered extension context 'dundi-e164-customers' -- Registered extension context 'dundi-e164-via-pstn' -- Registered extension context 'dundi-e164-local' -- Including context 'dundi-e164-canonical' in context 'dundi-e164-local' -- Including context 'dundi-e164-customers' in context 'dundi-e164-local' -- Including context 'dundi-e164-via-pstn' in context 'dundi-e164-local' -- Registered extension context 'dundi-e164-switch' -- Including switch 'DUNDi/e164' in context 'dundi-e164-switch' -- Registered extension context 'dundi-e164-lookup' -- Including context 'dundi-e164-local' in context 'dundi-e164-lookup' -- Including context 'dundi-e164-switch' in context 'dundi-e164-lookup' -- Registered extension context 'macro-dundi-e164' -- Added extension 's' priority 1 to macro-dundi-e164 -- Including context 'dundi-e164-lookup' in context 'macro-dundi-e164' -- Registered extension context 'iaxtel700' -- Added extension '_91700XXXXXXX' priority 1 to iaxtel700 -- Registered extension context 'iaxprovider' -- Registered extension context 'trunkint' -- Added extension '_9011.' priority 1 to trunkint -- Added extension '_9011.' priority 2 to trunkint -- Registered extension context 'trunkld' -- Added extension '_91NXXNXXXXXX' priority 1 to trunkld -- Added extension '_91NXXNXXXXXX' priority 2 to trunkld -- Registered extension context 'trunklocal' -- Added extension '_9NXXXXXX' priority 1 to trunklocal -- Registered extension context 'trunktollfree' -- Added extension '_91800NXXXXXX' priority 1 to trunktollfree -- Added extension '_91888NXXXXXX' priority 1 to trunktollfree -- Added extension '_91877NXXXXXX' priority 1 to trunktollfree -- Added extension '_91866NXXXXXX' priority 1 to trunktollfree -- Registered extension context 'international' -- Including context 'longdistance' in context 'international' -- Including context 'trunkint' in context 'international' -- Registered extension context 'longdistance' -- Including context 'local' in context 'longdistance' -- Including context 'trunkld' in context 'longdistance' -- Registered extension context 'local' -- Including context 'default' in context 'local' -- Including context 'trunklocal' in context 'local' -- Including context 'iaxtel700' in context 'local' -- Including context 'trunktollfree' in context 'local' -- Including context 'iaxprovider' in context 'local' -- Including context 'parkedcalls' in context 'local' -- Registered extension context 'macro-trunkdial' -- Added extension 's' priority 1 to macro-trunkdial -- Added extension 's' priority 2 to macro-trunkdial -- Added extension 's-NOANSWER' priority 1 to macro-trunkdial -- Added extension 's-BUSY' priority 1 to macro-trunkdial -- Added extension '_s-.' priority 1 to macro-trunkdial -- Registered extension context 'macro-stdexten' -- Added extension 's' priority 1 to macro-stdexten -- Added extension 's' priority 2 to macro-stdexten -- Added extension 's-NOANSWER' priority 1 to macro-stdexten -- Added extension 's-NOANSWER' priority 2 to macro-stdexten -- Added extension 's-BUSY' priority 1 to macro-stdexten -- Added extension 's-BUSY' priority 2 to macro-stdexten -- Added extension '_s-.' priority 1 to macro-stdexten -- Added extension 'a' priority 1 to macro-stdexten -- Registered extension context 'macro-stdPrivacyexten' -- Added extension 's' priority 1 to macro-stdPrivacyexten -- Added extension 's' priority 2 to macro-stdPrivacyexten -- Added extension 's-NOANSWER' priority 1 to macro-stdPrivacyexten -- Added extension 's-NOANSWER' priority 2 to macro-stdPrivacyexten -- Added extension 's-BUSY' priority 1 to macro-stdPrivacyexten -- Added extension 's-BUSY' priority 2 to macro-stdPrivacyexten -- Added extension 's-DONTCALL' priority 1 to macro-stdPrivacyexten -- Added extension 's-TORTURE' priority 1 to macro-stdPrivacyexten -- Added extension '_s-.' priority 1 to macro-stdPrivacyexten -- Added extension 'a' priority 1 to macro-stdPrivacyexten -- Registered extension context 'macro-page' -- Added extension 's' priority 1 to macro-page -- Added extension 's' priority 2 to macro-page -- Added extension 's' priority 3 to macro-page -- Added extension 's' priority 4 to macro-page -- Added extension 's' priority 5 to macro-page -- Added extension 's' priority 6 to macro-page -- Added extension 's' priority 7 to macro-page -- Registered extension context 'demo' -- Added extension 's' priority 1 to demo -- Added extension 's' priority 2 to demo -- Added extension 's' priority 3 to demo -- Added extension 's' priority 4 to demo -- Added extension 's' priority 5 to demo -- Added extension 's' priority 6 to demo -- Added extension 's' priority 7 to demo -- Added extension '2' priority 1 to demo -- Added extension '2' priority 2 to demo -- Added extension '3' priority 1 to demo -- Added extension '3' priority 2 to demo -- Added extension '1000' priority 1 to demo -- Added extension '1234' priority 1 to demo -- Added extension '1234' priority 2 to demo -- Added extension '1235' priority 1 to demo -- Added extension '1236' priority 1 to demo -- Added extension '1236' priority 2 to demo -- Added extension '#' priority 1 to demo -- Added extension '#' priority 2 to demo -- Added extension 't' priority 1 to demo -- Added extension 'i' priority 1 to demo -- Added extension '500' priority 1 to demo -- Added extension '500' priority 2 to demo -- Added extension '500' priority 3 to demo -- Added extension '500' priority 4 to demo -- Added extension '600' priority 1 to demo -- Added extension '600' priority 2 to demo -- Added extension '600' priority 3 to demo -- Added extension '600' priority 4 to demo -- Added extension '76245' priority 1 to demo -- Added extension '_7XXX' priority 1 to demo -- Added extension '7999' priority 1 to demo -- Added extension '7999' priority 2 to demo -- Added extension '8500' priority 1 to demo -- Added extension '8500' priority 2 to demo -- Registered extension context 'page' -- Added extension '_X.' priority 1 to page -- Registered extension context 'default' -- Including context 'demo' in context 'default' -- Registered extension context 'test' -- Added extension '1001' priority 1 to test -- Added extension '1002' priority 1 to test -- Added extension '1003' priority 1 to test -- Added extension '1004' priority 1 to test == Parsing '/etc/asterisk/users.conf': Found Dialplan reloaded. *CLI> 重新加載SIP方案:sip reload *CLI> sip reload
*CLI> Reloading SIP == Parsing '/etc/asterisk/sip.conf': Found == Parsing '/etc/asterisk/users.conf': Found == Parsing '/etc/asterisk/sip_notify.conf': Found *CLI> =========================sip 控制臺信息=====================================
1. 運行調試常用命令
./asterisk & 在后臺運行 ./asterisk -vvvc 啟動并盡量多的在控制臺顯示調試信息 ./asterisk -r 連接 控制臺 set verbose 9999 設置打印詳細信息 2. 控制臺下常用命令 sip reload 重新加載sip信息 sip set debug 設置顯示更多的sip信息 sip set debug off 關閉顯示更多的sip信息 sip show channels 顯示所有活動的sip通道 sip show users 顯示用戶情況 sip show user xxx 顯示用戶xxx的情況 dialplan show 顯示撥號方案 dialplan reload 重新加載撥號方案 stop gracefully 優(yōu)雅的停止asterisk stop now 立即停止運行 module show 顯示已有的加載
module load cdr_radius.so 加載模塊 cdrxxx module reload cdr_radius.so 重新加載模塊 cdrxxx module unload cdr_radius.so 卸載模塊 cdrxxx core show applications 顯示所有的應用 比如 Dial Radius Hangup Answer等 core show channels 顯示所有的通話通道 core show codecs 顯示所有支持的編碼 core show functions 顯示所有的功能函數(shù) ------------------------------------------------------------------------- *CLI> help ! Execute a shell command abort halt Cancel a running halt ael debug contexts Enable AEL contexts debug (does nothing) ael debug macros Enable AEL macros debug (does nothing) ael debug read Enable AEL read debug (does nothing) ael debug tokens Enable AEL tokens debug (does nothing) ael nodebug Disable AEL debug messages ael reload Reload AEL configuration agent logoff Sets an agent offline agent show Show status of agents agent show online Show all online agents agi debug Enable AGI debugging agi debug off Disable AGI debugging agi dumphtml Dumps a list of agi commands in html format agi show List AGI commands or specific help cdr status Display the CDR status console active Sets/displays active console console answer Answer an incoming console call console autoanswer Sets/displays autoanswer console boost Sets/displays mic boost in dB console dial Dial an extension on the console console flash Flash a call on the console console hangup Hangup a call on the console console mute Disable mic input console send text Send text to the remote device console transfer Transfer a call to a different extension console unmute Enable mic input core clear profile Clear profiling info core set debug channel Enable/disable debugging on a channel core set debug Set level of debug chattiness core set debug off Turns off debug chattiness core set global Set global dialplan variable core set verbose Set level of verboseness core show applications Shows registered dialplan applications core show application Describe a specific dialplan application core show audio codecs Displays a list of audio codecs core show channels Display information on channels core show channel Display information on a specific channel core show channeltypes List available channel types core show channeltype Give more details on that channel type core show codecs Displays a list of codecs core show codec Shows a specific codec core show config mappings Display config mappings (file names to config engines) core show file formats Displays file formats core show file version List versions of files used to build Asterisk core show functions Shows registered dialplan functions core show function Describe a specific dialplan function core show globals Show global dialplan variables core show hints Show dialplan hints core show image codecs Displays a list of image codecs core show image formats Displays image formats core show license Show the license(s) for this copy of Asterisk core show profile Display profiling info core show switches Show alternative switches core show threads Show running threads core show translation Display translation matrix core show uptime Show uptime information core show version Display version info core show video codecs Displays a list of video codecs core show warranty Show the warranty (if any) for this copy of Asterisk database del Removes database key/value database deltree Removes database keytree/values database get Gets database value database put Adds/updates database value database show Shows database contents database showkey Shows database contents dialplan add extension Add new extension into context dialplan add ignorepat Add new ignore pattern dialplan add include Include context in other context dialplan reload Reload extensions and *only* extensions dialplan remove extension Remove a specified extension dialplan remove ignorepat Remove ignore pattern from context dialplan remove include Remove a specified include from context dialplan save Save dialplan dialplan show Show dialplan dnsmgr reload Reloads the DNS manager configuration dnsmgr status Display the DNS manager status dundi debug Enable DUNDi debugging dundi flush Flush DUNDi cache dundi lookup Lookup a number in DUNDi dundi no debug Disable DUNDi debugging dundi no store history Disable DUNDi historic records dundi precache Precache a number in DUNDi dundi query Query a DUNDi EID dundi show entityid Display Global Entity ID dundi show mappings Show DUNDi mappings dundi show peers Show defined DUNDi peers dundi show peer Show info on a specific DUNDi peer dundi show precache Show DUNDi precache dundi show requests Show DUNDi requests dundi show trans Show active DUNDi transactions dundi store history Enable DUNDi historic records feature show Lists configured features file convert Convert audio file group show channels Display active channels with group(s) help Display help list, or specific help on a command http show status Display HTTP server status iax2 provision Provision an IAX device iax2 prune realtime Prune a cached realtime lookup iax2 reload Reload IAX configuration iax2 set debug Enable IAX debugging iax2 set debug jb Enable IAX jitterbuffer debugging iax2 set debug jb off Disable IAX jitterbuffer debugging iax2 set debug off Disable IAX debugging iax2 set debug trunk Enable IAX trunk debugging iax2 set debug trunk off Disable IAX trunk debugging iax2 show cache Display IAX cached dialplan iax2 show channels List active IAX channels iax2 show firmware List available IAX firmwares iax2 show netstats List active IAX channel netstats iax2 show peers List defined IAX peers iax2 show peer Show details on specific IAX peer iax2 show provisioning Display iax provisioning iax2 show registry Display IAX registration status iax2 show stats Display IAX statistics iax2 show threads Display IAX helper thread info iax2 show users List defined IAX users iax2 test losspct Set IAX2 incoming frame loss percentage indication add Add the given indication to the country indication remove Remove the given indication from the country indication show Display a list of all countries/indications keys init Initialize RSA key passcodes keys show Displays RSA key information local show channels List status of local channels logger mute Toggle logging output to a console logger reload Reopens the log files logger rotate Rotates and reopens the log files logger show channels List configured log channels manager show command Show a manager interface command manager show commands List manager interface commands manager show connected List connected manager interface users manager show eventq List manager interface queued events manager show users List configured manager users manager show user Display information on a specific manager user mgcp audit endpoint Audit specified MGCP endpoint mgcp reload Reload MGCP configuration mgcp set debug Enable MGCP debugging mgcp set debug off Disable MGCP debugging mgcp show endpoints List defined MGCP endpoints mixmonitor Execute a MixMonitor command. module load Load a module by name module reload Reload configuration module show List modules and info module show like List modules and info module unload Unload a module by name moh reload Music On Hold moh show classes List MOH classes moh show files List MOH file-based classes no debug channel originate Originate a call queue add member Add a channel to a specified queue queue remove member Removes a channel from a specified queue queue show Show status of a specified queue realtime load Used to print out RealTime variables. realtime pgsql status Shows connection information for the Postgresql RealTime driver realtime update Used to update RealTime variables. restart gracefully Restart Asterisk gracefully restart now Restart Asterisk immediately restart when convenient Restart Asterisk at empty call volume rtcp debug ip Enable RTCP debugging on IP rtcp debug Enable RTCP debugging rtcp debug off Disable RTCP debugging rtcp stats Enable RTCP stats rtcp stats off Disable RTCP stats rtp debug ip Enable RTP debugging on IP rtp debug Enable RTP debugging rtp debug off Disable RTP debugging say load set/show the say mode show parkedcalls Lists parked calls show queues sip history Enable SIP history sip history off Disable SIP history sip notify Send a notify packet to a SIP peer sip prune realtime Prune cached Realtime object(s) sip prune realtime peer Prune cached Realtime peer(s) sip prune realtime user Prune cached Realtime user(s) sip reload Reload SIP configuration sip set debug Enable SIP debugging sip set debug ip Enable SIP debugging on IP sip set debug off Disable SIP debugging sip set debug peer Enable SIP debugging on Peername sip show channels List active SIP channels sip show channel Show detailed SIP channel info sip show domains List our local SIP domains. sip show history Show SIP dialog history sip show inuse List all inuse/limits sip show objects List all SIP object allocations sip show peers List defined SIP peers sip show peer Show details on specific SIP peer sip show registry List SIP registration status sip show settings Show SIP global settings sip show subscriptions List active SIP subscriptions sip show users List defined SIP users sip show user Show details on specific SIP user skinny reset Reset Skinny device(s) skinny set debug Enable Skinny debugging skinny set debug off Disable Skinny debugging skinny show devices List defined Skinny devices skinny show lines List defined Skinny lines per device soft hangup Request a hangup on a given channel stop gracefully Gracefully shut down Asterisk stop now Shut down Asterisk immediately stop when convenient Shut down Asterisk at empty call volume stun debug Enable STUN debugging stun debug off Disable STUN debugging udptl debug Enable UDPTL debugging udptl debug ip Enable UDPTL debugging on IP udptl debug off Disable UDPTL debugging voicemail show users List defined voicemail boxes voicemail show zones List zone message formats *CLI> [Jan 20 16:15:05] NOTICE[6579]: chan_sip.c:15094 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 1001 |
|
來自: shangat > 《Linux 文章》