I will explain a bit more deeper about Asterisk configuration in this post, some trick and useful configuration that I found really helpful in configuring asterisk instalation. Asterisk developer really did a good job to make a complete PBX, they give the best tools to us and now it is our job to configure it.
One thing I found really annoying is the echo if we connect asterisk to PSTN line. I use digium TDM 410P and leave the card without tune it will give annoying echo. In my earlier post (Part 2) I explain that by running /usr/sbin/dahdi_genconf dahdi will automatically create /etc/dahdi/system.conf file that already contain information about hardware echo canceller. First thing you should remember if you have the budget is buy a card with hardware echo canceller. It will let the card to manage the echo without give the processor too much task to reduce it. After that you should tune the card. Luckily Digium give the best tools to tune the card named fxotune. To tune your card first shutdown the asterisk service and then run:
# /usr/sbin/fxotune -i 0
I put 0 (zero) because to dial an outside line I set the asterisk configuration to use 0. You should change it to whatever number you use. fxotune will create /etc/fxotune.conf file to put all the configuration it creates to reduce the echo. Pleas read "man fxotune" for more explanation about the tools.
To enable Asterisk to use the card configuration every time we boot the server we need a slight modification of init script. We should call the fxotune before we call Asterisk, you can either modify the init script of Asterisk to call fxotune before it call the Asterisk or you can modify /etc/init.d/after.local (yes, I use openSUSE). I prefer to use after.local. Create /etc/init.d/after.local and fill the lines below:
# ! /bin/sh
/usr/sbin/fxotune -s
sleep 1
/etc/init.d/asterisk161 start
Also you need to remove asterisk service from init script
# insserv -r /etc/init.d/asterisk161
You can boot the server and hear the difference. If everything goes well you can hear no echo :-)
Now let's take a look back to our extension.conf that I already give in the part 3.
[recordings]
exten => 500,1,Answer
exten => 500,2,Playback(en/silakanrekamgreeting)
exten => 500,3,Record(en/mymessage:gsm)
exten => 500,4,Playback(en/pesananda)
exten => 500,5,Playback(en/mymessage)
exten => 500,6,Playback(en/tekan1)
exten => 500,7,WaitExten(3)
exten => t,1,Playback(en/maafmohonulangi)
exten => t,2,Goto(500,5)
exten => i,1,Playback(en/pesanandasalah)
exten => i,2,Goto(500,5)
exten => 1,1,System(/bin/mv /var/lib/asterisk/sounds/en/mymessage.gsm /var/lib/asterisk/sounds/en/autoattendant.gsm)
exten => 1,2,Playback(en/terimakasih)
exten => 1,3,Playback(en/tekan3)
exten => 2,1,Goto(500,1)
exten => 3,1,Goto(500,1)
exten => 4,1,Hangup
include => internal-sip
This is the context about recording that we put it in extensions.conf and also in sip.conf, that's why I put "include => internal-sip" in the bottom of the context. We create the special extension 500 to record the greeting for our system. We will put the record as greeting, when someone from outside call our lines, then Asterisk will play this greeting. I will explain it to you don't worry :-). Those lines means:
If dial 500 then answer.
Play the sound file /var/lib/asterisk/sounds/en/silakanrekamgreeting.gsm. You can record a custom sound file which contain something like "Please record your greeting after the beep", save it as gsm format and call it from here.
Record your message (say the greeting you want to record) and put it as /var/lib/asterisk/sounds/en/mymessage.gsm
Play the file /var/lib/asterisk/sounds/en/pesananda.gsm. You can record a custom sound file which contain something like "Your greeting is", save it as gsm format and call it from here.
Play your record greeting that just you record in step 3.
Play the sound file /var/lib/asterisk/sounds/en/tekan1.gsm. You can record a custom sound file which contain something like "Please press 1 to save your message", save it as gsm format and call it from here.
Wait 3 second for pressing 1
t,1 means that if 3 seconds already time-out then play the sound file /var/lib/asterisk/sounds/en/maafmohoulangi.gsm. You can record a custom sound file which contain something like "Please re-record your message", save it as gsm format and call it from here.
t,2 go to point 6 above and repeat the steps.
i,1 means if you press another number in step 7 (you don't record the message) then play the sound file /var/lib/asterisk/sounds/en/pesanandasalah.gsm. You can record a custom sound file which contain something like "Sorry I didn't get that", save it as gsm format and call it from here.
i,2 go to point 6 above and repeat the steps.
1,1 if you press 1 in step 7 then asterisk will move /bin/mv /var/lib/asterisk/sounds/en/mymessage.gsm to /var/lib/asterisk/sounds/en/autoattendant.gsm
1,2 means play the sound file /var/lib/asterisk/sounds/en/terimakasih.gsm. You can record a custom sound file which contain something like "thankyou", save it as gsm format and call it from here.
1,3 means play the sound file /var/lib/asterisk/sounds/en/tekan3.gsm. You can record a custom sound file which contain something like "press 3 to record another message", save it as gsm format and call it from here.
include => internal-sip, means that asterisk will see also [recording] context in [internal-sip] context, usually we manage [internal-sip] in sip.conf.
Now ti's time to configure /etc/asterisk/sip.conf. This file manage the sip for ip phone and other peripheral in our setup. I use several desk ip-phone, wireless ip-phone (Polycom Kirk DECT) and also GSM gateway (Zed, Musitel etc), all of it running well. My sip.conf looks something like:
[general]
port = 5060
bindaddr = 10.7.1.120
disallow=all
allow=all
allow=ulaw
allow=gsm
context=internal-sip
;--------------------xxxxx site ---------------------------
;Polycom IP330
[8001]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
canreinvite=no
username=TELEPH01
userid=8001
callerid=TELEPH01 <8001>
mailbox=8001
allow=all
qualify=yes
[8002]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
username=TELEPH02
userid=8002
callerid=TELEPH02 <8002>
mailbox=8002
allow=all
qualify=yes
[8006]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
;context=internal-sip
context=recordings
nat=no
canreinvite=no
username=TELEPH06
userid=8006
callerid=DPTELEPH06 <8006>
mailbox=8006
allow=all
qualify=yes
; KIRK DECT 3040 at site
[8020]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
username=TELEPH20
userid=8020
callerid=TELEPH20 <8020>
mailbox=8020
allow=all
qualify=yes
;Zed GSM GATEWAY
[8031]
type=peer
insecure=very
disallow=all
allow=ulaw
allow=alaw
allow=gsm
context=internal-sip
host=10.7.1.31
username=GS8
permit=10.7.1.31/255.255.255.255
qualify=yes
canreinvite=no
call-limit=4
dtmfmode=rfc2833
nat=no
[8032]
type=peer
insecure=very
disallow=all
allow=ulaw
allow=alaw
allow=gsm
context=internal-sip
host=10.7.1.32
username=GS8
permit=10.7.1.32/255.255.255.255
qualify=yes
canreinvite=no
call-limit=4
dtmfmode=rfc2833
nat=no
[8001] and [8006] are the desk ip-phone, [8020] is wireless ip-phone, and [8031] and [8032] are Zed gsm gateway. Please pay attention to [8001] and [8006] almost all the configuration are same, except one line.context. For 8001 context=internal-sip but 8006 context=recording. This line tell us that for recording / greeting purpose we will use the phone with extension 8006. So we can only dial 500 and do the recording in that phone as we set it in /etc/asterisk/extension.conf. You cannot dial 500 and do recording in the phone with the sip configuration doesn't include the line context=recording. I hope you get it :-)
For gsm gateway, I set it up just like the other as internal-sip. But there are a lot of gsm gateways out there and every brand has their own configuration so please read the manual of your gsm gateway and set it up properly. You can use it in front of digium as fxo/fxs or you can also set it up as sip extension depend on you gsm gateway type.
Let's move to chan_dahdi.conf that I already attached several post earlier. Let me remind part of the file:
[channels]
language=en
context=internal-fxo
signalling=fxs_ks
rxwink=300
cidstart=polarity
answeronpolarityswitch=no
hanguponpolarityswitch=no
pulsedial=no
cidsignalling=dtmf
busydetect=yes
busycount=6
......
echocanceller=mg2,1-12
channel => 1-12
there is line with "context=internal-fxo". Basically it means that all the channels 1 through 12 are in the context of internal-fxo. By doing this all the lines will follow the setup we already done in extensions.conf under context [internal-fxo], please take a look extensions.conf in earlier part. You got it, don't you :-) ?
Let me finish this asterisk session, 5 part seem not enough but I'm afraid this will make my blog so bore :-). So final notes is about iax.conf. If you have several locations with asterisk server in every location you can connect the server and make conversation like you dial an extension. First of all you should setup a VPN between the site. I presume you already now how to set it up, there are a lot of howto in internet. Then you should configure the iax.conf. I already give the example in previous post, let me explain. Take attention in this part:
[general]
bindport=4569
bindaddr=10.8.1.120
.......................
register => ncpabxsv:0000@10.1.1.120:4569
register => dppabxsv:0000@10.7.1.120:4569
register => ygpabxsv:0000@10.8.1.120:4569
This server address is 10.8.1.120 and the port 4569 use for the iax. We should register all the server including this server in the 3 lines at the bottom.
Also we should make the setup for every server like below:
[ncpabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.1.1.120
qualify=yes
requirecalltoken=no
[dppabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.7.1.120
qualify=yes
requirecalltoken=no
[ygpabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.8.1.120
qualify=yes
requirecalltoken=no8020>8006>8002>8001>
In all site with the asterisk server we should configure iax.conf so every server can be registered with each other. By doing this you can call other site with extension. Now take a look again our extensions.conf in this section:
[internal-sip]
exten => _1.,1,Dial(IAX2/ygpabxsv:0000@10.1.1.120/${EXTEN:1}@local)
exten => _1.,2,Hangup()
exten => _2.,1,Dial(IAX2/ygpabxsv:0000@10.7.1.120/${EXTEN:1}@local)
exten => _2.,2,Hangup()
Above lines means:
_1. --> if you start a call with "pressing 1 then follow by extension then you connect to asterisk server in ip address 10.1.1.120". 10.1.1.120/${EXTEN:1} means the asterisk server in ip 10.1.1.120 will stripe the first digit.
_2. --> if you start a call with "pressing 2 then follow by extension then you connect to asterisk server in ip address 10.7.1.120". 10.7.1.120/${EXTEN:1} means the asterisk server in ip 10.7.1.120 will stripe the first digit.
I think I already explain everything that you should know about how to setup and configure an asterisk server, make a conference room, setting up extension, and even connecting between two or more asterisk server using iax. Now it is your turn :-) You can experiment with my setting until you get used to it and try another configuration that match with what you want.
Don't forget to have a lot of fun.
One thing I found really annoying is the echo if we connect asterisk to PSTN line. I use digium TDM 410P and leave the card without tune it will give annoying echo. In my earlier post (Part 2) I explain that by running /usr/sbin/dahdi_genconf dahdi will automatically create /etc/dahdi/system.conf file that already contain information about hardware echo canceller. First thing you should remember if you have the budget is buy a card with hardware echo canceller. It will let the card to manage the echo without give the processor too much task to reduce it. After that you should tune the card. Luckily Digium give the best tools to tune the card named fxotune. To tune your card first shutdown the asterisk service and then run:
# /usr/sbin/fxotune -i 0
I put 0 (zero) because to dial an outside line I set the asterisk configuration to use 0. You should change it to whatever number you use. fxotune will create /etc/fxotune.conf file to put all the configuration it creates to reduce the echo. Pleas read "man fxotune" for more explanation about the tools.
To enable Asterisk to use the card configuration every time we boot the server we need a slight modification of init script. We should call the fxotune before we call Asterisk, you can either modify the init script of Asterisk to call fxotune before it call the Asterisk or you can modify /etc/init.d/after.local (yes, I use openSUSE). I prefer to use after.local. Create /etc/init.d/after.local and fill the lines below:
# ! /bin/sh
/usr/sbin/fxotune -s
sleep 1
/etc/init.d/asterisk161 start
Also you need to remove asterisk service from init script
# insserv -r /etc/init.d/asterisk161
You can boot the server and hear the difference. If everything goes well you can hear no echo :-)
Now let's take a look back to our extension.conf that I already give in the part 3.
[recordings]
exten => 500,1,Answer
exten => 500,2,Playback(en/silakanrekamgreeting)
exten => 500,3,Record(en/mymessage:gsm)
exten => 500,4,Playback(en/pesananda)
exten => 500,5,Playback(en/mymessage)
exten => 500,6,Playback(en/tekan1)
exten => 500,7,WaitExten(3)
exten => t,1,Playback(en/maafmohonulangi)
exten => t,2,Goto(500,5)
exten => i,1,Playback(en/pesanandasalah)
exten => i,2,Goto(500,5)
exten => 1,1,System(/bin/mv /var/lib/asterisk/sounds/en/mymessage.gsm /var/lib/asterisk/sounds/en/autoattendant.gsm)
exten => 1,2,Playback(en/terimakasih)
exten => 1,3,Playback(en/tekan3)
exten => 2,1,Goto(500,1)
exten => 3,1,Goto(500,1)
exten => 4,1,Hangup
include => internal-sip
This is the context about recording that we put it in extensions.conf and also in sip.conf, that's why I put "include => internal-sip" in the bottom of the context. We create the special extension 500 to record the greeting for our system. We will put the record as greeting, when someone from outside call our lines, then Asterisk will play this greeting. I will explain it to you don't worry :-). Those lines means:
If dial 500 then answer.
Play the sound file /var/lib/asterisk/sounds/en/silakanrekamgreeting.gsm. You can record a custom sound file which contain something like "Please record your greeting after the beep", save it as gsm format and call it from here.
Record your message (say the greeting you want to record) and put it as /var/lib/asterisk/sounds/en/mymessage.gsm
Play the file /var/lib/asterisk/sounds/en/pesananda.gsm. You can record a custom sound file which contain something like "Your greeting is", save it as gsm format and call it from here.
Play your record greeting that just you record in step 3.
Play the sound file /var/lib/asterisk/sounds/en/tekan1.gsm. You can record a custom sound file which contain something like "Please press 1 to save your message", save it as gsm format and call it from here.
Wait 3 second for pressing 1
t,1 means that if 3 seconds already time-out then play the sound file /var/lib/asterisk/sounds/en/maafmohoulangi.gsm. You can record a custom sound file which contain something like "Please re-record your message", save it as gsm format and call it from here.
t,2 go to point 6 above and repeat the steps.
i,1 means if you press another number in step 7 (you don't record the message) then play the sound file /var/lib/asterisk/sounds/en/pesanandasalah.gsm. You can record a custom sound file which contain something like "Sorry I didn't get that", save it as gsm format and call it from here.
i,2 go to point 6 above and repeat the steps.
1,1 if you press 1 in step 7 then asterisk will move /bin/mv /var/lib/asterisk/sounds/en/mymessage.gsm to /var/lib/asterisk/sounds/en/autoattendant.gsm
1,2 means play the sound file /var/lib/asterisk/sounds/en/terimakasih.gsm. You can record a custom sound file which contain something like "thankyou", save it as gsm format and call it from here.
1,3 means play the sound file /var/lib/asterisk/sounds/en/tekan3.gsm. You can record a custom sound file which contain something like "press 3 to record another message", save it as gsm format and call it from here.
include => internal-sip, means that asterisk will see also [recording] context in [internal-sip] context, usually we manage [internal-sip] in sip.conf.
Now ti's time to configure /etc/asterisk/sip.conf. This file manage the sip for ip phone and other peripheral in our setup. I use several desk ip-phone, wireless ip-phone (Polycom Kirk DECT) and also GSM gateway (Zed, Musitel etc), all of it running well. My sip.conf looks something like:
[general]
port = 5060
bindaddr = 10.7.1.120
disallow=all
allow=all
allow=ulaw
allow=gsm
context=internal-sip
;--------------------xxxxx site ---------------------------
;Polycom IP330
[8001]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
canreinvite=no
username=TELEPH01
userid=8001
callerid=TELEPH01 <8001>
mailbox=8001
allow=all
qualify=yes
[8002]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
username=TELEPH02
userid=8002
callerid=TELEPH02 <8002>
mailbox=8002
allow=all
qualify=yes
[8006]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
;context=internal-sip
context=recordings
nat=no
canreinvite=no
username=TELEPH06
userid=8006
callerid=DPTELEPH06 <8006>
mailbox=8006
allow=all
qualify=yes
; KIRK DECT 3040 at site
[8020]
type=friend
host=dynamic
dtmfmode=rfc2833
language=en
context=internal-sip
nat=no
username=TELEPH20
userid=8020
callerid=TELEPH20 <8020>
mailbox=8020
allow=all
qualify=yes
;Zed GSM GATEWAY
[8031]
type=peer
insecure=very
disallow=all
allow=ulaw
allow=alaw
allow=gsm
context=internal-sip
host=10.7.1.31
username=GS8
permit=10.7.1.31/255.255.255.255
qualify=yes
canreinvite=no
call-limit=4
dtmfmode=rfc2833
nat=no
[8032]
type=peer
insecure=very
disallow=all
allow=ulaw
allow=alaw
allow=gsm
context=internal-sip
host=10.7.1.32
username=GS8
permit=10.7.1.32/255.255.255.255
qualify=yes
canreinvite=no
call-limit=4
dtmfmode=rfc2833
nat=no
[8001] and [8006] are the desk ip-phone, [8020] is wireless ip-phone, and [8031] and [8032] are Zed gsm gateway. Please pay attention to [8001] and [8006] almost all the configuration are same, except one line.context. For 8001 context=internal-sip but 8006 context=recording. This line tell us that for recording / greeting purpose we will use the phone with extension 8006. So we can only dial 500 and do the recording in that phone as we set it in /etc/asterisk/extension.conf. You cannot dial 500 and do recording in the phone with the sip configuration doesn't include the line context=recording. I hope you get it :-)
For gsm gateway, I set it up just like the other as internal-sip. But there are a lot of gsm gateways out there and every brand has their own configuration so please read the manual of your gsm gateway and set it up properly. You can use it in front of digium as fxo/fxs or you can also set it up as sip extension depend on you gsm gateway type.
Let's move to chan_dahdi.conf that I already attached several post earlier. Let me remind part of the file:
[channels]
language=en
context=internal-fxo
signalling=fxs_ks
rxwink=300
cidstart=polarity
answeronpolarityswitch=no
hanguponpolarityswitch=no
pulsedial=no
cidsignalling=dtmf
busydetect=yes
busycount=6
......
echocanceller=mg2,1-12
channel => 1-12
there is line with "context=internal-fxo". Basically it means that all the channels 1 through 12 are in the context of internal-fxo. By doing this all the lines will follow the setup we already done in extensions.conf under context [internal-fxo], please take a look extensions.conf in earlier part. You got it, don't you :-) ?
Let me finish this asterisk session, 5 part seem not enough but I'm afraid this will make my blog so bore :-). So final notes is about iax.conf. If you have several locations with asterisk server in every location you can connect the server and make conversation like you dial an extension. First of all you should setup a VPN between the site. I presume you already now how to set it up, there are a lot of howto in internet. Then you should configure the iax.conf. I already give the example in previous post, let me explain. Take attention in this part:
[general]
bindport=4569
bindaddr=10.8.1.120
.......................
register => ncpabxsv:0000@10.1.1.120:4569
register => dppabxsv:0000@10.7.1.120:4569
register => ygpabxsv:0000@10.8.1.120:4569
This server address is 10.8.1.120 and the port 4569 use for the iax. We should register all the server including this server in the 3 lines at the bottom.
Also we should make the setup for every server like below:
[ncpabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.1.1.120
qualify=yes
requirecalltoken=no
[dppabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.7.1.120
qualify=yes
requirecalltoken=no
[ygpabxsv]
type=friend
auth=md5
secret=0000
context=local
host=dynamic
defaultip=10.8.1.120
qualify=yes
requirecalltoken=no8020>8006>8002>8001>
In all site with the asterisk server we should configure iax.conf so every server can be registered with each other. By doing this you can call other site with extension. Now take a look again our extensions.conf in this section:
[internal-sip]
exten => _1.,1,Dial(IAX2/ygpabxsv:0000@10.1.1.120/${EXTEN:1}@local)
exten => _1.,2,Hangup()
exten => _2.,1,Dial(IAX2/ygpabxsv:0000@10.7.1.120/${EXTEN:1}@local)
exten => _2.,2,Hangup()
Above lines means:
_1. --> if you start a call with "pressing 1 then follow by extension then you connect to asterisk server in ip address 10.1.1.120". 10.1.1.120/${EXTEN:1} means the asterisk server in ip 10.1.1.120 will stripe the first digit.
_2. --> if you start a call with "pressing 2 then follow by extension then you connect to asterisk server in ip address 10.7.1.120". 10.7.1.120/${EXTEN:1} means the asterisk server in ip 10.7.1.120 will stripe the first digit.
I think I already explain everything that you should know about how to setup and configure an asterisk server, make a conference room, setting up extension, and even connecting between two or more asterisk server using iax. Now it is your turn :-) You can experiment with my setting until you get used to it and try another configuration that match with what you want.
Don't forget to have a lot of fun.
Comments
Post a Comment