My Asterisk Config (a work in progress)

Asterisk Installation Guides | Communications

If you don't have time to learn it proper
1) download Xorcom Rapid from http://xorcom.com/rapid/

OR

1) download and compile from source if you want all the newest nifty features... http://www.ctunion.com/node/106

a) install extra sounds, free play music on hold, improved music on hold. sqlite cdr logging

b) set verbosity level to 10

c) enable sip and iax extensions

d) note ip-address down and change if necessary

e) update software inventory (apt-get update)

f) upgrade software

g) major software upgrade

h) change root password

i) change host name

j) ping yahoo.com

2) after its installed, add the full debian apt source back in (the xorcom apt source severly limits your access to the full package list)

nano /etc/apt/sources.list

##add the following lines into this file
deb http://http.us.debian.org/debian stable main contrib non-free
##added

3) install some necessary apps

apt-get update
apt-get install ftp smbfs ntpdate vsftpd unp bzip2 kernel-source-2.6.8
base-config (set the time zone up properly)
ntpdate 0.pool.ntp.org (sync the time with the internet)

4) base-config
a) set time zone

b) ntpdate pool.ntp.org

c) restart asterisk server for new time to take effect
/etc/init.d/asterisk stop
/etc/init.d/asterisk start

d) edit the config so the time extension is enabled and call it to read you the time. with out this being proper, all your voicemail will seem to be left at strange hours..

nano /etc/asterisk/extensions.d/default.conf

##Add This line to the above file
include => tests
##======

call exten 220 to verify the time reads correctly.

5) set up the email so the notifications will get emailed.
dpkg-reconfigure exim4-config

set the mail server settings to use SNTP.

now tail the maillog and then leave your self a voicemail to see if it tries to mail it to you.
tail -f /var/log/exim4/mainlog

6) edit the global dialplan settings such that Zap/1 is Zap/g1
with out this change, only one call will be made at once.

7) nano /etc/asterisk/extensions.d/trunk-9.conf
;THE DIAL PLAN WORKS BETTER WITH THE POLYCOM PHONES; ALLOWS THE CALL LISTS TO WORK

[trunk-9]

;exten=>_9.,1,Macro(dialout,${TRUNK},${EXTEN:1})
exten=>_###,1,Dial(${EXTEN}, 20, tr)
exten=>_NXXXXXX,1,Macro(dialout,${TRUNK},${EXTEN:0})
exten=>_NXXNXXXXXX,1,Macro(dialout,${TRUNK},${EXTEN:0})
exten=>_1NXXNXXXXXX,1,Macro(dialout,${TRUNK},${EXTEN:0})

8) nano /etc/asterisk/extensions-phones.d/501.conf (the default settings from XORCOM dont allow message waiting lights to work for example..I also had problems connecting to the server from behind a fire wall.... reformatting the file fixed all these problems...

username=501
context=internal
type=friend
secret=501
qualify=no
port=5060
pickupgroup=
nat=yes (if you behind a firewall and asterisk box isn't otherwise say no)
mailbox=501
host=dynamic
dtmfmode=rfc2833
canreinvite=no
callgroup=
callerid="J. Hansen"

9) nano /etc/asterisk/extensions.d
rename
[macro-stdexten] => [macro-stdexten-old]

paste (this slightly modified program allows the messages key to work for the polycom phones.
[macro-stdexten]
;
; Standard extension macro:
; ${ARG1} - Device(s) to ring
; ${ARG2} - flags for Dial: if empty: tr. pass '-' for no flags.
; ${ARG3} - voicemail box. If empty: use the extension number.
exten => s,1,SetVar(VMBOX=${MACRO_EXTEN}); default for VMBOX, if no ARG3
exten => s,2,GotoIf(${ARG3} = ${CALLERIDNUM}?10)
exten => s,3,GotoIf($[${LEN(${ARG3})} > 0]?5)
exten => s,4,SetVar(VMBOX=${ARG3})
; Ring the interface, 20 seconds maximum
exten => s,5,SetVar(FLAGS=tr)
; why 'x'? see bourne shell 101
exten => s,6,GotoIf($[ "x${ARG2}" : x- ]:8); '-' as the 'flags' argument
exten => s,7,SetVar(FLAGS=${ARG2})
exten => s,8,Dial(${ARG1},20,${ARG2})
; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s,9,Goto(s-${DIALSTATUS},1)
exten => s,10,Wait(1)
exten => s,11,VoiceMailMain(s${CALLERIDNUM})

; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,1,Voicemail(u${VMBOX})
; If they press #, return to start
exten => s-NOANSWER,2,Goto(default,s,1)

; If busy, send to voicemail w/ busy announce
exten => s-BUSY,1,Voicemail(b${VMBOX})
; If they press #, return to start
exten => s-BUSY,2,Goto(default,s,1)

; Treat anything
exten => _s-.,1,Goto(s-NOANSWER,1)

;
; You may want to improve this one
;
;This script has been improved to allow the messages light to go to voicemail with one touch.
;make sure the one touch voicemail option is enabled in the phone menu.

10) we need to create a script to restart asterisk every night as it seems that sometimes asterisk will have little problems cropping up if we leave it running for an extended period of time. this example script will stop asterisk, stop the wan router (used in the sangoma hardware) restart the wanrouter, run ztcfg -vvv (a necessary step after wanrouter has been started) and then restart a fresh copy of asterisk, it writes all this too a log file under /var/log/asterisk/asterisk_restart.log

the specific reason i added this is because the wanpipe seem to have a problem releasing zap channels, after some heavy useage, the zap channel will show in use even when no calls are running. this will stop asterisk from using this channel, when all the channels are used up, guess what no calls can be made, users start getting mad. This will free up the channels every night...

nano /root/scripts/asterisk_restart.sh

#--------------------START------------------------------------------
date >> /var/log/asterisk/asterisk_restart.log
asterisk -rx "stop now" >> /var/log/asterisk/asterisk_restart.log
sleep 1s >> /var/log/asterisk/asterisk_restart.log
wanrouter restart >> /var/log/asterisk/asterisk_restart.log
sleep 1s >> /var/log/asterisk/asterisk_restart.log
ztcfg -vvvv >> /var/log/asterisk/asterisk_restart.log
sleep 1s >> /var/log/asterisk/asterisk_restart.log
asterisk >> /var/log/asterisk/asterisk_restart.log
#--------------------END-------------------------------------------


Now add a cron tab

crontab -e
25 23 * * * root /root/scripts/asterisk_restart.sh

This will run the restart script every night at about 11:25PM (just before midnight) and write the output to the log file...

EASIER FREE MUSIC ON HOLD

To get some great music on hold free, with no logon or registration visit:

http://www.signate.com/moh.php