Asterisk http downloads oreilly combooks978 0596510480 pdf Asterisk
Asterisk 系統架構與說明 http: //downloads. oreilly. com/books/978 0596510480. pdf
Asterisk 系統架構與介紹 • 什麼是Asterisk PSTN Vo. IP
簡單的應用 Basic Extension(Dialplan) Basic Web page(HTML) exten <html> => => 100, 1, Answer() 100, n, wait(1) 100, n, Play(hello) Hangup() <head> </head> <body> <h 1>Hello World!</h 1> </body> </html>
Asterisk 硬體測試結果 • 硬體 : • AMD Athlon 64 X 2 4200 • 1 G RAM • 80 G SATA • 測試方式 : SIP call • Connection • Wait • Play audio • disconnection 同時通話數 330 550 CPU 使用率 149% 14. 8% 57. 6% 平均負載 49 25 60 儲存裝置 硬碟 RAM Disk
Asterisk 軟體系統
Asterisk : System Service Linux Operating System Web DNS DHCP mail proxy firewall
Asterisk : module channels Linux Operating System SIP IAX 2 Skype DAHDI
Asterisk : module resource Linux Operating System SIP IAX 2 Skype DAHDI CDR Codec Format Config
Asterisk : Command Line Interface Linux Operating System SIP IAX 2 Skype DAHDI Codec Format Config CLI CDR
Asterisk : Applications and Functions Linux Operating System SIP IAX 2 Skype CLI DAHDI Applications Functions CDR Codec Format Config
Asterisk : Manager Interface(AMI) Linux Operating System SIP IAX 2 Skype Applications CLI AMI CDR DAHDI Dialplan Codec Format Functions Config
Asterisk : Manager Interface(AMI) Linux Operating System SIP IAX 2 Skype Applications CLI AMI CDR DAHDI Dialplan Codec Format Functions Config
Asterisk Call flow • B 2 BUA : Back to Back User Agent PSTN Internet
Asterisk Call process 101 Ring! Phone 102 SIP channel driver sip. conf [100] type=friend host=dynamic context=inside Phone 101 PBX Engine SIP channel driver extensions. conf [inside] exten => 101, 1, Dial(SIP/101, 20) exten => 101, n, Voicemail(101) exten => 102, 1, Dial(SIP/102, 20) exten => 102, n, Voicemail(102)
Asterisk : Connectivity
Asterisk Solution : PBX
Asterisk • 全球已經有非常多以Asterisk • • • Freepbx Elastix PBX in a flash • 有非常多的硬體廠商 • • • Digium Sangoma Voicetronix • 有非常多的add-on • • • CDR ODBC Voicemail Security Conference 為基礎的系統
Digium’s Asterisk. NOW
Asterisk Applications • Vo. IP Gateway • IVR • Call Center • Conference Bridge
Asterisk 系統建置 Asterisk 系統調整 SIP client 軟體(Windows/Mac) SIP Client軟體(for Android) SIP hardphone SIP. conf Extension. conf tcpdump/Wireshark Asterisk CLI command
相關連結 • 使用手冊 • http: //ofps. oreilly. com/titles/9780596517342/index. html • Asterisk. NOW • https: //www. asterisk. org/downloads • SIP Client • Windows • http: //www. counterpath. com/x-lite-4 -for-windows-download. html • Mac • http: //www. counterpath. com/x-lite-4 -for-mac-download. html • i. Pad • http: //www. counterpath. com/bria-ipad-edition. html • Android • https: //play. google. com/store/apps/details? id=com. csipsimple&hl=zh_TW • Wireshark • https: //www. wireshark. org/download. html
Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW
Installing Asterisk. NOW • 要� 動的服務 • httpd • ntpd • sendmail • sshd
新增系統管理者 • 一般來說, 使用root 帳號做為管理有極大的風險. • 建議新增一個非root 的管理者, 但使用權限與root 相近. • 透過adduser command 可以新增一個使用者. • 密碼切勿使用範例或易猜的數字、英文名. # adduser asteriskpbx # passwd asteriskpbx Changing password for user asteriskpbx. New UNIX password: Retype new UNIX password:
asterisk. conf • The [directories] Section • Table. Value/Example Option Notes astetcdir /etc/asterisk The location where the Asterisk configuration files are stored. astmoddir /usr/lib/asterisk/modules The location where loadable modules are stored. astvarlibdir /var/lib/asterisk The base location for variable state information used by various parts of Asterisk. This includes items that are written out by Asterisk at runtime. astdbdir /var/lib/asterisk Asterisk will store its internal database in this directory as a file called astdb. astkeydir /var/lib/asterisk Asterisk will use a subdirectory called keys in this directory as the default location for loading keys for encryption. astdatadir /var/lib/asterisk This is the base directory for system-provided data, such as the sound files that come with Asterisk. astagidir /var/lib/asterisk/ agi-bin Asterisk will use a subdirectory called agi-bin in this directory as the default location for loading AGI scripts. astspooldir /var/spool/asterisk The Asterisk spool directory, where voicemail, call recordings, and the call origination spool are stored. astrundir /var/run/asterisk The location where Asterisk will write out its UNIX control socket as well as its process ID (PID) file. astlogdir /var/log/asterisk The directory where Asterisk will store its log files.
asterisk. conf • The Option [options] Section - 1 Value/Example Notes verbose 3 Sets the default verbose setting for the Asterisk logger. This value is also set by the -v command-line option. The verbose level is 0 by default. debug 3 Sets the default debug setting for the Asterisk logger. This value is also set by the -d command-line option. The debug level is 0 by default. alwaysfork yes Forking forces Asterisk to always run in the background. This option is set to no by default. nofork yes Forces Asterisk to always run in the foreground. This option is set to no by default. quiet yes Quiet mode reduces the amount of output seen at the console when Asterisk is run in the foreground. This option is set to no by default. timestamp yes Adds timestamps to all output except output from a CLI command. This option is set to noby default. execincludes yes Enables the use of #exec in Asterisk configuration files. This option is set to no by default. console yes Runs Asterisk in console mode. Asterisk will run in the foreground and will present a prompt for CLI commands. This option is set to no by default.
asterisk. conf • The [options] Section - 2 Option Value/E xample Notes highpriority yes Runs the Asterisk application with real-time priority. This option is set to no by default. initcrypto yes Loads keys from the astkeydir at startup. This option is set to no by default. [a] nocolor yes Suppresses color output from the Asterisk console. This is useful when saving console output to a file. This option is set to no by default. dontwarn yes Disables a few warning messages. This option was put in place to silence warnings that are generally correct, but may be considered to be so obvious that they become an annoyance. This option is set to no by default. dumpcore yes Tells Asterisk to generate a core dump in the case of a crash. This option is set to no by default. [b] yes Configures how the prompt language is used in building the path for a sound file. By default, this is yes, which places the language before any subdirectories, such asen/digits/1. gsm. Setting this option to no causes Asterisk to behave as it did in previous versions, placing the language as the last directory in the path, (e. g. digits/en/1. gsm). languageprefix
asterisk. conf • The [options] Section - 3 Option Value/E xample Notes internal_timing yes Uses a timing source to synchronize audio that will be sent out to a channel in cases such as file playback or music on hold. This option is set to yes by default and should be left that way; its usefulness has greatly diminished over the last few major versions of Asterisk. systemname my_ syste m _name Gives this instance of Asterisk a unique name. When this has been set, the system name will be used as part of the uniqueid field for channels. This is incredibly useful if more than one system will be logging CDRs to the same database table. By default, this option is not set. autosystemnam e yes Automatically sets the system name by using the hostname of the system. This option is set tono by default. maxcalls 100 Sets a maximum number of simultaneous inbound channels. No limit is set by default. maxload 0. 9 Sets a maximum load average. If the load average is at or above this threshold, Asterisk will not accept new calls. No threshold is set by default. 1 Sets the minimum number of megabytes of free memory required for Asterisk to continue accepting calls. If Asterisk detects that there is less free memory available than this threshold, new calls will not be accepted. This option is not set by default. minmemfree
asterisk. conf • The [options] Section - 4 Option Value/Ex ample Notes runuser asterisk Sets the system user that the Asterisk application should run as. This option is not set by default, meaning that the application will continue to run as the user that executed the application. rungroup asterisk Sets the system group that the Asterisk application should run as. This option is not set by default. en_US The built-in documentation for Asterisk applications, functions, and other things is included in an external XML document. This option specifies the preferred language for documentation. If it is not available, the default of en_US will be used. yes Setting this option to yes causes Asterisk to not display notifications of remote console connections and disconnections at the Asterisk CLI. This is useful on systems where there are scripts that use remote consoles heavily. The default setting is no. no When this option is enabled, the Asterisk configuration directory will be protected with a lock. This helps protect against having more than one application attempting to write to the same file at the same time. The default value isno. documentation_l anguage hideconnect lockconfdir
asterisk. conf • The [files] Section Option Value/Example Notes astctlpermissions 0660 Sets the permissions for the Asterisk control socket. astctlowner root Sets the owner for the Asterisk control socket. astctlgroup apache Sets the group for the Asterisk control socket. astctl asterisk. ctl Sets the filename for the Asterisk control socket. The default is asterisk. ctl.
asterisk. conf • The Option pbx_realtime res_agi app_set [compat] Section Value/Example Notes 1. 6 In versions earlier than Asterisk 1. 6. x, thepbx_realtime module would automatically convert pipe characters into commas for arguments to Asterisk applications. This is no longer done by default. To enable this previous behavior, set this option to 1. 4. 1. 6 In versions earlier than Asterisk 1. 6. x, the. EXEC AGI command would automatically convert pipe characters into commas for arguments to Asterisk applications. This is no longer done by default. To enable this previous behavior, set this option to 1. 4. 1. 6 Starting with the Asterisk 1. 6. x releases, the. Set() application only allows setting the value of a single variable. Previously, Set() would allow setting more than one variable by separating them with a &. This was done to allow any characters in the value of a variable, including the & character, which was previously used as a separator. MSet() is a new application that behaves like Set() used to. However, setting this option to 1. 4 makes. Set() behave like MSet().
modules. conf • The Option [modules] Section Value/Example Notes yes Instead of explicitly listing which modules to load, you can use this directive to tell Asterisk to load all modules that it finds in the modules directory, with the exception of modules listed as not to be loaded using the noload directive. The default, and our recommendation, is to set this option to yes. preload res_odbc. so Indicates that a module should be loaded at the beginning of the module load order. This directive is much less relevant than it used to be; modules now have a load priority built into them that solves the problems that this directive was previously used to solve. load chan_sip. so Defines a module that should be loaded. This directive is only relevant if autoload is set to no. noload chan_alsa. so Defines a module that should not be loaded. This directive is only relevant if autoload is set to yes. require chan_sip. so Does the same thing as load; additionally, Asterisk will exit if this module fails to load for some reason. preload-require res_odbc. so Does the same thing as preload; additionally, Asterisk will exit if this module fails to load for some reason. autoload
musiconhold. conf • 音效檔路徑 • /var/lib/asterisk/moh • 也可以取得免費的音樂, 重新convert後置於上述路徑. • DBS ITCrew Free MOH: CC BY-SA (free, royalty free, commercially usable) on hold music. • Star. Tel Free Music On Hold: Download Royalty Free Music for your PBX • 建議將音效檔轉成asterisk • *. sln • *. wav • *. pcm • *. gsm 可能有效應用的檔案為最佳:
Sip. conf
設定sip. conf • 輸入[general] context=unauthenticated allowguest=no 號 srvlookup=yes � udpbindaddr=0. 0 面的service port tcpenable=no 做為服務port ; 預設撥進來的context ; 不充許未經許可的撥 ; 將DNS� 詢的功能開 ; 使用udp 做為所有介 ; 不使用 tcp port
設定sip. conf • 設定sip channel 和 設備 [000 F 90 B 0 B 771] type=friend 比對 ; 定義一個section ; Channel driver 會先去 ; honst name, 再比對IP context=Local. Sets dialplan host=dynamic asterisk註冊 nat=yes 後 secret=s 3 Cu. R#p@s 5 dtmfmode=auto disallow=all reset allow=ulaw allow=alaw ; 指定由此進來的call 所對應的 ; 此設定IP動態, 要跟 ; 此設備可在 NAT ; 指定此設備的密碼; ; 接受dtmf ; 將此設備可接受的codec ; 此設備可使用ulaw ; 此設備可使用alaw
extensions. conf
設定extensions. conf [Local. Sets] exten => 900, 1, Answer() exten => 900, 2, Play. Back(hello-world) Exten => 900, 3, Hangup()
* Sip. conf *
* * 設定sip. conf • 輸入[general] context=unauthenticated ; 預設撥進來的context, 因為我們不會另外 ; 設定一個叫 unauthenticated 的context, ; 即表示進來的 需求, 如果不在我們設定的 ; context內, 那就不會被接受 allowguest=no srvlookup=yes udpbindaddr=0. 0 port tcpenable=no ; 不充許未經許可的撥號 ; 將DNS� 詢的功能開� ; 使用udp 做為所有介面的service ; 不使用 tcp port 做為服務port
* * 設定sip. conf • 設定sip channel 和 設備 [c 42 c 031 ed 01 d] type=friend 去比對 ; 定義一個 section ; Channel driver 會先 ; honst name, 再比對IP context=Local. Sets dialplan host=dynamic nat=yes secret=s 3 Cu. R#p@s 5 dtmfmode=auto disallow=all reset allow=ulaw allow=alaw ; 指定由此進來的call 所對應的 ; 此設定IP動態, 要跟asterisk註冊 ; 此設備可在 NAT 後 ; 指定此設備的密碼; ; 接受dtmf ; 將此設備可接受的codec ; 此設備可使用ulaw ; 此設備可使用alaw
* Sip. conf • type = friend *
* Don’t forget (or sip_custom. conf), 因此要讓asterisk 知道有新的設定. • 重新� 動sip的方式: • 因為已重新設定過sip. conf • 在linux shell下: #asterisk -x 'sip reload' • 在asterisk CLI下: localhost*CLI> sip reload *
* extension s. conf *
* 設定extensions. conf • extensions_custom. conf [Local. Sets] exten => 900, 1, Answer() exten => 900, 2, Play. Back(hello-world) Exten => 900, 3, Hangup() *
sip. conf 與 extensions. conf sip. conf [123456789 ABC 0] context=Local. Sets_A extensions. conf [general] [globals] [Local. Sets_A] exten => 105, 1, Dial(SIP/1234567 89 ABC 5] [123456789 ABC 5] host=dynamic
* 設定extensions. conf • 設定此設備的分機 [Local. Sets] exten => 100, 1, Dial(SIP/c 42 c 031 ed 01 d) ; 當撥 100時, 則對應到 000 F 90 B 0 B 771這個sip channel去 exten => 900, 1, Answer() exten => 900, 2, Play. Back(hello-world) exten => 900, 3, Hangup() *
- Slides: 70