Asterisk Notes

From Stu2
Jump to navigation Jump to search

Notes about Asterisk VoIP PBX

FreePBX 2.11, Asterisk 11 and Ubuntu 12.04

I installed 2.10 from scratch and tried to upgrade to 2.11. Upgrading to 2.11 was a mess. I essentially ripped out asterisk, freepbx (/var/www/html) and deleted all the mysql tables. Luckily, I kept the workign /etc/asterisk directory in another place so I could refer to it. The point is to get google voice to work using chan_motif.

Use this link, which is pretty standard. Add openssl to the list of installed packages, otherwise SIP won't compile.

Install Asterisk: http://www.kartook.com/2012/05/ubuntu-how-to-install-asterisk-10-on-ubuntu-12-04-lts/

Don't install the sample files, or do and then delete the ones that FreePBX complains about regarding 'symlinks' in the first status web page. When you install FreePBX, the 'main' config files are not overwritten. This means the 'main' conf files never get the #includes to the 'additional' conf files. Then reload amportal. I discovered this when SIP phones wouldn't register.

Install FreePBX. There are lots of things that go wrong. The following link explains most of those things. The worst problem is with webroot. This fellow leaves Apache2 as is and configures FreePBX to use /var/www. You install freepbx the first time with the apache user as www-data:www-data. Then change the apache user to asterisk:www-data. See his posting for details.

http://ubuntuforums.org/showthread.php?p=12300646#post12300646

Change the directory permissions for /var/lib/php5 to 777. You may need to change the session file in that directory, if you don't reboot first. The symptom for this breakage is the web gui returns to the admin page and/or gives you an error about jquery.

To add IPv6 capability, in sip_general_custom.conf, add:

bindaddr=::

MWI, TDM400P and DAHDI

Talk about esoteric.... the VM boxes for the DAHDI lines are defined in /etc/dahdi/genconf_parameters. The base extension defaults to 4000. If the mailbox= parameter in CLI> dahdi show channel 1 - doesn't match the extension #, you wont' get a MWI indicator. I also set mwisendtype=neon in /etc/asterisk/chan_dahdi.conf.

FreePBX and Google Voice

Notes:

Use chan_motif and the 'Google Voice/Chan Motif' plugin under FreePBX. The asterisk module needs to be compiled using 'config menuselect' and choosing chan_motif. Use Asterisk 11 and FreePBX 2.11.

Make sure to use a different gmail.com account than your personal gmail account when activating your google voice account. Having two google accounts connected from the same IP address apparently makes the service less reliable. Astrisk will sign into the gmail account permanently and there isn't any way to change the status or status message. Although, I noticed if the status is changed from 'available' to 'unavailable', Google wouldn't forward the call to Asterisk. So perhaps this may be a way of sending presence data to GV someday.

The Google Voice module is simple to configure. However, it will install the code to send a DTMF 1, when google calls the asterisk server. Then, the call is routed to the other contexts within asterisk. If you configure Google to call other phones, such as a cell phone, the other phones won't ring because by sending the '1', Google thinks a phone was answered.

exten => s,n,Wait(1)
exten => s,n,Answer
exten => s,n,SendDTMF(1)

My solution is to tell FreePBX to NOT send the '1' and then overide the system Asterisk Dial Options for each extension in the Google inbound path. Add 'TtrD:1' to the Extensions Options and check 'override'. This will send a '1' when the phone is answered. To get FreePBX to skip the auto send DTMF 1, I added the following to /etc/asterisk/extensions_custom.conf:

[im-CONTEXT-custom]
exten => s,1(1),Noop(Receiving GoogleVoice on DID: xxxxxxxxxx)
exten => s,2,Noop(${EXTEN})
exten => s,3,Set(CALLERID(name)=${CUT(CALLERID(name),@,1)})
exten => s,4,GotoIf($["${CALLERID(name):0:2}" != "+1"]?nextstop)
exten => s,5,Set(CALLERID(name)=${CALLERID(name):2})
exten => s,6(nextstop),GotoIf($["${CALLERID(name):0:1}" != "+"]?notrim)
exten => s,7,Set(CALLERID(name)=${CALLERID(name):1})
exten => s,8(notrim),Set(CALLERID(number)=${CALLERID(name)})
exten => s,9,Goto(from-trunk,xxxxxxxxxx,1)
exten => h,1,Hangup

where CONTEXT is the context included by the Google Voice module located in extensions_additional.conf.
And xxxxxxxxxxx is the Google Phone number.
Note - I added the sequencial steps (1-9)

Conference

Add a conference to the configuration using the FreePBX Conference app. To get people in there:

  • Answer the call or call person 'A'
  • Blind Transfer them into the conference room '##Ext'
  • Call person 'B'
  • Blind Transfer them into the conference room '##Ext'
  • Call the conference: Ext

All three people should be in the room.

Phones

Polycom 501

Default password Polycom/456

sip.conf

[poly1]  ;use in dial statements e.g. dial (SIP/poly1,20,tr)
type=friend  ;make calls and recieve calls
username=xxx  ;username programmed into phone
secret=yyy  ;SIP password
host=dynamic
defaultip=192.168.a.b ;IP address of phone
context=internal  ;phone used in this context within extensions.conf
callerid="Polycom"
mailbox=z
qualify=yes  ;check reachability every 300 seconds

Budetone 101

sip.conf

[phone2]
type=friend
context=internal
username=xxx
secret=yyy
fromuser=xxx
callerid="Name <ext>"
host=dynamic
defaultip=192.168.a.c
nat=no
canreinvite=no
dtmfmode=rfc2833
mailbox=z
disallow=all
allow=ulaw
allow=alow
qaulify=yes

X-lite phone - what a great soft phone!

sip.conf

; Stu's x-lite phone
[xlite]
type=friend
username=xxx
secret=yyy
host=dynamic
regexten=zzzz
dtmfmode=rfc2833
context=internal
callerid="Computer"<zzzz>
mailbox=
disallow=all
allow=gsm

Conference Calls

Using VoIP phones is a little different than analog. With an analog loop, any extension can pick up the phone and join the conversation. With VoIP phones, the second user has to be conferenced in or have the call transferred.

Just a quick update - conference call seems to work on both my Polycom and Bugdetone phone. So to solve the problem:

Phone rings on A and B

A -> answers phone, first to pick up, so seizes the channel
A -> press conference call button - which places the caller on hold and provides a dial tone for A
A -> dial B's extension

Phone rings at B

B -> answers phone
A -> press conference call button - all three parties are now on the same stream

So A has to know the extension of B. You can't just yell at B to 'pickup the phone' like an analog loop. Works with two phones and seems easy.Don't know if it works with more lines?

Linking with SIP

Here's how to trunk two asterisk boxes using FreePBX and SIP. We have two Asterisk servers; ServerA (192.168.1.1) and ServerB (192.168.2.1) Essentially, you configure the outgoing settings as 'type=friend' and use the same from/to user names. Make sure the context is 'from-internal' so both boxes look like they are 'on the inside.' That way, you can route calls across the linking trunk and use an outbound trunk on the remote box. (e.g. pstn)

The context is important. If the context is listed as 'from-internal' you will be able to place outbound calls on the PSTN lines from the remote asterisk box. Howerver, you will not be able to dial internal misc destinations (e.g. VM). If the context is 'from-trunk', you will not be able to dial out on a PSTN line, but you will be able to dial internal trunks. In my case, I had to create two trunks, one listed as 'from-internal' and the other as 'from-trunk', then I set the outbound dialing rules accordingly. That is, route the internal extensions to the trunk listed with the context 'from-trunk'.

On ServerA create a trunk and fill in the following (leave off the comments which start with a ;):

Outgoing Settings

Trunk Name: home
PEER Details:
type=friend             ;peer+user handles both incoming and outgoing
context=from-internal   ;puts this stuff in the right context for FreePBX, makes the other box look like an insider
canreinvite=no          ; probably not needed
dtmfmode=rfc2833        ; dtmf is not 'inband' GSM would distort the tones
nat=no                  ; not using NAT
username=home           ; matches incoming name
fromuser=home           ; used as outgoing name
secret=scratchy         ; password
host=192.168.2.1        ; host to call
defaultip=192.168.2.1   ; host IP to call
disallow=all            ; only use GSM - this is your choice
allow=gsm

On ServerB create a trunk and fill in the following, using the IP address of ServerA:

Outgoing Settings

Trunk Name: home
PEER Details:
type=friend
context=from-internal
canreinvite=no
dtmfmode=rfc2833
nat=no
username=home
fromuser=home
secret=scratchy
host=192.168.1.1
defaultip=192.168.1.1
disallow=all
allow=gsm

On ServerA create a misc destination, such as "Echo Test" using the built in functions. (Need the Misc Destination and Info Services Module).

Description: Echo Test
Dial: {infoservices:echotest}

On ServerA Assign an incoming route to the the Misc Destination. For example:

Description: Echo Test
DID Number: 2600
Set Destination: Misc Destinations <Echo Test>

On ServerB create an Outbound route.

Dial Patterns: 2600

Trunk Sequence: SIP/home

From an extension on ServerB, you should be able to dial '2600' to place a call to ServerA's Echo Test. Now you can make more complicated dial plans.

Linking with IAX2

On server A – The IP address is 192.168.62.33 (mini-itx w/dynamic address) listening on port 4569.

This server registers with the other server. (Server B)

iax.conf

[general]
register => serverA:[email protected]

[serverB]
type=friend
secret=password
auth=md5
host=192.168.62.36
context=internal
trunk=yes
qualify=yes

extensions.conf

[globals]
REMOTE = IAX2/serverA:[email protected]
[internal]
exten => 107,1,Dial(${REMOTE}/105,30,r)
exten => 107,2,Congestion
exten => _7.,1,Dial(${REMOTE}/${EXTEN:1},60,r)
exten => _7.,2,Congestion

Check the registry for success.

CLI> iax2 show registry

On server B – The IP address is 192.168.62.36 (home w/static IP address) listening on port 4569

iax.conf

[serverA]
type=friend
auth=md5
secret=password
host=dynamic
context=internal
trunk=yes
qualify=yes

extensions.conf

[globals]
REMOTE = IAX2/serverB:[email protected]
[internal]
exten => 107,1,Dial(${REMOTE}/105,30,r)
exten => 107,2,Congestion
exten => _7.,1,Dial(${REMOTE}/${EXTEN:1},60,r)
exten => _7.,2,Congestion

Check the peers for success

CLI> iax2 show peers

Notes:

If one of the addresses is dynamic (e.g. NATed), make it server A. That way, server A registers with Server B using the iax.conf register statement (on server A), which updates server B with the dynamic address of server A. In server B's extension.conf file, refer to the server as 'serverA' (instead of the IP address) and asterisk will substitute the server A's registered IP address.

Make sure iax binds to the same port, which is 4596. Comment out bindaddr=0.0.0.0.

Upgrading to 1.4

Use SVN as per the Digium site.

make menuselect

Jabber needs something.

Check for gotchas in the dial plan. (extensions.conf).

ResponseTimeout => set(TIMEOUT(response)=30)

Remove the leading 'u in '[email protected]' where used.

Common Mailbox

To get all the extensions to dump into a common mailbox, you need to do the following:

  • For each extension, make the default mailbox [email protected]
  • Set up follow me for each extension to go to the unavailable message on mailbox 3
  • Record the 'unavailable message' in MB 3

Note, I tried using mailbox 1, but the *97 feature still dials 3. So it depends on some sort of ordering, but I don't know where.