這里先來個開場白,寫這個博客,是因為近來,研究車聯網,涉及到語音通話的需求,所以就想基於IP的通話解決方案,為用戶和公司打個經濟算盤。
VoIP通話,相關的背景介紹,就不浪費時間了,自己問度娘,這里我選擇比較經典的穩定性比較高的asterisk(Linux版本)作為VoIP通話的服務端解決方案,客戶端,也就是電話工具,選擇的是Yate Client(Window版本)。
基礎環境信息:
Linux:CentOS7,1C4G100G
Windows:Win10, 8C16G1T
Asterisk:asterisk-17-current.tar.gz
YateClient:yate-5.4.0-1-setup.exe
1.下載asterisk,libpri,dahdi(linux,tools,合並為complete)
https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-17-current.tar.gz (http://downloads.asterisk.org/pub/telephony/asterisk/或者在這里自行選擇) https://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz https://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
2.下面按順序安裝各個組件
2.1 安裝dahdi
先tar解壓,然后make,遇到下面的錯誤。缺乏kernel-devel
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make make -C linux all make[1]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make -C drivers/dahdi/firmware firmware-loaders make[2]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' You do not appear to have the sources for the 3.10.0-514.el7.x86_64 kernel installed. make[1]: *** [modules] Error 1 make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make: *** [all] Error 2
安裝上即可,kernel-devel在CentOS的安裝鏡像里面有,配置為yum源安裝即可。
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# yum install kernel-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package kernel-devel.x86_64 0:3.10.0-514.el7 will be installed --> Finished Dependency Resolution
然后,繼續make
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make make -C linux all make[1]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux' make -C drivers/dahdi/firmware firmware-loaders make[2]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi/firmware' make -C /lib/modules/3.10.0-514.el7.x86_64/build KBUILD_EXTMOD=/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/drivers/dahdi DAHDI_INCLUDE=/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/linux/include DAHDI_MODULES_EXTRA=" " HOTPLUG_FIRMWARE=yes modules DAHDI_BUILD_ALL=m make[2]: Entering directory `/usr/src/kernels/3.10.0-514.el7.x86_64' .... make[3]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' CC libtonezone_la-version.lo CCLD libtonezone.la CCLD fxstest CCLD patlooptest CC version.o CCLD dahdi_maint CCLD dahdi_cfg make -f ./Makefile.legacy top_srcdir=. srcdir=. all make[4]: Entering directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[4]: Nothing to be done for `all'. make[4]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[3]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' [root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]#
然后,make install
.... ################################################### ### ### DAHDI installed successfully. ### If you have not done so before, install the package ### dahdi-tools. ### ################################################### .... ################################################### ### ### DAHDI tools installed successfully. ### If you have not done so before, install init scripts with: ### ### make install-config ### ################################################### .... mkdir -p /etc/bash_completion.d install -m 644 ./dahdi-bash-completion /etc/bash_completion.d/dahdi make[4]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[3]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[2]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' make[1]: Leaving directory `/usr/local/src/voip/dahdi-linux-complete-3.1.0+3.1.0/tools' [root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]#
然后, make config
[root@tkiot-isc1 dahdi-linux-complete-3.1.0+3.1.0]# make config make: Nothing to be done for `config'
2.2 安裝libpri
用tar命令解壓,然后安裝
[root@tkiot-isc1 libpri-1.6.0]# make [root@tkiot-isc1 libpri-1.6.0]# make install
2.3 安裝asterisk
2.3.1 配置configure
[root@tkiot-isc1 asterisk-17.5.0]# ./configure checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking whether char is unsigned... no checking for uname... /usr/bin/uname checking for g++... no checking for c++... no checking for gpp... no checking for aCC... no checking for CC... no checking for cxx... no checking for cc++... no checking for cl.exe... no checking for FCC... no checking for KCC... no checking for RCC... no checking for xlC_r... no checking for xlC... no checking whether we are using the GNU C++ compiler... no checking whether g++ accepts -g... no checking how to run the C preprocessor... gcc -E checking how to run the C++ preprocessor... /lib/cpp configure: error: in `/usr/local/src/voip/asterisk-17.5.0': configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details [root@tkiot-isc1 asterisk-17.5.0]#
上述錯誤,是系統缺乏插件
yum install glibc-headers
yum install gcc-c++
安裝結束后,再次configure,依然報錯
configure: error: patch is required to configure bundled pjproject
需要安裝patch依賴
yum install patch
依然報錯:
checking for a sed that does not truncate output... (cached) /usr/bin/sed checking whether gcc is Clang... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking whether more special flags are required for pthreads... no checking for PTHREAD_PRIO_INHERIT... yes checking for RAII support... checking for gcc -fnested-functions... no checking for clang strsep/strcmp optimization... no checking for embedded pjproject (may have to download)... configuring [pjproject] Downloading https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.9/pjproject-2.9.tar.bz2 to /tmp/pjproject-2.9.tar.bz2 [pjproject] Retrying download [pjproject] Downloading https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/2.9/pjproject-2.9.tar.bz2 to /tmp/pjproject-2.9.tar.bz2 make: *** [/tmp/pjproject-2.9.tar.bz2] Error 4 make: *** Deleting file `/tmp/pjproject-2.9.tar.bz2' failed configure: Unable to configure third-party/pjproject configure: error: Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details.
顯示pjproject下載不下來,我只能選擇手動下載安裝,因為我的機器不能上外網。https://github.com/pjsip/pjproject/releases/tag/2.9,從這里下載2.9版本,當前最新的版本是2.10. 解壓tar包后,進行安裝,三步走(configure,make,make install)
1) 參考文檔(https://wiki.asterisk.org/wiki/display/AST/PJSIP-pjproject),有些注意細節
./configure --libdir=/usr/lib64 CFLAGS='-O2 -DNDEBUG'
2) make dep & make
3) make install
4) ldconfig (更新庫的鏈接)
5) ldconfig -p | grep pj (校驗動態庫鏈接的更新情況)
然后繼續上面的asterisk的configure。提示還是存在上述pjproject-2.9.tar.bz2配置不成功的問題,於是,按照下面的指令操作。這里--without-pjproject-bundled表示不用asterisk自帶的pjproject包,可以采用外部安裝的pjproject,如前面已經安裝的。
[root@tkiot-isc1 asterisk-17.5.0]# ./configure --without-pjproject-bundled --libdir=/usr/lib64 .... checking utime.h usability... yes checking utime.h presence... yes checking for utime.h... yes checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for LIBEDIT... no checking for history_init in -ledit... no configure: error: *** Please install the 'libedit' development package.
參考網上的經驗,在CentOS下安裝asterisk,需要的依賴都裝上
yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel
這里,我的機器yum install libedit-devel不成功,后來,下載libedit的rpm包安裝成功,繼續configure,還是報下面的錯誤:
checking uuid/uuid.h presence... yes checking for uuid/uuid.h... yes checking for JANSSON... no checking for json_sprintf in -ljansson... no configure: *** Asterisk requires libjansson >= 2.11 and no system copy was found. configure: *** Please install the 'libjansson' development package or configure: *** use './configure --with-jansson-bundled'
在這里,我從http://digip.org/jansson/releases/網站下載了2.12版本的,解壓,configure&&make&&make install后,再進行asterisk的configure就ok了,得到下面的期待的效果:
checking for ncurses.h... (cached) yes checking for a sed that does not truncate output... /usr/bin/sed checking for xml2-config... /bin/xml2-config checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for GTK2... yes configure: creating ./config.status config.status: creating makeopts config.status: creating autoconfig.h configure: Menuselect build configuration successfully completed .$$$$$$$$$$$$$$$=.. .$7$7.. .7$$7:. .$$:. ,$7.7 .$7. 7$$$$ .$$77 ..$$. $$$$$ .$$$7 ..7$ .?. $$$$$ .?. 7$$$. $.$. .$$$7. $$$$7 .7$$$. .$$$. .777. .$$$$$$77$$$77$$$$$7. $$$, $$$~ .7$$$$$$$$$$$$$7. .$$$. .$$7 .7$$$$$$$7: ?$$$. $$$ ?7$$$$$$$$$$I .$$$7 $$$ .7$$$$$$$$$$$$$$$$ :$$$. $$$ $$$$$$7$$$$$$$$$$$$ .$$$. $$$ $$$ 7$$$7 .$$$ .$$$. $$$$ $$$$7 .$$$. 7$$$7 7$$$$ 7$$$ $$$$$ $$$ $$$$7. $$ (TM) $$$$$$$. .7$$$$$$ $$ $$$$$$$$$$$$7$$$$$$$$$.$$$$$$ $$$$$$$$$$$$$$$$. configure: Package configured for: configure: OS type : linux-gnu configure: Host CPU : x86_64 configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu : configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
2.3.2 編譯asterisk
[root@tkiot-isc1 asterisk-17.5.0]# make ...... [CC] stasis_recording/stored.c -> stasis_recording/stored.o [LD] res_stasis_recording.o stasis_recording/stored.o -> res_stasis_recording.so Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons +--------- Asterisk Build Complete ---------+ + Asterisk has successfully been built, and + + can be installed by running: + + + + make install + +-------------------------------------------+
2.3.3 安裝asterisk
[root@tkiot-isc1 asterisk-17.5.0]# make install Installing modules from channels... Installing modules from pbx... Installing modules from apps... Installing modules from codecs... Installing modules from formats... Installing modules from cdr... Installing modules from cel... Installing modules from bridges... Installing modules from funcs... Installing modules from tests... Installing modules from main... Installing modules from res... Installing modules from addons... ...... +---- Asterisk Installation Complete -------+ + + + YOU MUST READ THE SECURITY DOCUMENT + + + + Asterisk has successfully been installed. + + If you would like to install the sample + + configuration files (overwriting any + + existing config files), run: + + + + For generic reference documentation: + + make samples + + + + For a sample basic PBX: + + make basic-pbx + + + + + +----------------- or ---------------------+ + + + You can go ahead and install the asterisk + + program documentation now or later run: + + + + make progdocs + + + + **Note** This requires that you have + + doxygen installed on your local system + +-------------------------------------------+
2.3.4 生成asterisk的配置文件
[root@tkiot-isc1 asterisk-17.5.0]# make samples Installing adsi config files... /usr/bin/install -c -d "/etc/asterisk" Installing configs/samples/asterisk.adsi Installing configs/samples/telcordia-1.adsi Installing other config files... Installing file configs/samples/acl.conf.sample Installing file configs/samples/adsi.conf.sample Installing file configs/samples/agents.conf.sample Installing file configs/samples/alarmreceiver.conf.sample Installing file configs/samples/alsa.conf.sample Installing file configs/samples/amd.conf.sample ...... Installing file configs/samples/xmpp.conf.sample Updating asterisk.conf /usr/bin/install -c -d "/var/spool/asterisk/voicemail/default/1234/INBOX" build_tools/make_sample_voicemail "//var/lib/asterisk" "//var/spool/asterisk" Installing file phoneprov/000000000000.cfg Installing file phoneprov/000000000000-directory.xml Installing file phoneprov/000000000000-phone.cfg Installing file phoneprov/polycom_line.xml Installing file phoneprov/polycom.xml Installing file phoneprov/snom-mac.xml
從日志中可以看出,配置文件,主要在目錄/etc/asterisk下面
2.3.5 生成配置項菜單列表menuselect
[root@tkiot-isc1 asterisk-17.5.0]# make menuselect ************************************************** Asterisk Module and Build Option Selection ************************************************** Press 'h' for help. ---> Add-ons (See README-addons.txt) Applications Bridging Modules Call Detail Recording Channel Event Logging Channel Drivers Codec Translators Format Interpreters Dialplan Functions PBX Modules Resource Modules Test Modules Compiler Flags Utilities AGI Samples Core Sound Packages Music On Hold File Packages Extras Sound Packages
這是一個字符菜單,光標上下滑動選擇,回車鍵確認,進入子菜單,向左鍵回退上一級菜單
2.3.6 安裝asterisk的初始化腳本
[root@tkiot-isc1 asterisk-17.5.0]# make config
2.3.7 安裝日志工具logrotate
[root@tkiot-isc1 asterisk-17.5.0]# make install-logrotate
主要是方便日志的回滾管理,方便后續問題追溯
2.3.8 查看asterisk所需的依賴是否都在
[root@tkiot-isc1 asterisk-17.5.0]# cd contrib/scripts [root@tkiot-isc1 scripts]# ./install_prereq install Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile No package jansson-devel available. No package speex-devel available. No package speexdsp-devel available. No package libogg-devel available. No package libvorbis-devel available. No package portaudio-devel available. No package xmlstarlet available. No package neon-devel available. No package gmime-devel available. No package lua-devel available. No package uriparser-devel available. Package 1:mariadb-devel-5.5.52-1.el7.x86_64 already installed and latest version No package bluez-libs-devel available. No package radcli-devel available. No package freetds-devel available. No package jack-audio-connection-kit-devel available. No package iksemel-devel available. No package corosynclib-devel available. No package newt-devel available. No package spandsp-devel available. No package libresample-devel available. No package uw-imap-devel available. No package libsrtp-devel available. No package gsm-devel available. No package hoard available. No package codec2-devel available. No package libsndfile-devel available. No package unbound-devel available. Nothing to do ############################################# ## install completed successfully #############################################
自己在網上,將上述依賴的包,都裝上即可
這里需要說明一個小小的技巧,針對rpm安裝中出現A依賴B,但是B又依賴A的問題,可以通過將要安裝的包在一個命令里面進行安裝,並且在命令行后面加上參數 -aid。下面是freetds依賴freetds-libs,但是freetds-libs又依賴freetds的場景。
[root@tkiot-isc1 voip]# rpm -ivh freetds-1.1.20-1.el7.x86_64.rpm warning: freetds-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: freetds-libs(x86-64) = 1.1.20-1.el7 is needed by freetds-1.1.20-1.el7.x86_64 libsybdb.so.5()(64bit) is needed by freetds-1.1.20-1.el7.x86_64 [root@tkiot-isc1 voip]# rpm -ivh freetds-libs-1.1.20-1.el7.x86_64.rpm warning: freetds-libs-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY error: Failed dependencies: freetds = 1.1.20-1.el7 is needed by freetds-libs-1.1.20-1.el7.x86_64
解決的辦法如下:
[root@tkiot-isc1 voip]# rpm -ivh freetds-* -aid warning: freetds-1.1.20-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:freetds-libs-1.1.20-1.el7 ################################# [ 33%] 2:freetds-1.1.20-1.el7 ################################# [ 67%] 3:freetds-devel-1.1.20-1.el7 ################################# [100%]
說明:對於僅僅是打通IP之間的電話,即純粹的網絡電話,這一步中的prerequisite的package,是不用全都安裝完安裝好的
3. 驗證安裝的效果
3.1 首先看asterisk的安裝是否OK
[root@tkiot-isc1 asterisk-17.5.0]# service asterisk start Starting asterisk (via systemctl): [ OK ] [root@tkiot-isc1 asterisk-17.5.0]# [root@tkiot-isc1 asterisk-17.5.0]# service asterisk status ● asterisk.service - LSB: Asterisk PBX Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled) Active: active (running) since Thu 2020-06-18 16:57:55 CST; 4s ago Docs: man:systemd-sysv-generator(8) Process: 21876 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS) Main PID: 21905 CGroup: /system.slice/asterisk.service ├─21901 /bin/sh /usr/sbin/safe_asterisk └─21911 sleep 4 Jun 18 16:57:54 tkiot-isc1 systemd[1]: Starting LSB: Asterisk PBX... Jun 18 16:57:55 tkiot-isc1 asterisk[21876]: Starting asterisk: Jun 18 16:57:55 tkiot-isc1 systemd[1]: PID file /var/run/asterisk/asterisk.pid not readable (yet?) after start. Jun 18 16:57:55 tkiot-isc1 systemd[1]: asterisk.service: Supervising process 21905 which is not our child. We'll most likely not notice when it exits. Jun 18 16:57:55 tkiot-isc1 systemd[1]: Started LSB: Asterisk PBX.
3.2 遠程連接驗證
[root@tkiot-isc1 asterisk-17.5.0]# asterisk -rvvv
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
這里遇到了問題,怎么解決呢?在網上查詢了很多方法,都試過了不能解決問題,什么文件權限,什么配置啥的,都不管用。我是在執行asterisk -cvvv的指令時,有提示下面的信息得到的啟發:
[root@tkiot-isc1 ~]$ asterisk -cvvv Asterisk 17.5.0, Copyright (C) 1999 - 2018, Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Manager registered action DBGet Manager registered action DBPut Manager registered action DBDel Manager registered action DBDelTree PBX UUID: 66ed4c43-ba2e-467c-b2b6-0ad8705d02d8 There was a problem finding jansson 2.11 runtime libraries. Please rebuild Asterisk using ./configure --with-jansson-bundled. libjansson initialization failed. ASTERISK EXITING! Manager unregistered action DBGet Manager unregistered action DBPut Manager unregistered action DBDel Manager unregistered action DBDelTree
說明啥呢,jansson這個插件沒有安裝好。於是,我再次進入到jansson的包,從configure,make,make install再次執行了邊。這里最大的可能就是configure出了問題,因為其他的安裝,我都制定了--libdir=/usr/lib64,唯獨這個安裝沒有指定,於是乎,這么一來,還真就解決了問題。

[root@tkiot-isc1 asterisk-17.5.0]# asterisk -rvvvv Asterisk 17.5.0, Copyright (C) 1999 - 2018, Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= Connected to Asterisk 17.5.0 currently running on tkiot-isc1 (pid = 3717) tkiot-isc1*CLI> tkiot-isc1*CLI> core show help ! -- Execute a shell command acl show -- Show a named ACL or list all named ACLs ael reload -- Reload AEL configuration ael set debug {read|tokens|macros|contexts|off} -- Enable AEL debugging flags agent logoff -- Sets an agent offline agent show all -- Show status of all agents agent show online -- Show status of online agents agent show -- Show information about an agent agi dump html -- Dumps a list of AGI commands in HTML format agi exec -- Add AGI command to a channel in Async AGI agi set debug [on|off] -- Enable/Disable AGI debugging agi show commands [topic] -- List AGI commands or specific help aoc set debug -- enable cli debugging of AOC messages ari mkpasswd -- Encrypts a password ari set debug -- Enable/disable debugging of an ARI application ari show apps -- List registered ARI applications ari show app -- Display details of a registered ARI application ari show status -- Show ARI settings ari show users -- List ARI users ari show user -- List single ARI user bridge kick -- Kick a channel from a bridge bridge show all -- List all bridges bridge show -- Show information about a bridge bridge technology show -- List registered bridge technologies bridge technology {suspend|unsuspend} -- Suspend/unsuspend a bridge technology calendar dump sched -- Dump calendar sched context calendar show calendar -- Display information about a calendar calendar show calendars -- Show registered calendars calendar show types -- Show all calendar types loaded cc cancel [core|all] -- Kill a CC transaction cc report status -- Reports CC stats cdr set debug [on|off] -- Enable debugging in the CDR engine cdr show active -- Display active CDRs for channels cdr show pgsql status -- Show connection status of the PostgreSQL CDR driver (cdr_pgsql) cdr show status -- Display the CDR status cdr submit -- Posts all pending batched CDR data cel show status -- Display the CEL status channel originate -- Originate a call channel redirect -- Redirect a call channel request hangup -- Request a hangup on a given channel cli check permissions -- Try a permissions config for a user cli reload permissions -- Reload CLI permissions config cli show aliases -- Show CLI command aliases cli show permissions -- Show CLI permissions confbridge kick -- Kick participants out of conference bridges. confbridge list -- List conference bridges and participants. confbridge lock -- Lock a conference. confbridge mute -- Mute participants. confbridge record start -- Start recording a conference confbridge record stop -- Stop recording a conference. confbridge show menu -- Show a conference menu confbridge show menus -- Show a list of conference menus confbridge show profile bridge -- Show a conference bridge profile. confbridge show profile bridges -- Show a list of conference bridge profiles. confbridge show profile user -- Show a conference user profile. confbridge show profile users -- Show a list of conference user profiles. confbridge unlock -- Unlock a conference. confbridge unmute -- Unmute participants. config list -- Show all files that have loaded a configuration file config reload -- Force a reload on modules using a particular configuration file config show help -- Show configuration help for a module console answer -- Answer an incoming console call 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|unmute} [toggle] -- Disable/Enable mic input console send text -- Send text to the remote device console transfer -- Transfer a call to a different extension console {device} -- Generic console command console {set|show} autoanswer [on|off] -- Sets/displays autoanswer console {set|show} active [<device>] -- Sets/displays active console core abort shutdown -- Cancel a running shutdown core clear profile -- Clear profiling info core ping taskprocessor -- Ping a named task processor core reload -- Global reload core reset taskprocessor -- Reset a named task processor's stats core reset taskprocessors -- Reset all task processors' stats core restart gracefully -- Restart Asterisk gracefully core restart now -- Restart Asterisk immediately core restart when convenient -- Restart Asterisk at empty call volume core set debug channel -- Enable/disable debugging on a channel core set debug -- Set level of debug chattiness core set verbose -- Set level of verbose chattiness core show applications [like|describing] -- Shows registered dialplan applications core show application -- Describe a specific dialplan application core show calls [uptime] -- Display information on calls core show channels [concise|verbose|count] -- 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 [audio|video|image|text] -- Displays a list of registered 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 functions [like] -- Shows registered dialplan functions core show function -- Describe a specific dialplan function core show hanguphandlers all -- Show hangup handlers of all channels core show hanguphandlers -- Show hangup handlers of a specified channel core show help -- Display help list, or specific help on a command core show hints -- Show dialplan hints core show hint -- Show dialplan hint 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 settings -- Show some core settings core show sounds -- Shows available sounds core show sound -- Shows details about a specific sound core show switches -- Show alternative switches core show sysinfo -- Show System Information core show taskprocessor alerted subsystems -- List task processor subsystems in alert core show taskprocessors [like] -- List instantiated task processors and statistics core show threads -- Show running threads core show translation -- Display translation matrix core show uptime [seconds] -- Show uptime information core show version -- Display version info core show warranty -- Show the warranty (if any) for this copy of Asterisk core stop gracefully -- Gracefully shut down Asterisk core stop now -- Shut down Asterisk immediately core stop when convenient -- Shut down Asterisk at empty call volume core waitfullybooted -- Wait for Asterisk to be fully booted database del -- Removes database key/value database deltree -- Removes database keytree/values database get -- Gets database value database put -- Adds/updates database value database query -- Run a user-specified query on the astdb database show -- Shows database contents database showkey -- Shows database contents devstate change -- Change a custom device state devstate list -- List currently known custom device states dialplan add extension -- Add new extension into context dialplan add ignorepat -- Add new ignore pattern dialplan add include -- Include context in other context dialplan debug -- Show fast extension pattern matching data structures dialplan reload -- Reload extensions and *only* extensions dialplan remove context -- Remove a specified context 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 current dialplan into a file dialplan set chanvar -- Set a channel variable dialplan set extenpatternmatchnew false -- Use the Old extension pattern matching algorithm. dialplan set extenpatternmatchnew true -- Use the New extension pattern matching algorithm. dialplan set global -- Set global dialplan variable dialplan show -- Show dialplan dialplan show chanvar -- Show channel variables dialplan show globals -- Show global dialplan variables dnsmgr refresh -- Performs an immediate refresh dnsmgr reload -- Reloads the DNS manager configuration dnsmgr status -- Display the DNS manager status dundi flush [stats] -- Flush DUNDi cache dundi lookup -- Lookup a number in DUNDi dundi precache -- Precache a number in DUNDi dundi query -- Query a DUNDi EID dundi set debug {on|off} -- Enable/Disable DUNDi debugging dundi show cache -- Show DUNDi cache dundi show entityid -- Display Global Entity ID dundi show hints -- Show DUNDi hints in the cache dundi show mappings -- Show DUNDi mappings dundi show peers [registered|include|exclude|begin] -- 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 {on|off} -- Enable/Disable DUNDi historic records fax set debug {on|off} -- Enable/Disable FAX debugging on new FAX sessions fax show capabilities -- Show the capabilities of the registered FAX technology modules fax show session -- Show the status of the named FAX sessions fax show sessions -- Show the current FAX sessions fax show settings -- Show the global settings and defaults of both the FAX core and technology modules fax show stats -- Summarize FAX session history fax show version -- Show versions of FAX For Asterisk components features show -- Lists configured features file convert -- Convert audio file group show channels -- Display active channels with group(s) hangup request -- <no description available> help -- <no description available> 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 {on|off|peer} -- Enable/Disable IAX debugging iax2 set debug jb {on|off} -- Enable/Disable IAX jitterbuffer debugging iax2 set debug trunk {on|off} -- Enable/Disable IAX trunk debugging iax2 set mtu -- Set the IAX systemwide trunking MTU iax2 show cache -- Display IAX cached dialplan iax2 show callnumber usage -- Show current entries in IP call number limit table iax2 show channels -- List active IAX channels iax2 show firmware -- List available IAX firmware iax2 show netstats -- List active IAX channel netstats iax2 show peer -- Show details on specific IAX peer iax2 show peers -- List defined IAX peers 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 [like] -- List defined IAX users iax2 test losspct -- Set IAX2 incoming frame loss percentage iax2 unregister -- Unregister (force expiration) an IAX2 peer from the registry 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 add channel -- Adds a new logging channel logger mute -- Toggle logging output to a console logger reload -- Reopens the log files logger remove channel -- Removes a logging channel logger rotate -- Rotates and reopens the log files logger set level {DEBUG|NOTICE|WARNING|ERROR|VERBOSE|DTMF} {on|off} -- Enables/Disables a specific logging level for this console logger show channels -- List configured log channels malloc trim -- Return excess memory to the OS manager reload -- Reload manager configurations manager set debug [on|off] -- Show, enable, disable debugging of the manager code 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 events -- List manager interface events manager show event -- Show a manager interface event manager show settings -- Show manager global settings manager show users -- List configured manager users manager show user -- Display information on a specific manager user media cache create -- Create an item in the media cache media cache delete -- Remove an item from the media cache media cache refresh -- Refresh an item in the media cache media cache show all -- Show all items in the media cache media cache show -- Show a single item in the media cache mgcp audit endpoint -- Audit specified MGCP endpoint mgcp reload -- Reload MGCP configuration mgcp set debug {on|off} -- Enable/Disable MGCP debugging mgcp show endpoints -- List defined MGCP endpoints minivm list accounts [for] -- List defined mini-voicemail boxes minivm list templates -- List message templates minivm list zones -- List zone message formats minivm reload -- Reload Mini-voicemail configuration minivm show settings -- Show mini-voicemail general settings minivm show stats -- Show some mini-voicemail statistics mixmonitor {start|stop|list} -- Execute a MixMonitor command module load -- Load a module by name module reload -- Reload configuration for a module module show [like] -- List modules and info module unload -- Unload a module by name moh reload -- Reload MusicOnHold moh show classes -- List MusicOnHold classes moh show files -- List MusicOnHold file-based classes moh unregister class -- Unregister realtime MusicOnHold class no debug channel -- Disable debugging on channel(s) odbc read -- Test reading a func_odbc function odbc show -- List ODBC DSN(s) odbc write -- Test setting a func_odbc function originate -- <no description available> parking show -- Show a parking lot or a list of all parking lots. phoneprov show routes -- Show registered phoneprov http routes pjproject set log level {default|0|1|2|3|4|5|6} -- Set the maximum active pjproject logging level pjproject show buildopts -- Show the compiled config of the pjproject in use pjproject show log level -- Show the maximum active pjproject logging level pjproject show log mappings -- Show pjproject to Asterisk log mappings pjsip dump endpt -- Dump the res_pjsip endpt internals pjsip export config_wizard primitives [to] -- Export config wizard primitives pjsip list aors -- List PJSIP Aors pjsip list auths -- List PJSIP Auths pjsip list channels -- List PJSIP Channels pjsip list ciphers -- List available OpenSSL cipher names pjsip list contacts -- List PJSIP Contacts pjsip list endpoints -- List PJSIP Endpoints pjsip list identifies -- List PJSIP Identifies pjsip list registrations -- List PJSIP Registrations pjsip list subscriptions {inbound|outbound} [like] -- List active inbound/outbound subscriptions pjsip list transports -- List PJSIP Transports pjsip qualify -- Send an OPTIONS request to a PJSIP endpoint pjsip reload qualify aor -- Synchronize the PJSIP Aor qualify options pjsip reload qualify endpoint -- Synchronize the qualify options for all Aors on the PJSIP endpoint pjsip reload -- <no description available> pjsip send notify -- Send a NOTIFY request to a SIP endpoint pjsip send register -- Registers an outbound registration target pjsip send unregister -- Unregisters outbound registration target pjsip set history {on|off|clear} -- Enable/Disable PJSIP History pjsip set logger {on|off|host|add|verbose|pcap} -- Enable/Disable PJSIP Logger Output pjsip show aors -- Show PJSIP Aors pjsip show aor -- Show PJSIP Aor pjsip show auths -- Show PJSIP Auths pjsip show auth -- Show PJSIP Auth pjsip show channels -- Show PJSIP Channels pjsip show channel -- Show PJSIP Channel pjsip show channelstats -- Show PJSIP Channel Stats pjsip show contacts -- Show PJSIP Contacts pjsip show contact -- Show PJSIP Contact pjsip show endpoints -- Show PJSIP Endpoints pjsip show endpoint -- Show PJSIP Endpoint pjsip show history -- Display PJSIP History pjsip show identifiers -- List registered endpoint identifiers pjsip show identifies -- Show PJSIP Identifies pjsip show identify -- Show PJSIP Identify pjsip show qualify aor -- Show the PJSIP Aor current qualify options pjsip show qualify endpoint -- Show the current qualify options for all Aors on the PJSIP endpoint pjsip show registrations -- Show PJSIP Registrations pjsip show registration -- Show PJSIP Registration pjsip show scheduled_tasks -- Show all scheduled tasks pjsip show settings -- Show global and system configuration options pjsip show subscription {inbound|outbound} -- Show active subscription details pjsip show subscriptions {inbound|outbound} [like] -- Show active inbound/outbound subscriptions pjsip show transports -- Show PJSIP Transports pjsip show transport -- Show PJSIP Transport pjsip show unidentified_requests -- Show PJSIP Unidentified Requests pjsip show version -- Show the version of pjproject in use presencestate change -- Change a custom presence state presencestate list -- List currently know custom presence states pri intense debug span -- <no description available> prometheus show metrics -- Display the current metrics and their values prometheus show status -- Display the status of Prometheus metrics collection queue add member -- Add a channel to a specified queue queue priority caller -- Change priority caller on queue queue reload {parameters|members|rules|all} -- Reload queues, members, queue rules, or parameters queue remove member -- Removes a channel from a specified queue queue reset stats -- Reset statistics for a queue queue set penalty -- Set penalty for a channel of a specified queue queue set ringinuse -- Set ringinuse for a channel of a specified queue queue show -- Show status of a specified queue queue show rules -- Show the rules defined in queuerules.conf queue {pause|unpause} member -- Pause or unpause a queue member realtime destroy -- Delete a row from a RealTime database realtime load -- Used to print out RealTime variables. realtime show pgsql cache -- Shows cached tables within the PostgreSQL realtime driver realtime show pgsql status -- Shows connection information for the PostgreSQL RealTime driver realtime store -- Store a new row into a RealTime database realtime update -- Used to update RealTime variables. realtime update2 -- Used to test the RealTime update2 method reload -- <no description available> rtcp set debug {on|off|ip} -- Enable/Disable RTCP debugging rtcp set stats {on|off} -- Enable/Disable RTCP stats rtp set debug {on|off|ip} -- Enable/Disable RTP debugging rtp show settings -- Display RTP settings say load [new|old] -- Set or show the say mode skinny message clear -- Clear message to devices skinny message set -- Send message to devices skinny reload -- Reload Skinny config skinny reset -- Reset Skinny device(s) skinny show devices -- List defined Skinny devices skinny show device -- List Skinny device information skinny show lines [verbose] -- List defined Skinny lines per device skinny show line -- List Skinny line information skinny show settings -- List global Skinny settings sorcery memory cache dump -- Dump all objects within a sorcery memory cache sorcery memory cache expire -- Expire a specific object or ALL objects within a sorcery memory cache sorcery memory cache populate -- Clear and populate the sorcery memory cache with objects from the backend sorcery memory cache show -- Show sorcery memory cache information sorcery memory cache stale -- Mark a specific object or ALL objects as stale within a sorcery memory cache stasis show topics -- Show all topics stasis show topic -- Show topic stun set debug {on|off} -- Enable/Disable STUN debugging stun show status -- Show STUN servers and statuses timing test -- Run a timing test udptl set debug {on|off|ip} -- Enable/Disable UDPTL debugging udptl show config -- Show UDPTL config options ulimit -- Set or show process resource limits unistim reload -- Reload UNISTIM configuration unistim send packet -- Send packet (for reverse engineering) unistim set debug {on|off} -- Toggle UNITSTIM debugging unistim show devices -- Show UNISTIM devices unistim show info -- Show UNISTIM info voicemail reload -- Reload voicemail configuration voicemail show aliases -- List mailbox aliases voicemail show users [for] -- List defined voicemail boxes voicemail show zones -- List zone message formats xmldoc dump -- Dump the XML docs to the specified file
3.3 做最基本的語音呼叫配置
3.3.1 編輯/etc/asterisk/sip.conf
若沒有這個文件,應該有一個sip.conf.sample,將其重命名為sip.conf,配置內容如下:
[general] context=default allowoverlap=no udpbindaddr=0.0.0.0 tcpenable=no tcpbindaddr=0.0.0.0 transport=udp srvlookup=yes
然后在此配置文件的下方,配置用戶section的地方,配置上3個用戶
[1001] type=friend callerid=user1 secret=1001 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1001 disallow=all allow=ulaw transport=udp [1002] type=friend callerid=user2 secret=1002 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1002 disallow=all allow=ulaw transport=udp [1003] type=friend callerid=user3 secret=1003 host=dynamic canreinvite=no dtmfmode=rfc2833 mailbox=1003 disallow=all allow=ulaw transport=udp
3.3.2 編輯/etc/asterisk/extensions.conf
配置通話的基本路由
[general] static=yes writeprotect=no
其他的都不變,保持默認狀態,然后,在default對應的section部分的末尾,添加下面的路由信息:
[default] exten => 1001,1,Answer() exten => 1001,n,Dial(SIP/1001,20,tr) exten => 1001,n,Hangup exten => 1002,1,Answer() exten => 1002,n,Dial(SIP/1002,20,tr) exten => 1002,n,Hangup exten => 1003,1,Answer() exten => 1003,n,Dial(SIP/1003,20,tr) exten => 1003,n,Hangup
3.3.3 配置asterisk的logger模塊(/etc/asterisk/logger.conf)
asterisk安裝完畢后,默認的日志文件名為messages,級別如下(notice,warning,error):
messages => notice,warning,error
我們的修改策略是,在asterisk的尾部,添加一行(文件名為mylog):
mylog => notice,warning,error,debug,verbose,dtmf
3.4 加載chan_sip.so模塊
基本指令操作
tkiot-isc1*CLI> sip show peers No such command 'sip show peers' (type 'core show help sip show' for other possible commands) tkiot-isc1*CLI> tkiot-isc1*CLI> sip No such command 'sip' (type 'core show help sip' for other possible commands)
上述反饋,沒有sip指令,解決辦法如下:
tkiot-isc1*CLI> module load chan_sip.so Loaded chan_sip.so SIP channel loading... == SIP Listening on 0.0.0.0:5060 == Using SIP CoS mark 4 == Using SIP CoS mark 4 -- Message technology 'sip' registered. == Registered channel type 'SIP' (Session Initiation Protocol (SIP)) == Registered RTP glue 'SIP' == Registered application 'SIPDtmfMode' == Registered application 'SIPAddHeader' == Registered application 'SIPRemoveHeader' == Registered custom function 'SIP_HEADER' == Registered custom function 'SIP_HEADERS' == Registered custom function 'SIPPEER' == Registered custom function 'CHECKSIPDOMAIN' == Manager registered action SIPpeers == Manager registered action SIPshowpeer == Manager registered action SIPqualifypeer == Manager registered action SIPshowregistry == Manager registered action SIPnotify == Manager registered action SIPpeerstatus [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35476 deprecation_notice: chan_sip has no official maintainer and is deprecated. Migration to [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35477 deprecation_notice: chan_pjsip is recommended. See guides at the Asterisk Wiki: [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35478 deprecation_notice: https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip [Jun 19 17:53:59] WARNING[26933]: chan_sip.c:35479 deprecation_notice: https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip Loaded chan_sip.so => (Session Initiation Protocol (SIP))
再次查看sip指令操作的結果(前述配置完畢后,需要將asterisk重啟一次):
tkiot-isc1*CLI> sip show peers Name/username Host Dyn Forcerport Comedia ACL Port Status Description 1001/1001 (Unspecified) D Auto (No) No 0 Unmonitored 1002/1002 (Unspecified) D Auto (No) No 0 Unmonitored 1003/1003 (Unspecified) D Auto (No) No 0 Unmonitored 3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 3 offline]
3.5 安裝sip客戶端
這里采用的是yate client(http://old.yate.ro/pmwiki/index.php?n=Main.Download),我這里的版本是windows的5.4.0,安裝就不說了。
3.6 IP電話驗證
這里對應的配置也很簡單,Settings->Accounts->New. 參照圖例,其他的都不變,保持默認,配置完畢后,點擊OK按鈕即可。若沒有什么問題,Accounts的配置界面,應該像下面的圖
這里,有一點,需要非常的注意,yate client的默認傳輸協議是UDP,所以,在SIP客戶端register的時候,一定要確保客戶端和服務端之間的網絡權限是否開啟,默認SIP的端口是5060.若傳輸協議,兩邊配置的不一樣,或者網絡權限沒有開啟,最后那個register的流程出現timeout的問題,如下圖
下面,就來看看,1001用戶給1002用戶(兩個yate client在同一個PC機器上進行的模擬)打個語音電話,接通后的截圖如下
接通成功后的效果如下:
對應的asterisk的后台日志:
[Jun 23 15:34:12] VERBOSE[12019] chan_sip.c: Registered SIP '1001' at 10.95.177.137:63637 [Jun 23 15:34:16] VERBOSE[12019] chan_sip.c: Registered SIP '1002' at 10.95.177.137:61809 [Jun 23 15:34:36] VERBOSE[12019][C-00000006] netsock2.c: Using SIP RTP CoS mark 5 [Jun 23 15:34:36] VERBOSE[12019][C-00000006] res_rtp_asterisk.c: 0x7fb478010fd0 -- Strict RTP learning after remote address set to: 10.95.177.137:31494 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] pbx.c: Executing [1002@default:1] Answer("SIP/1001-0000000a", "") in new stack [Jun 23 15:34:36] VERBOSE[13571][C-00000006] pbx.c: Executing [1002@default:2] Dial("SIP/1001-0000000a", "SIP/1002,20,tr") in new stack [Jun 23 15:34:36] VERBOSE[13571][C-00000006] netsock2.c: Using SIP RTP CoS mark 5 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] app_dial.c: Called SIP/1002 [Jun 23 15:34:36] VERBOSE[13571][C-00000006] app_dial.c: SIP/1002-0000000b is ringing [Jun 23 15:34:42] VERBOSE[12019][C-00000006] res_rtp_asterisk.c: 0x7fb48000c5a0 -- Strict RTP learning after remote address set to: 10.95.177.137:29882 [Jun 23 15:34:42] VERBOSE[13571][C-00000006] app_dial.c: SIP/1002-0000000b answered SIP/1001-0000000a [Jun 23 15:34:42] VERBOSE[13574][C-00000006] bridge_channel.c: Channel SIP/1002-0000000b joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:34:42] VERBOSE[13571][C-00000006] bridge_channel.c: Channel SIP/1001-0000000a joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13574][C-00000006] bridge_channel.c: Channel SIP/1002-0000000b left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13571][C-00000006] bridge_channel.c: Channel SIP/1001-0000000a left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5> [Jun 23 15:36:00] VERBOSE[13571][C-00000006] pbx.c: Spawn extension (default, 1002, 2) exited non-zero on 'SIP/1001-0000000a'
asterisk的CLI窗口顯示的日志,體現了注冊1002,從1001呼叫1002的過程:
tkiot-isc1*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
1001/1001 10.95.177.137 D Auto (No) No 63637 Unmonitored
1002/1002 10.95.177.137 D Auto (No) No 61809 Unmonitored
1003/1003 (Unspecified) D Auto (No) No 0 Unmonitored
3 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 1 offline]
-- Registered SIP '1001' at 10.95.177.137:63637 -- Registered SIP '1002' at 10.95.177.137:61809
== Using SIP RTP CoS mark 5
> 0x7fb478010fd0 -- Strict RTP learning after remote address set to: 10.95.177.137:31494
-- Executing [1002@default:1] Answer("SIP/1001-0000000a", "") in new stack
-- Executing [1002@default:2] Dial("SIP/1001-0000000a", "SIP/1002,20,tr") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/1002
-- SIP/1002-0000000b is ringing
> 0x7fb48000c5a0 -- Strict RTP learning after remote address set to: 10.95.177.137:29882
-- SIP/1002-0000000b answered SIP/1001-0000000a
-- Channel SIP/1002-0000000b joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1001-0000000a joined 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1002-0000000b left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
-- Channel SIP/1001-0000000a left 'simple_bridge' basic-bridge <da205a61-8f50-4352-958f-a0c661c559e5>
== Spawn extension (default, 1002, 2) exited non-zero on 'SIP/1001-0000000a'
wireshark抓包:
請看下面的截圖,這個過程包含1002用戶的注冊register過程,在1001電話機上給1002撥號打call(invite),1001方響鈴,接起通話,然后掛斷通話,最后1002解除在線(offline) 。
到此,asterisk+yateclient的基礎IP通話環境搭建完畢,驗證成功,總結注意事項:
1. 網絡權限,5060端口默認,SIP默認傳輸協議是UDP協議
2. asterisk 17的SIP模塊,默認是沒有的,需要通過CLI進行指令的加載chan_sip.so
3. 當前這種基礎模式存在明顯的缺陷,用戶的創建和呼叫路由,必須在sip.conf和extensions.conf文件里面,靜態的配置,每次創建用戶后,必須重啟asterisk,重新load chan_sip.so,然后才能工作,這個操作,影響已經存在用戶的正常業務
歡迎評論,歡迎關注,轉帖請注明出處!