返回列表 發帖
本帖最後由 角色 於 2015-6-7 00:40 編輯

下面将会是一系列的Workshops,通过这些Workshops大家可以对怎样set Asterisk有更加深刻的认识。但是还没有进行每个Workshop,我们的Asterisk Server要进行一些设定。

1. Copy sip.conf to sip.conf.old

2. Clean sip.conf such that it contains nothing

3. Similarly to extensions.conf, copy extensions.conf to extensions.conf.old

4. Clean extensions.conf such that it contains nothing
  1. root@debian:/etc/asterisk# cp sip.conf sip.conf.old
  2. root@debian:/etc/asterisk# vi sip.conf
  3. root@debian:/etc/asterisk# cp extensions.conf extensions.conf.old
  4. root@debian:/etc/asterisk# vi extensions.conf
  5. root@debian:/etc/asterisk#
複製代碼
5. Move users.conf users.conf.old

6. Move sip_notify.conf sip_notify.conf.old

7. mv extensions.ael extensions.ael.old

8. mv extensions.ual extensions.lua.old

9. mv res_parking.conf res_parking.conf.old

3005.png
图一: 简单内部电话系统

为了简单测试电话,我们最好有IP Phone,或者ATA。

我常用的平价的IP Phone DGP306
IP-PBX-office-call-multi-line-phones-for-the-receptionist-to-pass-the-call-to-the.jpg

Obihai Obi110 ATA
Screen Shot 2015-06-06 at 10.09.12 PM.png

有了SIP Client,通常要需要三个parameters,
1:SIP Server hostname/IP,
2:user name,
3:password。

那么针对我们今天的Workshop,给Ext。3101的SIP Parameters为:

1. SIP Server:10.0.88.14
2. User name:3101
3. Password:3101

我们用DGP306来体现

Screen Shot 2015-06-06 at 10.12.35 PM.png

Screen Shot 2015-06-06 at 11.44.21 PM.png

Screen Shot 2015-06-06 at 11.43.55 PM.png

TOP

本帖最後由 角色 於 2015-6-7 09:55 編輯

Workshop 1: Setting up an echo test server and one telephone extension number

准备功夫:

一、 第一个Workshop还没有详细介绍的时候,先让大家认识Asterisk里的Command Line Interface,简称CLI。CLI有什么用,请大家看下面的链接就知道:
http://www.telecom-cafe.com/forum/viewthread.php?tid=6658

二、怎样编辑text (*.conf)文件?如果你会unix、Linux的vi command,那么不用再说你也会怎样edit。如果不会的话,你可以别的editor,如nano。你可以输入nano text.conf,然后按回车键,那么就可以看是编辑text档案,界面如我们以前用的WordStar类似。

在学习Asterisk中,如果一开始就设两个extensions,如果不通,都不知道哪里出问题,所以我们要学怎样利用某个extension拨打一个系统里的echo test server。

sip.conf
  1. [3101]
  2. typp=friend
  3. secret=3101
  4. qualify=yes
  5. nat=no
  6. host=dynamic
  7. canreinvit=no
  8. context=internal
複製代碼
extensions.conf
  1. [internal]
  2. ;
  3. ; Create an extension, 1000, for evaulating echo latency.
  4. ;
  5. exten => 1000,1,Playback(demo-echotest) ; Let them know what's going on
  6. exten => 1000,2,Echo ; Do the echo test
  7. exten => 1000,3,Playback(demo-echodone) ; Let them know it's over
複製代碼
如果我们把上面的设定分别放入sip.conf和extensions.conf里,再重新启动Asterisk,再用CLI进入Asterisk里“asterisk -rvvvv”,用“sip show peers”,我们看到
Screen Shot 2015-06-06 at 10.00.50 PM.png

我们可以用“dialplan show”看看我们有什么dial plan是什么,是否与extensions.conf一致?

Screen Shot 2015-06-07 at 12.31.21 AM.png

在上图的连个dialling rules,是系统default,是删不掉的,我们只看下面就可以。那些信息就是extensions.conf里内容是一致。

那么我们可以拿起DGP306话筒,然后拨打1000号,我们从Asterisk CLI可以看到如下:

Screen Shot 2015-06-07 at 12.34.47 AM.png

打完1000号,你可以按#号就马上拨通,然后你会听到一把女声,说echo test怎样测试,等她说完后,你说1,2,3,系统马上把你的声音回到你听筒里。如果Server是很远,那么你要等大约300ms才能听到你的回音。

Reference:
[1] http://www.voip-info.org/wiki/view/Asterisk+cmd+Echo
[2] http://www.telecom-cafe.com/foru ... ;highlight=workshop

通过Workshop 1,你学会了:

1、你学会怎样编辑sip.conf, extensions.conf
2、Asterisk Server 给出三个SIP parameters (server IP/hostname, username and password)
3、怎样使用Asterisk CLI简单指令(sip show peers,dialplan show,sip reload)
4、怎样建立echo test server和怎样使用。

TOP

本帖最後由 角色 於 2015-6-7 11:28 編輯

Workshop 2:Installation of two extensions such that

1. Both call each other using the other's telephone extension number.
2. Both can carry out the echo test offered by the Asterisk server in Workshop 1.

sip.conf
  1. [3101]
  2. typp=friend
  3. secret=3101
  4. qualify=yes
  5. nat=no
  6. host=dynamic
  7. canreinvit=no
  8. context=internal

  9. [3102]
  10. typp=friend
  11. secret=3102
  12. qualify=yes
  13. nat=no
  14. host=dynamic
  15. canreinvit=no
  16. context=internal
複製代碼
extensions.conf
  1. [internal]
  2. ;
  3. ; Create an extension, 1000, for evaulating echo latency.
  4. ;
  5. exten => 1000,1,Playback(demo-echotest) ; Let them know what's going on
  6. exten => 1000,2,Echo ; Do the echo test
  7. exten => 1000,3,Playback(demo-echodone) ; Let them know it's over

  8. exten => 3101,1,Dial(SIP/3101,,r)
  9. exten => 3102,1,Dial(SIP/3102,,r)
複製代碼
如果安装正确,那么Asterisk CLI里可以看到

sip show peers
Screen Shot 2015-06-07 at 1.56.21 AM.png

dialplan show
Screen Shot 2015-06-07 at 11.04.17 AM.png

TOP

本帖最後由 角色 於 2015-6-7 19:44 編輯

Workshop 3: Allow external SIP client to access the resource available of Asterisk server and WAN of router is fixed IP

之前的Workshop,SIP clients都是在私网内进行,如果一个在公网的SIP client是怎样注册到我们的Asterisk server内呢?这个牵涉非常多得关卡,稍有做错一步就整系统就不能工作,所以这个Workshop可以说是非常重要。

3006.png
图一:外网与内网连接

为了让公网的SIP Client能接入来,我们要处理的事包括:

一、公网的SIP Parameters是怎样?

如果WAN是用fixed IP address,那么我们可以fixed IP address,不然我们就要用DDNS的hostname。那么三个parameters为:
1、hostname:sip.telecom-cafe.com (这个hostname,能在DNS查到它的WAN口IP地址)
2、extension name:3104
3、password:3104

二、SIP信号来到router的WAN口是怎样处理?

当外面(公网)的SIP packet来到router的WAN口,那么我们要把数据包转到Asterisk server (10.0.88.14)。标准的SIP port是5060,但是我的network系统后也用其他Asterisk server,我们可以改用其他port number去代替,如用44123,你可以选用其他的port number。

除了SIP的UDP外,我们还要其他UDP port个RTP用,default是10000-20000,我们可以选用44200-44500,就已经非常足够。

Router settings:
UDP port 44123 forwarding to 10.0.88.14
UDP port 44200-44500 forwarding to 10.0.88.14

留意3104的nat=force_rport,comedia,而不是3101-3102的nat=no。因为3101-3102在网内,而3104是在网外,所以nat不能设nat=no。最初调整系统是发现“单边声音”,这个在用Asterisk server是非常出名的一个名词,这都与nat有关。最后才记起要把外网的nat改为no,但是Astiersk 13已经不用no,而改用force_rport,comedia。

sip.conf
  1. [general]
  2. bindport=44123
  3. externip=<your wan IP address>
  4. localnet=10.0.88.0/255.255.255.0

  5. [3101]
  6. typp=friend
  7. secret=3101
  8. qualify=yes
  9. nat=no
  10. host=dynamic
  11. canreinvit=no
  12. context=internal

  13. [3102]
  14. typp=friend
  15. secret=3102
  16. qualify=yes
  17. nat=no
  18. host=dynamic
  19. canreinvit=no
  20. context=internal

  21. [3104]
  22. typp=friend
  23. secret=3104
  24. qualify=yes
  25. nat=nat=force_rport,comedia
  26. host=dynamic
  27. canreinvit=no
  28. context=internal
複製代碼
extensions.conf
  1. [internal]
  2. ;
  3. ; Create an extension, 1000, for evaulating echo latency.
  4. ;
  5. exten => 1000,1,Playback(demo-echotest) ; Let them know what's going on
  6. exten => 1000,2,Echo ; Do the echo test
  7. exten => 1000,3,Playback(demo-echodone) ; Let them know it's over

  8. exten => 3101,1,Dial(SIP/3101,,r)
  9. exten => 3102,1,Dial(SIP/3102,,r)
  10. exten => 3104,1,Dial(SIP/3104,,r)
複製代碼
rtf.conf
  1. rtpstart=44200
  2. rtpend=44500
複製代碼

TOP

本帖最後由 角色 於 2015-6-7 19:57 編輯

Workshop 4: WAN IP of router is a dynamic IP

Workshop 3的WAN IP是fixed,不变,但是很多时候WAN是dynamic IP,那么SIP的设置会有变化。

sip.conf
  1. [general]
  2. bindport=44123
  3. externhost=FQDN of your WAN IP
  4. localnet=10.0.88.0/255.255.255.0

  5. [3101]
  6. typp=friend
  7. secret=3101
  8. qualify=yes
  9. nat=no
  10. host=dynamic
  11. canreinvit=no
  12. context=internal

  13. [3102]
  14. typp=friend
  15. secret=3102
  16. qualify=yes
  17. nat=no
  18. host=dynamic
  19. canreinvit=no
  20. context=internal

  21. [3104]
  22. typp=friend
  23. secret=3104
  24. qualify=yes
  25. nat=nat=force_rport,comedia
  26. host=dynamic
  27. canreinvit=no
  28. context=internal
複製代碼

TOP

本帖最後由 角色 於 2015-6-12 20:00 編輯

Workshop 5: Conference call using ConfBridge application

The purpose of this conference is to allow extension users can go to the voip conference room. The example shown in this workshop is very primitive and easy to use. You only need to add a line to the extensions.con

extensions.conf
  1. ;other lines are the same as other workshops

  2. exten => 4000,1,ConfBridge(101);  join room 101
複製代碼
How to enter the room 101? You just only type 4000.

TOP

本帖最後由 角色 於 2015-6-24 02:45 編輯

Workshop 6: Setup a user SIP account on OBi110

The information that you need is

1. Server SIP IP/hostname = 10.0.88.14
2. Server SIP port number = 44123 (default is 5060)
3. SIP account name = 3102
4. Password for the above SIP account name = 3102 (for simplicity)

Important notice: After changing the parameters of OBi110, you need to press "Submit" button followed by "Reboot" the device.

Service Providers -> ITSP Profile A -> SIP -> SIP ...
Screen Shot 2015-06-24 at 1.51.01 am.png

Voice Services -> SP1 Service -> SIP Credentials ...
Screen Shot 2015-06-24 at 1.51.38 am.png

If the user does not want to enter <**1> to access the SP1 service, then we can set the default line to SP1

Physical Interfaces -> PHONE Port
Screen Shot 2015-06-24 at 2.14.37 am.png

TOP

本帖最後由 角色 於 2015-6-25 09:28 編輯

Workshop 7: Connecting PSTN/PABX Trunk to LINE of OBi110 Part I: Outbound Call via PSTN Trunk

Before going to the actual settings of OBi110 and Asterisk box, we have to discuss about the connections to the OBi110 to the PSTN world as shown in Figure 1.

For simplicity, only the Hong Kong is installed with OBi110 devices. However the method described below is also applicable to other sites such as Macao and Zhuhai as well. In Figure 1, it shows two configuration for the two OBi110 devices, namely OBiA and OBiB.

OBiA Connection: LINE port connected to a PSTN system
OBiB Connection: LINE port connected to an analogue PABX system

Configuration on OBiA:
LINE port is connected to a PSTN system.
INTERNET port is connected to the LAN of Router 2.
PHONE port is connected to an analogue telephone.
SP1 is configured to EXT. 2102
SP2 is configured to EXT. 1901 (forms a gateway for Asterisk server to other resources **1, **2, **8, **9 of OBiA)

Objective 1: In Hong Kong Office, someone picks up EXT. 3101 telephone,

1a. press <2102#>, the EXT. 2102 telephone will ring.
1b. press <00852> + <8-digit telephone number> to make phone calls to HK PSTN

Screen Shot 2015-06-24 at 10.52.54 pm.png

Figure 1: Block diagram of OBi110 connection to PSTN

Step 1: Edit sip.conf for extension 1901

sip.conf
  1. [1901]
  2. type=friend
  3. secret=1901
  4. qualify=yes
  5. nat=force_rport,comedia
  6. ;nat=no ;if Obi110 is within the network
  7. host=dynamic
  8. canreinvite=no
  9. disallow=all
  10. allow=speex,gsm,ulaw,alaw,ilbc,g729
  11. context=internal
複製代碼
Step 2: Include new dialplan for ext. 1901 in extensions.conf

extensions.conf
  1. ;00852 Trunk via 1901 OBi110's LINE port
  2. exten => _00852.,1,Dial(SIP/**8${EXTEN:5}@1901,,)
  3. exten => _00852.,n,Hangup()

  4. exten => 1901,1,Dial(SIP/1901,,r)
複製代碼
Setting up OBi110

Step 3: Setup for ITSP B
Screen Shot 2015-06-25 at 1.22.17 am.png

The IP address above is the public IP address.

Step 3: Setup for SP2
Screen Shot 2015-06-25 at 1.16.29 am.png

The full string of X_InboundCallRoute is

{@>(<**1:>xx.):sp1},{@>(<**8:>xx.):li},{@>(<**9:>xx.):pp},{@>(<**0:>):aa}

The above string plays a very important role to inbound call from the Asterisk server to the Obi device of Extension 1901.
**1: sp1
**2: sp2 (not specified since it is 1901 itself)
**8: li (LINE Port, it is connected HK PSTN system)
**9: pp (OBiTalk)
**0: aa (Auto Attendent)

Step 4
Screen Shot 2015-06-25 at 12.11.19 am.png

The ITSP Profile for SP1 may need to change to B if OBi110 is not within the network.
Screen Shot 2015-06-25 at 1.16.51 am.png

Testing

Using a mobile phone with soft SIP client, enter <00852> + <8-digit number>. Based on the dialplan, the Asterisk send the 8-digit number to the extension 1901, which is used by the HK OBi110. The inbound calls are handled by the entry of X_InboundCallRoute.

TOP

本帖最後由 角色 於 2015-7-1 01:10 編輯

Workshop 8: Installation of HKBN 2b App for both outbound and inbound calls

With the following information, any HK PSNT number can be ported to HKBN 2b App account as shown in in the following link:http://www.telecom-cafe.com/foru ... &extra=page%3D1

With suitable arrangement your telephone number starting from the digit "2" can be easily ported to HKBN 2b App. The procedure of settings up HKBN 2b App are

Let us assume the followings:
HKBN 2b App number = 31234567
Password = pass

Step 1: Adding the following lines to your sip.con

sip.conf
  1. [general]
  2. .
  3. .
  4. .
  5. register => 31234567hk:pass@s2hkbntel.net:5060/31234567

  6. ;The above register string should be placed just after the context "general" and before the next context.

  7. [hkbn2b]
  8. type=peer
  9. username=31234567hk
  10. secret=pass
  11. port=5060
  12. host=s2hkbntel.net
  13. fromuser=31234567hk
  14. fromdomain=s2hkbntel.net
  15. nat=force_rport,comedia
  16. canreinvite=no
  17. canredirect = no
  18. insecure=port,invite
  19. dtmfmode=auto
  20. context=from-hkbn2b
複製代碼
Step 2: Adding the following dial plan to your extensions.conf
  1. ;00852 using the hkbn2b trunk
  2. exten => _00852.,1,Dial(SIP/${EXTEN:5}@hkbn2b,,)
  3. exten => _00852.,n,Hangup()

  4. [from-hkbn2b]
  5. exten => 31234567,1,Dial(SIP/3104,,r)
  6. exten => 31234567,n,Hangup()
複製代碼
Step 3: Adding IP address for hostnames in /etc/hosts
  1. 203.80.89.135   s2hkbntel.net s21hkbntel.net
複製代碼
If the above IP address to hostnames do not work, please use the following
  1. 203.80.89.139 s2hkbntel.net s22.hkbntel.net
複製代碼
You need to update the new settings in sip.con accordingly.

If the above does not work, there is another set of parameters to be used as follows

sip.conf
  1. register => 31234567hk:pass@s2hkbntel.net:5060/31234567hk

  2. [hkbn2b]
  3. type=peer
  4. username=31234567hk
  5. secret=pass
  6. port=5060
  7. host=s2hkbntel.net
  8. fromuser=31234567hk
  9. fromdomain=s2hkbntel.net
  10. nat=force_rport,comedia
  11. canreinvite=no
  12. canredirect = no
  13. insecure=port,invite
  14. qualify=yes
  15. dtmfmode=auto
  16. context=from-hkbn2b
複製代碼
extensions.conf
  1. exten => _9.,1,Dial(SIP/${EXTEN:1}@hkbn2b,,)
  2. exten => _9.,n,Hangup()

  3. exten => 3101,1,Dial(SIP/3101,,r)
  4. exten => 3102,1,Dial(SIP/3102,,r)

  5. [from-hkbn2b]
  6. exten => 31234567hk,1,Dial(SIP/3101,,r)
  7. exten => 31234567hk,n,Hangup()
複製代碼

TOP

本帖最後由 角色 於 2015-7-2 22:46 編輯

Workshop 9: Inbound call via OBi110

Actual working workshop:

http://www.telecom-cafe.com/foru ... =6657&pid=41508

Reference:
http://www.obitalk.com/forum/index.php?topic=1157.msg7261#msg7261

TOP

备用帖子

TOP

备用帖子

TOP

备用帖子

TOP

备用帖子

TOP

备用帖子

TOP

返回列表