Difference between revisions of "Asterisk"

From ArchWiki
Jump to: navigation, search
(Installation)
(Connecting to the PSTN: fix link (company renamed))
 
(22 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Category:Telephony and Voice]]
+
[[Category:Telephony and voice]]
 
+
[[ja:Asterisk]]
{{out of date}}
+
 
+
{{Article summary start}}
+
{{Article summary text|Asterisk is a complete PBX (private branch exchange) in software. It runs on Linux, BSD, Windows and OS X and provides all of the features you would expect from a PBX.}}
+
{{Article summary end}}
+
 
+
 
[http://www.asterisk.org Asterisk] is a complete PBX (private branch exchange) in software. It runs on Linux, BSD, Windows and OS X and provides all of the features you would expect from a PBX and more. Asterisk does voice over IP in four protocols, and can interoperate with almost all standards-based telephony equipment using relatively inexpensive hardware.
 
[http://www.asterisk.org Asterisk] is a complete PBX (private branch exchange) in software. It runs on Linux, BSD, Windows and OS X and provides all of the features you would expect from a PBX and more. Asterisk does voice over IP in four protocols, and can interoperate with almost all standards-based telephony equipment using relatively inexpensive hardware.
  
 
Asterisk provides voice-mail services with directory, call conferencing, interactive voice response and call queuing. It has support for three-way calling, caller ID services, ADSI, IAX, SIP, H.323 (as both client and gateway), MGCP (call manager only) and SCCP/Skinny.  
 
Asterisk provides voice-mail services with directory, call conferencing, interactive voice response and call queuing. It has support for three-way calling, caller ID services, ADSI, IAX, SIP, H.323 (as both client and gateway), MGCP (call manager only) and SCCP/Skinny.  
  
This article will show you how to configure a simple in house network enabling us to use a SIP [[soft-phone]] to talk to another SIP soft-phone on your LAN.
+
This article will show you how to configure a simple in house network enabling us to use a SIP [[softphone]] to talk to another SIP softphone on your LAN.
  
 
==Installation==
 
==Installation==
  
Install {{AUR|asterisk}} from the [[AUR]]. Start the server with <pre># rc.d start asterisk</pre>.
+
Install the {{AUR|asterisk}} package.
 +
 
 +
[[Start]] the server with {{ic|asterisk.service}}.
 +
 
 +
You will also need a SIP [[softphone]] and at least two machines. Recommendations for SIP phones are [http://www.linphone.org/ Linphone] ({{Pkg|linphone}} package) or [http://www.counterpath.com/x-lite/ X-Lite] ({{AUR|xlite_bin}} package).
  
You may also want to install [https://aur.archlinux.org/packages.php?ID=10223 asterisk-addons], [https://aur.archlinux.org/packages.php?ID=10224 asterisk-sounds] and [https://aur.archlinux.org/packages.php?ID=24364 zaptel]. You will also need a SIP [[soft-phone]] and at least two machines. Recommendations for SIP phones are [http://www.wirlab.net/kphone/ kphone], in the AUR and [http://www.xten.net/index.php?menu=X-Series x-lite], a binary package.
+
To enable ilbc codec support add the following to the very beginning of the {{ic|build}} section of the PKGBUILD:
 +
{{bc|<nowiki>
 +
cd ${srcdir}/${pkgname}-${pkgver}/contrib/scripts
 +
echo | ./get_ilbc_source.sh
 +
</nowiki>}}
  
 
==Configuration==
 
==Configuration==
 
===SIP===
 
===SIP===
 
Assuming your asterisk server is up and running, we will only need to edit two files: {{ic|sip.conf}} and {{ic|extensions.conf}}. Change to your asterisk configuration directory (should be {{ic|/etc/asterisk}}). Edit sip.conf and place the following:
 
Assuming your asterisk server is up and running, we will only need to edit two files: {{ic|sip.conf}} and {{ic|extensions.conf}}. Change to your asterisk configuration directory (should be {{ic|/etc/asterisk}}). Edit sip.conf and place the following:
<pre>
+
{{bc|1=
 
[me1]
 
[me1]
 
type=friend
 
type=friend
Line 36: Line 38:
 
host=dynamic
 
host=dynamic
 
context=house
 
context=house
</pre>
+
}}
  
 
This creates our two SIP users {{Ic|me1}} and {{Ic|me2}} with a password of {{Ic|PASSWORD}} in the {{Ic|house}} context.
 
This creates our two SIP users {{Ic|me1}} and {{Ic|me2}} with a password of {{Ic|PASSWORD}} in the {{Ic|house}} context.
  
 
We will be defining the context next -- edit extensions.conf with the following:
 
We will be defining the context next -- edit extensions.conf with the following:
<pre>
+
{{bc|1=
 
[house]
 
[house]
 
exten => 100,1,Dial(SIP/me1)
 
exten => 100,1,Dial(SIP/me1)
  
 
exten => 101,1,Dial(SIP/me2)
 
exten => 101,1,Dial(SIP/me2)
</pre>
+
}}
  
 
This creates the context {{Ic|house}} and assigns extension 100 to the SIP user {{Ic|me1}}, and extension 101 to the SIP user {{Ic|me2}}. Now all thats left is to see if it works.
 
This creates the context {{Ic|house}} and assigns extension 100 to the SIP user {{Ic|me1}}, and extension 101 to the SIP user {{Ic|me2}}. Now all thats left is to see if it works.
===Music On Hold===  
+
===Music on hold===
 
Music on hold is a really sweet feature. And once again easy to install and configure.
 
Music on hold is a really sweet feature. And once again easy to install and configure.
 
Edit {{ic|/etc/asterisk/musiconhold.conf}} and add, or make sure it is uncommented:
 
Edit {{ic|/etc/asterisk/musiconhold.conf}} and add, or make sure it is uncommented:
<pre>
+
{{bc|1=
 
[default]
 
[default]
 
mode=files
 
mode=files
 
directory=/var/lib/asterisk/mohmp3
 
directory=/var/lib/asterisk/mohmp3
</pre>
+
}}
 
Now go into your sip.conf
 
Now go into your sip.conf
<pre>
+
{{bc|1=
 
musiconhold=default
 
musiconhold=default
</pre>
+
}}
  
 
And that is all there is to it. Just copy your favorite legally obtained MP3 to {{ic|/var/lib/asterisk/mohmp3}}.
 
And that is all there is to it. Just copy your favorite legally obtained MP3 to {{ic|/var/lib/asterisk/mohmp3}}.
Line 68: Line 70:
  
 
Create/edit your {{ic|voicemail.conf}}:
 
Create/edit your {{ic|voicemail.conf}}:
<pre>
+
{{bc|<nowiki>
 
[general]
 
[general]
 
format=gsm|wav49|wav
 
format=gsm|wav49|wav
Line 79: Line 81:
 
[default]
 
[default]
 
100 => 1234,Me,me@mydomain.com
 
100 => 1234,Me,me@mydomain.com
</pre>
+
</nowiki>}}
  
 
What does this mean? Most of the {{Ic|[general]}} is pretty self-explanatory. However, do note that if you have postfix set up right the PBX will send an email notifying the user of a new voice-mail and if {{Ic|1=attach=yes}} is defined it will attach the file.
 
What does this mean? Most of the {{Ic|[general]}} is pretty self-explanatory. However, do note that if you have postfix set up right the PBX will send an email notifying the user of a new voice-mail and if {{Ic|1=attach=yes}} is defined it will attach the file.
Line 99: Line 101:
 
{{Note|The 'VoiceMail' applications have a significant amount of options, so it is suggested reading over some additional documentation. This is just for a basic, home use setup.  Also note that it is generally a good idea to use extensions higher then your users extensions for accessing 'VoiceMail'. This way someone dialing 208 does not hit someone's voice-mail at 205.}}
 
{{Note|The 'VoiceMail' applications have a significant amount of options, so it is suggested reading over some additional documentation. This is just for a basic, home use setup.  Also note that it is generally a good idea to use extensions higher then your users extensions for accessing 'VoiceMail'. This way someone dialing 208 does not hit someone's voice-mail at 205.}}
  
===Connecting To The PSTN===
+
===Connecting to the PSTN===
Now that you have the previous setup, it is time to actually connect to the outside world. To do this, you will need a provider such as [http://pstn.junctionnetworks.com/ Junction Networks]. Your provider should have instructions on connecting to asterisk, so this section is very general.
+
Now that you have the previous setup, it is time to actually connect to the outside world. To do this, you will need a provider such as [https://www.onsip.com/ OnSIP]. Your provider should have instructions on connecting to asterisk, so this section is very general.
  
====General Set-up====
+
====General set-up====
 
=====sip.conf=====
 
=====sip.conf=====
<pre>
+
{{bc|1=
 
[general]
 
[general]
 
register => username:password@sip.specific.com
 
register => username:password@sip.specific.com
Line 115: Line 117:
 
secret=passwordduh
 
secret=passwordduh
 
type=peer
 
type=peer
</pre>
+
}}
  
 
=====extensions.conf=====
 
=====extensions.conf=====
<pre>
+
{{bc|1=
 
[outboundwithCID]  ; this can be whatever
 
[outboundwithCID]  ; this can be whatever
 
exten => _1NXXNXXXXXX,1,SetCIDNum(15555551234)
 
exten => _1NXXNXXXXXX,1,SetCIDNum(15555551234)
Line 124: Line 126:
 
exten => _1NXXNXXXXXX,3,Congestion()
 
exten => _1NXXNXXXXXX,3,Congestion()
 
exten => _1NXXNXXXXXX,103,Busy()
 
exten => _1NXXNXXXXXX,103,Busy()
 
  
 
[default]  ; This should be set in your sip.conf for incoming calls
 
[default]  ; This should be set in your sip.conf for incoming calls
Line 133: Line 134:
 
exten => 1NXXNXXXXXX,2,Playback(ttt-weasels)
 
exten => 1NXXNXXXXXX,2,Playback(ttt-weasels)
 
exten => 1NXXNXXXXXX,3,HangUp()
 
exten => 1NXXNXXXXXX,3,HangUp()
</pre>
+
}}
  
 
*In the outbound context, any number dialed will be sent out to your service provider. The 'whatever' in the 2 priority should match what you have in your sip.conf.
 
*In the outbound context, any number dialed will be sent out to your service provider. The 'whatever' in the 2 priority should match what you have in your sip.conf.
Line 142: Line 143:
  
 
Now edit your iax.conf with the following in the 'general' section:
 
Now edit your iax.conf with the following in the 'general' section:
<pre>
+
{{bc|1=
 
register => FWDNUMBER:PASSWORD@iax2.fwdnet.net  
 
register => FWDNUMBER:PASSWORD@iax2.fwdnet.net  
 
disallow = all
 
disallow = all
 
allow = ulaw
 
allow = ulaw
</pre>
+
}}
  
 
And at the bottom add:
 
And at the bottom add:
<pre>
+
{{bc|1=
 
[iaxfwd]
 
[iaxfwd]
 
type=user
 
type=user
Line 155: Line 156:
 
auth=rsa
 
auth=rsa
 
inkeys=freeworlddialup
 
inkeys=freeworlddialup
</pre>
+
}}
  
 
This allows calls from FWD.
 
This allows calls from FWD.
Line 161: Line 162:
 
=====extensions.conf=====
 
=====extensions.conf=====
 
Place this at the top under '[globals]':
 
Place this at the top under '[globals]':
<pre>
+
{{bc|1=
 
FWDNUMBER=MYFWDNUMBER ; your calling number
 
FWDNUMBER=MYFWDNUMBER ; your calling number
 
FWDCIDNAME="MyName"; your caller id
 
FWDCIDNAME="MyName"; your caller id
Line 167: Line 168:
 
FWDRINGS=sip/office ; the phone to ring
 
FWDRINGS=sip/office ; the phone to ring
 
FWDVMBOX=1000 ; the VM box for this user
 
FWDVMBOX=1000 ; the VM box for this user
</pre>
+
}}
  
 
Next, add this to a context for outgoing:
 
Next, add this to a context for outgoing:
<pre>
+
{{bc|1=
 
exten => _393.,1,SetCallerId,${FWDCIDNAME}
 
exten => _393.,1,SetCallerId,${FWDCIDNAME}
 
exten => _393.,2,Dial(IAX2/${FWDNUMBER}:${FWDPASSWORD}@iax2.fwdnet.net/${EXTEN:3},60,r)
 
exten => _393.,2,Dial(IAX2/${FWDNUMBER}:${FWDPASSWORD}@iax2.fwdnet.net/${EXTEN:3},60,r)
 
exten => _393.,3,Congestion
 
exten => _393.,3,Congestion
</pre>
+
}}
  
 
You can change the '393' to whatever you want. This is what you will dial before dialing a 'fwd' number. For instance, to dial '744561' you would dial '393744561'.
 
You can change the '393' to whatever you want. This is what you will dial before dialing a 'fwd' number. For instance, to dial '744561' you would dial '393744561'.
  
 
And lastly, the incoming calls:
 
And lastly, the incoming calls:
<pre>
+
{{bc|1=
 
[fromiaxfwd]
 
[fromiaxfwd]
 
exten => ${FWDNUMBER},1,Dial(${FWDRINGS},20,r)
 
exten => ${FWDNUMBER},1,Dial(${FWDRINGS},20,r)
 
exten => ${FWDNUMBER},2,Voicemail,u${FWDVMBOX}
 
exten => ${FWDNUMBER},2,Voicemail,u${FWDVMBOX}
 
exten => ${FWDNUMBER},102,Voicemail,b${FWDVMBOX}
 
exten => ${FWDNUMBER},102,Voicemail,b${FWDVMBOX}
</pre>
+
}}
  
 
{{Note|If you have problems try removing the variables from {{ic|extensions.conf}}. These instructions are from FWD's site and I have not been tested by this article's author.}}
 
{{Note|If you have problems try removing the variables from {{ic|extensions.conf}}. These instructions are from FWD's site and I have not been tested by this article's author.}}
Line 190: Line 191:
 
Extensions to try calling are 55555 (a volunteer maned test line) and 514 (conference).
 
Extensions to try calling are 55555 (a volunteer maned test line) and 514 (conference).
  
 +
===Sounds===
 +
Sounds are stored in the folder {{ic|/var/lib/asterisk/xx}}, {{ic|xx}} stands for the code of the language for example "en" for English. To add new sounds copy them to the folder. Preserve the following folder structure:
 +
{{bc|
 +
/var/lib/asterisk/sounds/xx
 +
/var/lib/asterisk/sounds/xx/digits
 +
/var/lib/asterisk/sounds/xx/letters
 +
/var/lib/asterisk/sounds/xx/phonetic
 +
}}
 +
 +
Edit the language parameter in the {{ic|sip.conf}}
 +
{{bc|1=
 +
[general]
 +
...
 +
language=en
 +
...
 +
}}
 +
Possible sources for sounds are:
 +
* http://downloads.asterisk.org/pub/telephony/sounds/
 +
* https://packages.debian.org/wheezy/all/asterisk-prompt-xx
 +
** [https://packages.debian.org/wheezy/all/asterisk-prompt-fr fr]
 +
** [https://packages.debian.org/wheezy/all/asterisk-prompt-de de]
 +
** ...
 +
* [http://www.voip-info.org/wiki/view/Asterisk+sound+files+international voip-info.org]
 
===MeetMe===
 
===MeetMe===
 
MeetMe is the application that allows you to do conference calling. Same as everything, basic setup is easy.
 
MeetMe is the application that allows you to do conference calling. Same as everything, basic setup is easy.
Line 201: Line 225:
 
{{Note|You ''must'' have the zaptel package in order for MeetMe to work. Install it and run {{Ic|modprobe ztdummy}} before running asterisk. This provides digium timing for us without cards so we can utilize TDM.}}
 
{{Note|You ''must'' have the zaptel package in order for MeetMe to work. Install it and run {{Ic|modprobe ztdummy}} before running asterisk. This provides digium timing for us without cards so we can utilize TDM.}}
  
==Asterisk Console And Softphones==
+
==Asterisk console and softphones==
 
Now lets get Asterisk going:  
 
Now lets get Asterisk going:  
 
  # asterisk -vvvvvvc
 
  # asterisk -vvvvvvc

Latest revision as of 10:20, 15 June 2016

Asterisk is a complete PBX (private branch exchange) in software. It runs on Linux, BSD, Windows and OS X and provides all of the features you would expect from a PBX and more. Asterisk does voice over IP in four protocols, and can interoperate with almost all standards-based telephony equipment using relatively inexpensive hardware.

Asterisk provides voice-mail services with directory, call conferencing, interactive voice response and call queuing. It has support for three-way calling, caller ID services, ADSI, IAX, SIP, H.323 (as both client and gateway), MGCP (call manager only) and SCCP/Skinny.

This article will show you how to configure a simple in house network enabling us to use a SIP softphone to talk to another SIP softphone on your LAN.

Installation

Install the asteriskAUR package.

Start the server with asterisk.service.

You will also need a SIP softphone and at least two machines. Recommendations for SIP phones are Linphone (linphone package) or X-Lite (xlite_binAUR package).

To enable ilbc codec support add the following to the very beginning of the build section of the PKGBUILD:

cd ${srcdir}/${pkgname}-${pkgver}/contrib/scripts
echo | ./get_ilbc_source.sh

Configuration

SIP

Assuming your asterisk server is up and running, we will only need to edit two files: sip.conf and extensions.conf. Change to your asterisk configuration directory (should be /etc/asterisk). Edit sip.conf and place the following:

[me1]
type=friend
username=me1
secret=PASSWORD
host=dynamic
context=house

[me2]
type=friend
username=me2
secret=PASSWORD
host=dynamic
context=house

This creates our two SIP users me1 and me2 with a password of PASSWORD in the house context.

We will be defining the context next -- edit extensions.conf with the following:

[house]
exten => 100,1,Dial(SIP/me1)

exten => 101,1,Dial(SIP/me2)

This creates the context house and assigns extension 100 to the SIP user me1, and extension 101 to the SIP user me2. Now all thats left is to see if it works.

Music on hold

Music on hold is a really sweet feature. And once again easy to install and configure. Edit /etc/asterisk/musiconhold.conf and add, or make sure it is uncommented:

[default]
mode=files
directory=/var/lib/asterisk/mohmp3

Now go into your sip.conf

musiconhold=default

And that is all there is to it. Just copy your favorite legally obtained MP3 to /var/lib/asterisk/mohmp3.

Voicemail

Voicemail is another feature of asterisk. There are many ways to configure it, however this article only covers a simple approach.

Create/edit your voicemail.conf:

[general]
format=gsm|wav49|wav
serveremail=asterisk
attach=no
mailcmd=/usr/sbin/sendmail -t
maxmessage=180
maxgreet=60

[default]
100 => 1234,Me,me@mydomain.com

What does this mean? Most of the [general] is pretty self-explanatory. However, do note that if you have postfix set up right the PBX will send an email notifying the user of a new voice-mail and if attach=yes is defined it will attach the file.

Now for the actual mailbox. The format is:

mailbox => password,user,email

In this case, we gave 'Me' (email me@mydomain.com) mailbox 100, with a password of 1234.

Now we have to have a way to leave messages to this voice-mail, and a way to access it. For this, we go back to the extensions.conf and modify your existing entry as follows:

exten => 100,1,Dial(SIP/me1,20)
exten =>100,2,Voicemail(100@default)

The 20 on the end of the first 'exten' tells 'Dial()' to call for 20 seconds. If no one answers it heads to voice-mail box 100 in the default context.

Next is actually accessing your voicemail. For this we add:

exten => 600,1,VoiceMailMain,s100@default

So when we call 600, the application 'VoiceMailMain' goes to 100 in the default context. The s allows for automatic login.

Note: The 'VoiceMail' applications have a significant amount of options, so it is suggested reading over some additional documentation. This is just for a basic, home use setup. Also note that it is generally a good idea to use extensions higher then your users extensions for accessing 'VoiceMail'. This way someone dialing 208 does not hit someone's voice-mail at 205.

Connecting to the PSTN

Now that you have the previous setup, it is time to actually connect to the outside world. To do this, you will need a provider such as OnSIP. Your provider should have instructions on connecting to asterisk, so this section is very general.

General set-up

sip.conf
[general]
register => username:password@sip.specific.com

[whatever]                   
fromdomain=specific.com     
host=sip.specific.com
insecure=very    ; check with provider
username=usernameduh
secret=passwordduh
type=peer
extensions.conf
[outboundwithCID]  ; this can be whatever
exten => _1NXXNXXXXXX,1,SetCIDNum(15555551234)
exten => _1NXXNXXXXXX,2,Dial(SIP/${EXTEN}@whatever)
exten => _1NXXNXXXXXX,3,Congestion()
exten => _1NXXNXXXXXX,103,Busy()

[default]  ; This should be set in your sip.conf for incoming calls

;These should to be changed to your actual number
; ie     15555555555
exten => 1NXXNXXXXXX,1,Answer()
exten => 1NXXNXXXXXX,2,Playback(ttt-weasels)
exten => 1NXXNXXXXXX,3,HangUp()
  • In the outbound context, any number dialed will be sent out to your service provider. The 'whatever' in the 2 priority should match what you have in your sip.conf.
  • Of course, the inbound dial-plan can be modified to do what you want. For instance, you can have Dial(SIP/me1) so when someone calls your number they are routed to your SIP phone on your computer. Then add in voice-mail and so on.
iax.conf

The first step is to log into FWD and enable their side of IAX. It is under extra features, and keep in mind that the authors claim it takes a little while to activate.

Now edit your iax.conf with the following in the 'general' section:

register => FWDNUMBER:PASSWORD@iax2.fwdnet.net 
disallow = all
allow = ulaw

And at the bottom add:

[iaxfwd]
type=user
context=fromiaxfwd
auth=rsa
inkeys=freeworlddialup

This allows calls from FWD.

extensions.conf

Place this at the top under '[globals]':

FWDNUMBER=MYFWDNUMBER ; your calling number
FWDCIDNAME="MyName"; your caller id
FWDPASSWORD=MYFWDPASSWORD ; your password
FWDRINGS=sip/office ; the phone to ring
FWDVMBOX=1000 ; the VM box for this user

Next, add this to a context for outgoing:

exten => _393.,1,SetCallerId,${FWDCIDNAME}
exten => _393.,2,Dial(IAX2/${FWDNUMBER}:${FWDPASSWORD}@iax2.fwdnet.net/${EXTEN:3},60,r)
exten => _393.,3,Congestion

You can change the '393' to whatever you want. This is what you will dial before dialing a 'fwd' number. For instance, to dial '744561' you would dial '393744561'.

And lastly, the incoming calls:

[fromiaxfwd]
exten => ${FWDNUMBER},1,Dial(${FWDRINGS},20,r)
exten => ${FWDNUMBER},2,Voicemail,u${FWDVMBOX}
exten => ${FWDNUMBER},102,Voicemail,b${FWDVMBOX}
Note: If you have problems try removing the variables from extensions.conf. These instructions are from FWD's site and I have not been tested by this article's author.

Extensions to try calling are 55555 (a volunteer maned test line) and 514 (conference).

Sounds

Sounds are stored in the folder /var/lib/asterisk/xx, xx stands for the code of the language for example "en" for English. To add new sounds copy them to the folder. Preserve the following folder structure:

/var/lib/asterisk/sounds/xx
/var/lib/asterisk/sounds/xx/digits
/var/lib/asterisk/sounds/xx/letters
/var/lib/asterisk/sounds/xx/phonetic

Edit the language parameter in the sip.conf

[general]
...
language=en
...

Possible sources for sounds are:

MeetMe

MeetMe is the application that allows you to do conference calling. Same as everything, basic setup is easy.

Edit meetme.conf:

conf => 1000

Next is extensions.conf

exten => 999,1,MeetMe(1000|M)

Now dial 999 to get into conference 1000. The enables music on hold if no one is in there. It will automatically go away when someone joins the conference.

Note: You must have the zaptel package in order for MeetMe to work. Install it and run modprobe ztdummy before running asterisk. This provides digium timing for us without cards so we can utilize TDM.

Asterisk console and softphones

Now lets get Asterisk going:

# asterisk -vvvvvvc

This will give us the Asterisk CLI with verbose output. If Asterisk is already running you will need to use:

# asterisk -r

Now fire up your SIP clients and set them up with the information in the sip.conf. Switch back to your Asterisk CLI and you should see:

Registered SIP 'me1' at 192.168.0.142 port 5061 expires 60

Now you should be able to dial 101 from me1 and talk to me2.

Troubleshooting

If you receive a 404 Not Found error check your extensions.conf and the number you dialed.