VoIPowering Your Office with Asterisk: SOHO VoIP, Part 2

In part one, we learned how to connect an Asterisk server to legacy phones and phone service. Today we’re going to set up a connection to the outside world and set up internal extensions, so we can actually place and receive calls through Asterisk.

Starting the TDM04B at Boot
We need to finish configuring the TDM04B. Last time, we left off with manually loading the drivers for the TDM04B, just to make sure they would. If there are errors in /etc/zaptel.conf the drivers won’t load. Getting the drivers to load at boot is easy. Go to your Zaptel source tree (see VoIPowering Your Office With Asterisk: Moving to the Grownup Version) and install the startup files:

# cd /usr/src/zaptel-1.2.6
# make config
This takes care of everything. When you reboot the TDM04B will be loaded automatically. In fact it does too much. See for yourself with the lsmod command:
# lsmod
Module Size Used by
ztdummy 3924 0
wcusb 20000 0
wctdm 34880 0
wcfxo 13088 0
^20zaptel21^ 27936 0
wct1xxp 19488 0
^24zaptel25^ 65600 0
tor2 91936 0
zaptel 206852 12
ztdummy,wcusb,wctdm,wcfxo,^31zaptel32^,wct1xxp,^35zaptel36^,tor2
crc_ccitt 2113 1 zaptel
wcusb, ^41zaptel42^, wct1xxp, ^45zaptel46^, and tor2 are unnecessary. (See the README in your Zaptel source directory to learn what all of these are.) Edit /etc/default/zaptel on Debian systems to comment out the unneeded drivers; on Fedora, /etc/sysconfig/zaptel.

Configuring the Server
OK, then, enough messing around with the TDM04B. Time to set up Asterisk to answer and route incoming calls.

The next file to edit is /etc/asterisk/zapata.conf. Start over with an empty file:

# mv zapata.conf zapata.conf.old
# nano zapata.conf

Then enter these lines in it:
[channels]
context=pstn-test
signaling=fxs_ks
language=en
usecallerid=yes
echocancel=yes
transfer=yes
immediate=no
group=1
channel => 1
channel => 2
channel => 3
channel => 4
If you’re trying to make sense of this FXS/FXO stuff, you’re noticing that the TDM04B has four FXO modules, but the configurations specify FXS signaling. Think of it this way: It accepts and translates FXO signaling on incoming calls, but has to transmit FXS signaling, because that’s what the telco expects.

Then create the pstn-test context in /etc/asterisk/extensions.conf. Add this to the sample file:

[pstn-test]
exten => s,1,Dial(SIP/250,30)
exten => s,n,Voice-mail(250)
exten => s,n,Hangup

Make sure that you have “TRUNK=Zap/g1” in extensions.conf.

Adding Users
You probably want incoming calls to actually ring a phone, and possibly even be picked up by a human. There are two steps to setting up a new internal extension; both sip.conf and extensions.conf must be edited.

First, register the user in sip.conf, with the user’s real name and IP. Start over with an empty file, then add these lines:

[general]
port=5060
bindaddr=0.0.0.0
context=default
disallow=all
allow=gsm
allow=ulaw
allow=alaw

[alrac]
type=friend
username=alrac
secret=[alrac’s password]
host=[phone IP]
context=pstn-test

Go ahead and register a couple more users in the same way. Our example users are stan and ollie.

The next step is to register the users’ extensions in extensions.conf. Add these to the pstn-test context:

[pstn-test]
exten => 250,1,Dial(SIP/alrac)
exten => 251,1,Dial(SIP/stan)
exten => 252,1,Dial(SIP/ollie)

;Internal users can call each other directly with their 3-digit extensions:
exten => _2XX,1,Dial(SIP/${EXTEN},30)
exten => _2XX,n,Voice-mail(${EXTEN})
exten => _2XX,n,Hangup


Installing Phones
Every IP phone is configured little differently. These are the main parameters you’ll need, as this example for Alrac shows:

Enable: yes
Username: 250
Authorization User: 250
Password: [alrac’s password]
DomainRealm: [Asterisk server IP]
SIP Proxy: [Asterisk server IP]

The Story So Far
We’re not done yet, but this is a good place to stop and review what we’ve done so far:


  • Installed and configured the TDM04B card for interfacing between the PSTN and our IP phones
  • Created a new context, pstn-test
  • Incoming calls will all be routed to alrac
  • Calls will automatically go to the first available line
  • Registered our users in sip.conf
  • Registered telephone extensions in extensions.conf
  • Setup IP phones and registered them with the server
If you want to play with this a bit, reboot the Asterisk server, then try dialing your new extensions, and placing a call to yourself from an outside line. The final step is setting up outbound dialing.

Outbound Dialing
Receiving calls is nice, but you probably want to call out as well. We’ll get to this in part three, as there are some perils and pitfalls to be avoided. The biggest one: you must define your contexts and call routing carefully or you risk leaving yourself open to providing free long distance to the world.

We’ll also define a better default context and, in part four, we’ll set up a digital assistant so that Alrac doesn’t have to answer everyone’s calls. Digital assistants are very smart and will even screen your calls.

Resources
Asterisk: the Open Source PBX
Voip-Info.org


Adapted from voipplanet.com.





Do you have a comment or question about this article or other small business topics in general? Speak out in the SmallBusinessComputing.com Forums. Join the discussion today!

Must Read

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends, and analysis.