VoIPowering Your Office with Asterisk: SOHO VoIP, Part 2

Last week 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 week 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
wcte11xp               27936  0
wct1xxp                19488  0
wct4xxp                65600  0
tor2                   91936  0
zaptel                206852  12
crc_ccitt               2113  1 zaptel

wcusb, wcte11xp, wct1xxp, wct4xxp, and tor2 are all 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 faffing 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:

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:

exten => s,1,Dial(SIP/250,30)
exten => s,n,Voicemail(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:

secret=[alrac's password]
host=[phone IP]

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:

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,Voicemail(${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 settting up outbound dialing.

Outbound dialing
Receiving calls is nice, but you probably want to call out as well. We’ll get
to this next week, as there are some perils and pitfalls to be avoided. The
biggest one is 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 the following week 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.

Asterisk: the Open Source PBX

Get the Free Newsletter!
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter!
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Latest Articles

Follow Us On Social Media

Explore More