您的位置:首页 > 运维架构 > Linux

CentOS6.5下 Asterisk 的安装、配置及 2个软电话实现互拨

2014-09-17 18:51 615 查看
从 asterisk 的安装到配置,到最后实现 2 个软电话(或者SIP话机亦可)之间互拨。花了大概2天时间,期间晕头转向砸桌子。。。。

当1002 收到来自1001 呼叫响铃的那瞬间,爽了O(∩_∩)O哈哈~

以下整理自网络:

一、安装asterisk相关软件包。

●安装dahdi驱动

[root@maple 2.6.32-71.el6.i686]# cd ~ #切换到root主目录下

[root@maple ~]# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/releases/dahdi-linux-2.5.0.tar.gz
#这里我用的dahdi-linux-2.5.0.tar.gz版本

[root@maple ~]# tar -xzf dahdi-linux-2.5.0.tar.gz

[root@maple ~]# cd dahdi-linux-2.5.0

[root@maple dahdi-linux-2.5.0]# make

[root@maple dahdi-linux-2.5.0]# make install

[root@maple dahdi-linux-2.5.0]# cd ..

[root@maple ~]# wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/releases/dahdi-tools-2.5.0.tar.gz

[root@maple ~]# tar -xzf dahdi-tools-2.5.0.tar.gz

[root@maple ~]# cd dahdi-tools-2.5.0

[root@maple dahdi-tools-2.5.0]# ./config

[root@maple dahdi-tools-2.5.0]# make

[root@maple dahdi-tools-2.5.0]# make install

[root@maple dahdi-tools-2.5.0]# make config

[root@maple dahdi-tools-2.5.0]# cd ..

[root@maple ~]# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4.12.tar.gz

[root@maple ~]# tar -xzf libpri-1.4.12.tar.gz

[root@maple ~]# cd libpri-1.4.12

[root@maple libpri-1.4.12]# make

[root@maple libpri-1.4.12]# make install

[root@maple libpri-1.4.12]# cd ..

●安装asterisk

[root@maple ~]# wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-10.0.0-rc1.tar.gz

[root@maple ~]# tar -xzf asterisk-10.0.0-rc1.tar.gz

[root@maple ~]# cd asterisk-10.0.0-rc1

[root@maple asterisk-10.0.0-rc1]# ./configure

[root@maple asterisk-10.0.0-rc1]# make

[root@maple asterisk-10.0.0-rc1]# make install

[root@maple asterisk-10.0.0-rc1]# make samples

[root@maple asterisk-10.0.0-rc1]# make config

[root@maple asterisk-10.0.0-rc1]# cd ..

[root@maple ~]# wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.4.tar.gz

[root@maple ~]# tar -xzf asterisk-addons-1.6.2.4.tar.gz

[root@maple ~]# cd asterisk-addons-1.6.2.4

[root@maple asterisk-addons-1.6.2.4]# ./configure

[root@maple asterisk-addons-1.6.2.4]# make cdr

[root@maple asterisk-addons-1.6.2.4]# cp cdr/cdr_addon_mysql.so /usr/lib/asterisk/modules/

[root@maple asterisk-addons-1.6.2.4]# cd ..

二、配置及SIP话机互拨部分

Step1:设置 sip.conf

root@Ubuntu:/etc/asterisk# vim sip.conf

[general] //类似与全局变量

context = default

srvlookup = yes //DNS SRV记录查询

[111]

secret=aaa //密码,随意设置

port=5060 //SIP端口地址

type=friend //类型为friend

host=dynamic //要求号码注册,以便Asterisk可以知道如何找到电话

qualify = yes //确认远端设备是否可达

nat = no //如果一个号码在NAT设备后面,例如防火墙,配置为yes

context = internal //定义了指令的地点,用于控制电话的权限,及如何处理此号码的呼入呼叫。

canreinvite = no //让Asterisk媒体通道经过自己,而不允许RTP信息直接在端点之间传送

;-----------华丽的分割线--------------

[222]

secret=aaa

port=5060

qualify = yes

nat = no

context = internal

canreinvite = no

type=friend

host=dynamic

Step2:设置extensions.conf

root@Ubuntu:/etc/asterisk# vim extensions.conf

[internal] //这里的internal和sip.conf里的context相同,可修改

exten => 1001,1,Dial(SIP/111)

exten => 1002,1,Dial(SIP/222)

Step3:打开Asterisk

root@Ubuntu:/home/blackhole# asterisk -crvvvvv

...

...

Ubuntu*CLI>

Step4:设置X-lite

点击软件上方三角形ShowMenu

再点开SIP Account Settings,设置新账户

如图所示:



DisplayName可随意填写

User name 和Authorization user name填在sip.conf里面设置的名字我的是111就填111了

Domian就是本机的IP地址,proxy也是 但是记得加端口号

设置完点确定就OK了

此时 应该就能够看到

-- Registered SIP '111' at 172.19.60.10:45738

[Apr 15 20:33:15] NOTICE[1154]: chan_sip.c:24728 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 111

Ubuntu*CLI>

表示已经111已经连接上

此时你可以试试拨打1001

你会看到111在拨打自己

== Using SIP RTP CoS mark 5

-- Executing [1001@internal:1] Dial("SIP/111-00000023", "SIP/111") in new stack

== Using SIP RTP CoS mark 5

-- Called SIP/111

-- SIP/111-00000024 is ringing

-- SIP/111-00000024 is ringing

== Spawn extension (internal, 1001, 1) exited non-zero on 'SIP/111-00000023'

Ubuntu*CLI>

Step5:设置eyeBeam

在此解释一下X-lite和eyeBeam其实是相同的,只是eyeBeam不能使用视频而X-lite可以

我只是用他们做个测试

所以设置和eyeBeam是相同的

设置好后

-- Registered SIP '222' at 172.19.60.10:15934

[Apr 15 20:42:55] NOTICE[1154]: chan_sip.c:24728 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 222

Ubuntu*CLI>

这样就可以呼叫X-lite啦

拨打1001试试

当然也可以用X-lite拨打eyeBeam

== Using SIP RTP CoS mark 5

-- Executing [1001@internal:1] Dial("SIP/222-00000027", "SIP/111") in new stack

== Using SIP RTP CoS mark 5

-- Called SIP/111

-- SIP/111-00000028 is ringing

-- SIP/111-00000028 is ringing

Ubuntu*CLI>

附图:



这样就算是成功了吧

注:如果extensions.conf被重新编写了 一定要记得在CLI那里reload一下

重新编写sip.conf就sip reload

参考:
http://blog.chinaunix.net/uid-23069658-id-3142076.html http://blog.csdn.net/sukhoi27smk/article/details/17532249
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: