Hak5
Save 10% at GoDaddy.com with coupon code HAK

Asterisk

From Hak5

Jump to: navigation, search

This project is to be a tutorial on how to install Asterisk on an Unslung NSLU2, connect sip phones, enable voice mail notifications and add some simple demonstrations to the system. The point of this project will to be a launch pad for exploring IP Telephony projects based around Asterisk. So this guide will be limited to a simple installation scenario.

Contents

Overview To The Complete N00b

  • Asterisk is a complete open source software PBX (Private Branch eXchange) sponsored by Digium. It runs on Linux, BSD and MacOSX and provides all of the features you would expect from a PBX and more. It is designed to utilise both the intertubes using a variety VOIP protocols and manage connections to POTS (Plain Old Telephone Service). Asterisk is a project that is highly adaptable/specializable (Asterisk Gateway Interface), low cost (check out how much it costs for an Avaya system), efficient (read the specs on IAX2), easy to setup and use.

Equipment

Our setup is going to be designed to support a more SOHO type environment for here at the Hak.5 studio. Since Asterisk is very capable of being adapted to a lot of machines, the minimum requirements can be quite small compared to the capacity of most machines today. After bringing in a free Linksys NSLU2, Darren proceeded to open up its firmware via Unslung so that a linux machine can be run on an attached storage device, which a usb flash memory stick can be used for this purpose. In the case of a USB memory stick, min 256mb is generally recommended, but at least 512mb is a better option! This device generally has a really good up time and small power consuption. Then seeing that there is a package for Asterisk to be install on we decided to go forward and do a hot-to segment on it. Grandstream200T (its good!) Ive also setup the softphone (ekiga) on my laptop for testing. You can use what are called media gateways which will translate for an analog phone if you want to use one as well.

  • sip phones
  1. "hard phones"
  2. mention gateways
  3. "softphones"
  • nslu2

Installation steps

Install Asterisk

  1. update the package list
    ipkg update
    1. You may want to upgrade any installed packages
      ipkg upgrade
    2. If you do, run
      ipkg update
      again afterwards
  2. get Asterisk
    ipkg install asterisk
  3. get Asterisk Sounds
    ipkg -force-overwrite install asterisk-sounds

"WOW, that was easy. Wait theres more?"

Slim and customize Asterisk

  1. slim it down place to get this
    1. modules.conf
;Modules.conf
[modules]
autoload=yes
noload => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
noload => app_intercom.so
noload => chan_modem.so
noload => chan_modem_aopen.so
noload => chan_modem_bestdata.so
noload => chan_modem_i4l.so
noload => chan_mgcp.so
noload => chan_skinny.so
; require for voicemail
load => res_adsi.so
load => res_musiconhold.so
noload => app_festival.so
noload => app_url.so
noload => app_image.so
noload => app_disa.so
noload => app_qcall.so
noload => app_adsiprog.so
noload => app_ices.so
noload => codec_g726.so
noload => format_vox.so
noload => format_h263.so
noload => format_jpeg.so
noload => cdr_csv.so
noload => cdr_manager.so
noload => app_zapras.so
noload => app_flash.so
noload => app_zapbarge.so
noload => app_zapscan.so
noload => app_talkdetect.so
noload => app_alarmreceiver.so
noload => chan_alsa.so
noload => chan_oss.so

[global]
chan_modem.so=no 
  1. point to the correct directories with asterisk.conf
[directories]
astetcdir => /opt/etc/asterisk
astmoddir => /opt/lib/asterisk/modules
astvarlibdir => /opt/var/lib/asterisk
astagidir => /opt/var/lib/asterisk/agi-bin
astspooldir => /opt/var/spool/asterisk
astrundir => /opt/var/run 
astlogdir => /opt/var/log/asterisk

esmtp

  • #ipkg install esmtp
  • #esmtprc
hostname=smtp.my_outgoing_mail_server.net:25
username=yourusername
password=yourpassword
  • note - the username/password should be the same account as used in the serveremail entry in the voicemail.conf file

Providers

  • list of providers

List of DID providers

we used teliax because Gizmo was not playing nicely
  • what do you get "number, registry statement, authentication statement, pswd, their proxy"
    1. number is the number you're given. Depending on where, you have more choices.
    2. registry statement usually they will give this to you to put in to your sip file
    3. authentication the string that you'll put into sip.conf to qualify with thier system
    4. pswd depends on how thier system works its either the one you use to ign up to the account or its a hash of that pswd
    5. their proxy this is the point of access for your setup too their system

Configurations and its files

  • Asterisk
    1. the files you will use to make your system useful (although it's not very entertaining) sample files very available and well documented
    1. sip.conf
    2. iax.conf (if you want to use that)
    3. extensions.conf most of your time spent here
    4. voicemail.conf this is really easy to do and wont take long so drop you pants and bendover
  • yeah this is a good time to RTFM for things like global variables and includes/macros
  • remember your codec "SNAKE!!"
    1. 140.85 Roy Campbell and Naomi Hunter
    2. 140.96 Mei Ling
    3. 141.80 Master Miller
    4. 140.15 Meryl
    5. 141.12 Otacon
    6. 141.52 Nastasha Romanenko
    7. 140.48 Deepthroat
  • voicemail "eat it"
  • music on hold not today!

Demonstrations

sip.conf a general context is always needed to start this file

[general]
context=default
allowguest=no			; Allow or reject guest calls (default is yes,)

bindport=5060			
bindaddr=0.0.0.0		
srvlookup=yes			

language=en
tos=lowdelay
disallow=all

notifymimetype=text/plain	; Allow overriding of mime type in MWI NOTIFY
checkmwi=10			; Default time between mailbox checks for peers
vmexten=voicemail		; dialplan extension to reach mailbox sets the 
						; Message-Account in the MWI notify message 
						; defaults to "asterisk"
musicclass=default
trustrpid = no
sendrpid = yes
dtmfmode = auto
alwaysauthreject = yes

externip = your external ip address
externrefresh=10
localnet=192.168.1.0/255.255.255.0

nat=yes

rtautoclear=yes			; Auto-Expire friends created on the fly

;register to teliax
register => your_username:your_password@voip-co3.teliax.com

;teliax authentication
auth = your_username:your_password@voip-co3.teliax.com

; Definitions of locally connected SIP phones
;
; type = user	a device that authenticates to us by "from" field to place calls
; type = peer	a device we place calls to or that calls us and we match by host
; type = friend two configurations (peer+user) in one
;
; For local phones, type=friend works most of the time

[teliax-out]
context=hl-incoming
type=friend
username=your_username
user=your_username
host=voip-co3.teliax.com
secret=your_password
insecure=very
qualify=1000
call-limit=2
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm

[demo-phone-1]
type=friend
context=internal
callerid=dudes1 <1234>
host=dynamic
nat=no
canreinvite=yes
dtmfmode=info
call-limit=2
mailbox=1234@hak5.org
disallow=all
allow=ulaw
allow=alaw
allow=gsm
allow=g723.1
allow=g729
host=dynamic

[demo-phone-2]
type=friend
context=internal
callerid=dudes2 <5678>
host=dynamic
nat=no
canreinvite=yes
dtmfmode=info
call-limit=2
mailbox=5678@hak5.org
disallow=all
allow=ulaw
allow=alaw
allow=gsm
allow=g723.1
allow=g729
host=dynamic

a general context is always need to start this file

[general]
static=yes
writeprotect=no
autofallthrough=yes

[globals]
dudes1=SIP/demo-phone-1
dudes2=SIP/demo-phone-2
HLTRUNK=SIP/teliax-out

internal context

[internal]
include => hl-outbound
include => demos

;voicemail extensions
exten => 500,1,VoiceMailMain( )

;sip extensions
exten => 1234,1,Dial(${dudes1},30,r)
exten => 1234,n,Voicemail(u1234)
exten => 5678,1,Dial(${dudes2},30,r)
exten => 5678,n,Voicemail(u5678)
exten => i,1,Playback(jedi-extension-trick)
exten => i,2,Playback(vm-goodbye)
exten => i,3,Hangup( )

some demos for testing

[demos]
exten => 4255,1,Playback(office-iguanas)
exten => 4255,n,Playback(hak5)
exten => 4255,n,Hangup( )

exten => 6000,1,Playback(demo-echotest)		; Let them know what's going on
exten => 6000,n,Echo				; Do the echo test
exten => 6000,n,Playback(demo-echodone)		; Let them know it's over
exten => 6000,n,Goto(6000,1)			; Start over
exten => #,1,Playback(demo-thanks)		; "Thanks for trying the demo"
exten => #,n,Hangup				; Hang them up.
exten => i,1,Playback(jedi-extension-trick)
exten => i,2,Playback(vm-goodbye)
exten => i,3,Hangup( )

Out bound context

[hl-outbound]					;SIP/teliax-out 8003188529
exten => _81XXXXXXXXXX,1,SetCallerID("Hak5" <18003188529>)
exten => _81XXXXXXXXXX,2,Dial(${HLTRUNK}/${EXTEN:2},30,tr)
exten => _81XXXXXXXXXX,n,Congestion(${EXTEN:2})
exten => _81XXXXXXXXXX,n,Congestion(${EXTEN:2})

Home/local context

[hl-incoming]					;this will be what happens when the local line is caled
exten => s,1,Dial(${dudes1}&${dudes2},15,r)	;rings both phones
exten => s,n,Answer( )				;asterisk then answer when no one picks up
exten => s,n,Wait,1
exten => s,n,Background(enter-ext-of-person)	;says "yo, we ain't here man, and no i don't gotcha money"
exten => s,n,WaitExten(30)			;"so hit a one or a two"
exten => _[12],1,Goto(${EXTEN},1)		;_[12] allow for only 1 or 2 as valid number two enter
exten => 1,1,Voicemail(u1234)			;sends you to that person voicemail
exten => 2,1,Voicemail(u5678)			
exten => i,1,Goto(local-ring-group,s,3)		;if an incorrect extension is dialed goes back to playing the greeting
exten => t,1,Hangup( )

Corporate context

[hl-incoming]					;this will be what happens when the 800 line is called
exten => s,1,Answer( )				;asterisk picks up
exten => s,n,Wait,1				;you wait for me!
exten => s,n,Background(enter-ext-of-person)	;plays a welcome message that can be interupted
exten => s,n,WaitExten(120)			;waits to hear an extension
exten => 1234,1,Dial(${dudes1},20,r)		;if entered sends you to ext. 1234
exten => 1234,n,Voicemail(u1234)		;if 1234 does not pick up caller gets sent to voicemail
exten => 5678,1,Dial(${dudes1},20,r)		;if entered sends you to ext. 5678
exten => 5678,n,Voicemail(u5678)		;if 5678 does not pick up caller gets sent to voicemail
exten => 1337,1,Voicemail(u1337)		;used for a general voicemail for a group
exten => 4255,1,Goto(demos,4255,1)		;if entered sends you to ext. 4255 on the demos context
exten => 6000,1,Goto(demos,6000,1)		;if entered sends you to ext. 6000 on the demos context
exten => i,1,Playback(jedi-extension-trick)	;if you press something wrong it will send you this
exten => i,2,Playback(vm-goodbye)		;i said good day sir/ma'am
exten => i,3,Hangup( )				;dumps you because you're lame
exten => t,1,Playback(vm-goodbye)		;when your time is up it says
exten => t,2,Hangup( )				;"My 266MHz proccessor just smoked you!"

Path of segment

  • what asterisk is
  • equipment we used and why
    1. grandstreams
    2. slug
    3. computer (for access)
  • unslung nslu2
  • ipkg asterisk
    1. ipkg install asterisk
    2. ipkg -force-overwrite install asterisk-sounds
  • slimming asterisk
    1. modules.conf
    2. asterisk.conf
  • esmtp
    1. ipkg install esmtp
    2. esmtprc
    • voicemail.conf
  • auto start
  • editing conf files (the meat)
    • sip.conf (mention iax.conf)
    1. general
    2. phones
    3. poviders (teliax)
    4. external line
    • extensions.conf
    1. general
    2. globals and veriables
    3. internal ext.
    4. demo ext.
    5. outgoing ext.
    6. incoming house styl
    7. incoming company style

External links

Unslug Asterisk Wiki

A yahoo group that host slug asterisk sample files

Nslu2-linux Wiki

Reduce the profile of Asterisk

Link to O'Reilly book

O'Reilly's Emerging Telephony Blog

Nerd Vittles' Asterisk Blog