Asterisk
What Asterisk Can Do
● Voice Over IP (VOIP)
● Physical phone switch (PBX) ● Software phone switch
● Answering machine
VOIP
● Voice Over IP: Make telephone calls using the
Internet.
● Cheap (real phone calls) or free (VOIP to VOIP) ● Commercial/Semi-Commercial services like
Skype, Vonage.
● Like compressing a CD to MP3 files, the goal is
to make the voice data as small as possible without losing quality.
VOIP and Asterisk
● Asterisk supports several VOIP speech
compression codecs.
● Will not work with commercial VOIP solutions
like Vonage or Skype (different networks)
● Asterisk can route VOIP calls:
– Over the Internet to other Asterisk users
– Over the Internet to VOIP gateway providers
– Into the real phone network, if you have the right
● POTS – Plain Old Telephone System.
● Requires special hardware: FXS and FXO.
● FXS emulates the “phone system.” You can plug
a normal phone into a FXS adapter.
● FXO emulates a “phone device.” You can plug a
PC into the POTS network with a FXO adapter.
● High-end 'T' line interface hardware. Similar to
FXO but can trunk dozens of lines over a T1
Talking To Asterisk
● VOIP or “real” phone, you need a way to talk to
Asterisk.
● Analog phone to VOIP adapters: Ethernet on one
side, telephone jack on the other, lets you use any existing phone. Usually talk SIP protocol.
● FXS: Acts like a sound card in your Asterisk
server, lets you use any existing phone.
● Hardware VOIP phone: Looks like a real phone,
but talks SIP to Ethernet.
Installing Asterisk
● Download Asterisk from http://www.asterisk.org/
or look in your distribution for a package.
● Extract the source, compile, and install the
compiled code. Asterisk doesn't use the standard autoconfig tools, so a “./configure” is not needed.
tar xvf asterisk1.0.9.tar.gz make
Asterisk Configuration Files
● System configurations live in /etc/asterisk.
There are a lot of them. The most important ones are:
● sip.conf: controls SIP VOIP users.
● iax.conf: controls IAX VOIP connections.
● extensions.conf: controls phone numbers and call trees, both incoming and outgoing calls.
● voicemail.conf: controls voice mail boxes, passwords, etc.
Configuring Asterisk For SIP
● Most VOIP stuff uses SIP (software phones,
hardware adapters, etc)
● Needs a SIP configuration entry in sip.conf for
each SIP device.
● SIP entry defines type, extension context, name,
password, voicemail mailbox, and audio codecs allowed.
Example SIP User
[dragorngrandstream] type=friend context=nycccp username=dragorngrandstream fromuser=dragorngrandstream secret=monkey callerid=Dragorn <1020> host=dynamic nat=no canreinvite=yes dtmfmode=info mailbox=1020@default disallow=all allow=ulawThings To Know About SIP
● Extremely basic protocol.
● Stream of UDP packets containing voice data. ● CAN pass through NAT, but doesn't do so very
well in all situations.
● Container around multiple audio codecs: ulaw,
alaw, gsm, and more.
● Different codecs have different speech quality.
SIP Devices
● Assorted software phones: kphone, linphone,
mythphone, gnophone to name a few. Look on http://www.freshmeat.net
● Hardware phones: Budgetone is cheap & decent ● Standalone FXS to SIP adapters
Asterisk Extensions Configuration
● Very complex file, but important for operation. ● Boring part of the presentation, but controls all
the neat things Asterisk can do.
● Config is divided into segments, aka calling
domains.
● Each extension can perform multiple actions:
– Dialing another extension – Playing background audio
* Extensions: Outbound Dialing
● Wildcard extension matches “outbound” numbers
(1-XXX-XXX-XXXX)
● Set our caller ID to 1-800-555-1212 (hah!)
● Direct it to the external provider via the IAX2
protocol (Asterisk to Asterisk protocol, supported by our example outbound dialing provider, and configured in iax.conf)
exten => _1NXXNXXXXXX,1,SetCallerID(8005551212) exten => _1NXXNXXXXXX,2,Dial,IAX2/foo/${EXTEN}
* Extensions: Local Phones
● Define a macro which calls the SIP address of the
specified phone, waits a maximum of 20 seconds, and then directs the call based on the status.
● Set an extension in our local phone domain and
link it to the SIP phone.
[macrosipexten]
exten => s,1,Dial(SIP/${ARG1},20)
* Extensions: Calling Trees
● Include local phone domains. ● Set up background speech.
● Script the call tree and fall through to calling
local users if nothing else is entered.
[nycccpincoming] include => nycccp_phones include => nycccpvmdefaults exten => s,1,Background(nycccpintro) exten => 2,1,Goto(nycccpdepartments,s,1) exten => 3,1,Goto(nycccporginizations,s,1) exten => 4,1,Goto(nycccppeople,s,1) exten => 11,1,Goto(nycccptoolkit,s,1) exten => 2,1,Dial(SIP/dragorngrandstream&SIP/porkchop,10t)
* Extensions: CID Spoofing
● CID spoofing is trivial, depending on your VOIP
outbound provider.
● Match #*# and set the CID to the first number. ● Your provider may get unhappy with you doing
this a lot!
exten => _1NXXNXXXXXX*NXXNXXXXXX,1, SetCallerID(${EXTEN:10})
Voicemail
● Builtin voicemail system.
● Per-extension mailbox and passwords.
● Incoming messages recorded as wav, mp3.
● Remotely checkable if you add the voicemail
system to your dialable extensions.
Voice Synthesis
● Asterisk can use realtime voice synthesis via
Festival.
● Unfortunately, Festival sucks to compile and
install the extra voices.
● Voice quality is passable but not great. Often
better to record your own messages.
IAX, Asterisk Protocol
● Two Asterisk installations can communicate
directly with each other.
● Multiple phone switches in one location can share
the load.
● Direct connections between your house and
others via the Internet: Free calls to your friends!
● Some clients talk IAX directly (gnophone). ● More robust than SIP but less widespread.
Going From VOIP To World
● Free World Dialup provides Free (imagine that)
numbers to reach other FWD members. http://www.freeworldialup.com
● VoipJet provides outbound connections to the
real phone network at very cheap rates
($0.001/min inside the US and $0.03/min average international). http://voipjet.com
● Stanaphone provides NY inbound phone
VoipJet Is Weird
● The first rule about VoipJet is you do not talk
about VoipJet.
● In many ways they seem very sketchy. EULA
prohibits talking about using them or disclosing that you use them.
● Service is still good and you can pay via PayPal. ● Weirdness is probably to avoid being taxed as a
Business-Level Asterisk
● T1 interface card.
● Use Asterisk as a real phone PBX to trunk
multiple extensions to the T1 line.
● VOIP to the desk, or FXS to standard phones. ● Much cheaper to run than a commercial PBX
system.
● Uses the ZapTel kernel modules to drive analog
Tricks With Asterisk + POTS
● Using a FXO card, connects to your home
telephone jack.
● Route incoming calls to a call tree. Amaze your
friends, annoy the telemarketers.
● Route outgoing calls over phone or VOIP
depending on area code to save money.
● Digital answering machine. MP3s of your
VOIP Legalisms
● Commercial VOIP providers are likely to be
treated as telecom providers (= taxes!)
● FCC/Feds are planning to require VOIP providers
make it wiretappable. (= spying!)
● 911 support becoming a major issue. How does
the 911 system know where you are?
● None of this applies to you at home building your
Stuff To Worry About
● If your only phone is VOIP (Asterisk or
commercial), what happens if your power goes out or your Internet link goes down?
● VOIP is really too high bandwidth for dialup.
Broadband of some sort is necessary.
● VOIP is sniffable. It's not legal, but that won't
stop it. Your phone is also tappable. Take your pick.
VOIP Quality
● VOIP speech quality is directly affected by the
available bandwidth. Stuttering and dropouts will happen if your line isn't fast enough.
● Packet shaping can help if your line is congested
by uploads and downloads.
● If you use Linux for packet shaping, a “PFIFO
Queue” is most appropriate: The short packet queue prevents VOIP data from backing up causing stuttering.
Asterisk Config Helpers
● http://www.freshmeat.net has links to many
Asterisk frontends and utilities
● LiveCD distros and specific modified distro
installs such as Xorcom
● Several PHP configuration and billing frontends ● http://www.asternic.com has live diagnostics and
Outro
● Asterisk: http://www.asterisk.org
● Incoming: http://www.stanaphone.com ● Outgoing: http://www.voipjet.com
● Info & Wiki: http://www.voip-info.org
● More Software: http://www.freshmeat.net ● Us: http://www.mhvlug.org