Asterikast Episode 4 <4 4 4 4> (suppose to sound like an echo .5 Talk about the new website and sponsorship sexiness and why you will be cool if you sponsor asterikast 1. Installing asterisk 1.4 on a fresh Slackware 12.0 install Download libpri Download zaptel Download speex Download iksemel http://iksemel.googlecode.com/files/iksemel-1.3.tar.gz Download Asterisk Download Asterisk-addons Uncompress libpri ./configure make make install uncompress zaptel ./configure make menuselect <- explain the new menuselect option make make install uncompress speex ./configure --prefix=/usr make make install uncompress iksemel ./configure --prefix=/usr make make install uncompress asterisk Edit Makefile change /var/run to /var/run/asterisk ./configure make menuconfig <- Show options in menuconfig make make install make samples uncompress asterisk-addons ./configure make menuconfig <- no h323 compile here everything else though make make install 2. Installing the free g729 codec from asterikast download the codec http://asterikast.com/downloadclicks.php?url=http://www.asterikast.com/_downloads/codecs_slackware.zip&name=Asterisk%20g729/g723%20codec%20for%20asterisk%201.4%20Slackware%20Edition&ver=1.0 unzip and install into /usr/lib/asterisk/modules 3. Changing the permissions of asterisk so it does not need to run as root (important) Add asterisk user groupadd asterisk useradd -s /bin/false -g asterisk asterisk chown -R asterisk:asterisk /etc/asterisk chown -R asterisk:asterisk /dev/zap chown -R asterisk:asterisk /usr/lib/asterisk chown -R asterisk:asterisk /etc/zaptel.conf chown -R asterisk:asterisk /var/lib/asterisk chown -R asterisk:asterisk /var/run/asterisk 4. Modify /usr/sbin/safe_asterisk change Priority if desired max is -20 Start asterisk: safe_asterisk -U asterisk -G asterisk (must start as root) asterisk -r to verify 5. Connect your sip phone to asterisk edit the sip.conf (take out the crap) [general] Setup default context Setup allowguest disallow codecs allow codecs <- Explain that order matters dtmfmode (explain the differences sip info, rfc2833, inband, auto) nat settings (explain) canreinvite (explain) [new_user] type=friend context=context_for_incoming_calls disallow=all <- if so desired for this phone allow=g729 <-if so desired host=dynamic <- or static username=new_user secret=new_user_password canreinvite=no [new_sip_peer] type=peer disallow=all <- if desired allow=ulaw host=xxx.xxx.xxx.xxx context=context_for_incoming_calls dtmfmode=inband 6. Writing a simple extensions.conf edit /etc/asterisk/extensions.conf delete all except: [general] static=yes writeprotect=no clearglobalvars=no [globals] CONSOLE=Console/dsp [local] include=>default [default] include=>demo [demo] exten => _600,1,answer exten => _600,2,wait(1) exten => _600,3,playback(tt-weasels) exten => _600,4,hangup() at this point edit your sip phone config change the line under new_user context=context_for_incoming_calls to context=default type: asterisk -r you will now be presented with the asterisk cli interface type reload 7. Configure the phone ... 8. Place a call to 600 from the sip phone it will answer locally and say "Weasels have eaten our phone system" Congratulations you have made your first Asterisk Telephone call 9. Writing an External Asterisk config dial plan to keep orginization [local] include=>default #include outbound.conf [default] include=>demo include=>outbound save the file edit /etc/asterisk/outbound.conf [outbound] exten => _XXXXXXX,1,DIAL(SIP/new_sip_peer/${EXTEN}|20) ;try the call for 20 seconds exten => _XXXXXXX,2,congestion() ; play back a fast busy exten => _1XXXXXXXXXX,1,(SIP/new_sip_peer/${EXTEN}|20) ;try the call for 20 seconds exten => _1XXXXXXXXXX,2,congestions ; play back a fast busy if new_sip_peer is actually a peer then you will now be able to make local and long distance calls 10. Using a DID or extension to accept an incoming call. [local] include=>default #include outbound.conf #include did.conf [default] include=>demo include=>did ;all incoming did's include=>outbound ; are outbound dial plan edit /etc/asterisk/did.conf Lets say we have the did 9999999999 [did] exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user|20) save the file then asterisk -r reload 11. This is all fine and dandy but lets add voicemail edit /etc/asterisk/voicemail.conf find the [default] context add your mailbox number in my example use 9999999999 => 1234,John,john@asterikast.com,,tz=central|saycid=yes|dialout=outbound edit /etc/asterisk/did.conf find the context [did] edit: exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user|20) Add: exten => _9999999999,3,voicemail({$EXTEN},u) <- Plays the unavalible message So the whole thing looks like: exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user|20) exten => _9999999999,3,voicemail({$EXTEN},u) <- Plays the unavalible message Your users can now leave you voicemail after an asterisk -rx reload 12. Checking your voicemail This is done by adding a new dialplan. I simply just add this to the main extensions.conf [local] include=>default #include outbound.conf #include did.conf [default] include=>demo include=>did ;all incoming did's include=>voicemail ; add the voicemail context include=>outbound ; are outbound dial plan [voicemail] exten => 500,1,answer exten => 500,2,wait(.5) exten => 500,3,voicemailmain() ; this will prompt for the mailbox and password or if you know you want to check your 9999999999 then [voicemail] exten => 500,1,answer exten => 500,2,wait(.5) exten => 500,3,voicemailmain(9999999999) ; this will prompt for the password Finally if you trust everyone and don't want a password or anything you will do the following: [voicemail] exten => 500,1,answer exten => 500,2,wait(.5) exten => 500,3,voicemailmain(9999999999,s) ; this will prompt for nothing and drop you into the mailbox 13. You now have a simple working asterisk system. Lets integrate with Google Talk (gtalk) then simultaneous ring gtalk and your sipphone for when your on the road. You must signup for a new gtalk account: http://www.google.com/talk/ You can just signup online using online gtalk. since we installed iksemel and used gnutls we will be able to just have jabberwork (jabber is the underlying protocol for gtalk) we'll pretend I signedup john@gmail.com edit /etc/asterisk/jabber.conf [general] debug=no autoprune=yes autoregister=yes [asterisk] type=client serverhost=talk.google.com username=john@gmail.com/Talk secret=johnssupersecretpassword port=5222 usetls=yes usesasl=yes statusmessage="Asterikast RULES!!!" timeout=100 Now edit /etc/asterisk/gtalk.conf [general] context=default allowguest=yes ;bindaddr=xxx.xxx.xxx.xxx ;optional is you have one way audio put the address of your external interface [guest] disallow=all allow=speex ;Ulaw and speex are avalible we choose speex for bandwidth savings context=guest ;this context must exsist edit /etc/asterisk/extensions.conf make a new context called [guest] here is an example [guest] exten => s,1,answer exten => s,2,DIAL(SIP/new_user|20) exten => s,3,voicemail(9999999999,u) When someone calls your new gtalk account it will ring your sip phone YEAH! Now we also want to ring gtalk when someone calls 9999999999 edit did.conf [did] exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user>alk/asterisk/otherusername@gmail.com|20) exten => _9999999999,3,voicemail({$EXTEN},u) The calls will now ring your sip phone and your other gtalk account via your new gtalk account in my example john will ring otherusername@gmail.com it is important that you add john@gmail.com to otherusername@gmail.com otherwise the call will be rejected via jabber because your not on the users buddy list. You will notice one thing that sucks about gtalk is that it does not set a callerid of the person calling you. We wrote a little perl hack to fix this: #!/usr/bin/perl use Asterisk::AGI; $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); $channel = $ARGV[0]; @channelsplit = split(/Gtalk\//,$channel,2); #print "$channelsplit[1]\r\n"; $channel = $channelsplit[1]; $channel =~ /.*-(.*)/; $remove = "-".$+; #print "$remove\r\n"; $channel =~ s/$remove//; @channelsplit = split($remove,$channel); #print "$channelsplit[0]\r\n"; #print "$channel\r\n"; $AGI->set_variable('gtalk_name',$channel); save file as getName.pl in /var/lib/asterisk/agi-bin/ this has worked in everytest that I have tried however it may be a bit buggy it sets gtalk_name as the variable We will show you how to do agi in a minute 14. AGI installing perl agi http://asterisk.gnuinter.net/files/asterisk-perl-0.10.tar.gz uncompress perl Makefile.PL make make install perl agi is now installed. now from the previous example we can set the callerid on your sipphone to be a gtalk buddy edit extensions.conf [guest] exten => s,1,answer exten => s,2,agi,getName.pl|${CHANNEL} ;channel is a built in variable exten => s,3,(CALLERID(all)=GTALK <${gtalk_name}>) exten => s,4,DIAL(SIP/new_user|20) exten => s,5,voicemail(9999999999,u) this will display the callerid name GTALK and the buddy name as the phone number. 15. Creating a conference a simple conference can be created by editing meetme.conf /etc/asterisk/meetme.conf add a new conference by adding the line conf=>1234 ; optionally you can add a pin number and an adminpin, adminpins allow you to admin the conference via the phone to use an adminpin but not a conference pin conf=>1234,,12345 ;so when logging into the conference enter 1234 as the conference number and enter 12345 as the admin pin Add the conference to extensions.conf [local] include=>default #include outbound.conf #include did.conf [default] include => demo include => did ;all incoming did's include => voicemail ; add the voicemail context include => conference ;add the conference extension to any one allowed at default include => outbound ; are outbound dial plan [conference] exten => 100,1,meetme() ; this will ask for the conference id [conference] exten => 100,1,meetme(1234) ; this will ask for the admin pin (or pin) is specified [conference] exten => 100,1,meetme(1234,ocMspI) exten => 100,2,hangup this will ask for the moderator pin and start the conference o = talker optimization treats all who are not speaking as muted c = Announce the conference count on connection M = Enable music when you are the only person in the conference s = Present the menu when * is pressed p = Allow pound to exit the conference I = Have the user record there name and then enter the conference. 16. Pointing a new did at your conference So you already have in your did.conf [did] exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user>alk/asterisk/otherusername@gmail.com|20) exten => _9999999999,3,voicemail({$EXTEN},u) below all of this lets say your new did is 9999999998 exten => _9999999998,1,answer exten => _9999999998,2,wait(.5) exten => _9999999998,3,goto(conference,100,1) ; this will send you to the precreated conference so your full did.conf will look like: [did] exten => _9999999999,1,answer exten => _9999999999,2,dial(SIP/new_user>alk/asterisk/otherusername@gmail.com|20) exten => _9999999999,3,voicemail({$EXTEN},u) exten => _9999999998,1,answer exten => _9999999998,2,wait(.5) exten => _9999999998,3,goto(conference,100,1) ; this will send you to the precreated conference