configuring Wildcard TDM400P

In this tutorial we will give you an example which includes one FXO and one FXS station interfaces. TDM400P card with such modules is called TDM11B. Below you will find description of the name model used by Digium.

The Wildcard TDM11B is a half-length PCI card that supports FXO and FXS interfaces for connecting analogue or ADSI telephones and regular POTS through a computer. TDM11B card is from the TDM400p family. This card can be extended with additional FXO or FXS modules (maximum 4 modules per card).
Can we find what modules are plugged in the card just from the name? Yes, the name is divided in several parts: TDM X Y B. X – shows how many FXS modules are in the card, Y – is the number FXO modules. So TDM11B – has one FXS module, and one FXO module

1.PREREQUISITES

 
To install such Wildcard we assume that you already have installed Asterisk PBX on the PC you would like to install the TDM card.
For the hardware requirements you need minimum 500Mhz Pentium III or better with 64 MB.

2.INSTALLATION

 
Find empty PCI slot
Have a look at the card before placing it in the PCI slot. Find empty PCI slot and plug the card there, next you have to plug power cable in the card. There is a red and a green module on it:

Green Module is FXS – Foreign Exchange Station
Red Module is FXO – Foreign Exchange Office


An FXS device initiates and sends signals to an FXO device. The telephone that receives the calls is the last FXO device (if you have several FXO devices) and when the signal is received from the FXS device the telephone has to ring.

Plug the cables
To connect the device to your network – connect the FXO port to the outside lines and local PSTN phone to the FXS port. The FXO uses FXS signalling and the FXS device uses FXO signalling.

When you have everything connected, turn on the Asterisk PBX PC and configure the device there.

Did your OS recognize the card
By typing ‘lspci’ you will receive a list of all the PCI devices you have. Note that Digium cards are recognized under different name:

Communication controller: Xilinx Corporation: Unknown device 0314 (rev 01) for the TE410p / TE405p
Communication controller: Tiger Jet Network Inc. Tiger3XX Modem/ISDN interface / Network controller: Tiger Jet Network Inc. Tiger3XX Modem/ISDN interface for the TE110p or the TDM400p
Network controller: Jens Scoenfeld for the TE110p or the TDM400p

Zaptel installation
If you have not install the zaptel on your asterisk you have to do it now. The PSTN calls on asterisk are passing through Zap channel. For zaptel you need to install the zlib1g-dev module.

apt-get install zlib1g-dev

Now in order to compile it

cd /usr/src/asterisk/zaptel
make linux26
make install

And then recompile the Asterisk

cd /usr/src/asterisk/asterisk
make
make install

3.CONFIGURATION

 
In order to make calls you have to register users and extensions (respectively in iax.conf and extensions.conf) and to adjust the zaptel protocol settings in /etc/zaptel.conf and /etc/asterisk/zapata.conf .

configuring zaptel.conf
In zaptel.conf it is enough to set the type of signalling for FXO and FXS. As we mentioned above FXO uses fxs signalling and FXS uses fxo signalling. For FXO devices you can use one of the following signalling methods.

fxsls : Channel(s) are signalled using FXS Loopstart protocol
fxsgs : Channel(s) are signalled using FXS Groundstart protocol
fxsks : Channel(s) are signalled using FXS Koolstart protocol

And for FXS one of the types standing below

fxols : Channel(s) are signalled using FXO Loopstart protocol
fxogs : Channel(s) are signalled using FXO Groundstart protocol
fxoks : Channel(s) are signalled using FXO Koolstart protocol

Here is my simple configuration

Note that fxoks=1 means that the FXO Koolstart protocol signalling used for the first device which has to be FXS. So have in mind the order of the devices on the TDM card when you register the signalling for each one.

With loadzone and defaultzone you can define the tone zone which to be loaded where the zone is a two-letter country code.

configuring zapata.conf
In zapata.conf some channel configurations are to be made. As I have just two devices, an FXS and an FXO, so I will have just two channels. Here is how I configured my zapata.conf.

As you see there some ‘global’ settings above – they take effect for each channel defined.

Context is the extensions context where the channels will be used (if omitted the default context will be used)
Usecalledid is for using or not called id (may be omitted)
Hidecalledid is whether or not to hide the caller id (may be omitted)
Immediate specifies whether a channel should be answered immediately or not

Signaling is the signalling defined in /etc/zaptel.conf. Just add an underscore before the protocol type (signaling = fxo_ks)
Echocancelation is used for enabling echo cancellation. The valid values are: ‘yes’, ‘no’ or a power of two from 32 to 256.
Group is used for device logically the outgoing calls. Groups can be defined from 0 to 63 as well as multiple groups can be specified.
Channel is channel number for each channel.

User registration
I also have a user registered in iax.conf, but you can also place calls without any user registered from CLI (see the dial command).

Register extensions
And the last step is to register valid numbers in extensions.conf.

Here when you enter the standard extension an operator picks up, the variables concerning the caller is displayed in the CLI – the name of the caller, the number of the caller and the id of the caller, then some welcome message is played. After this you can leave a mail on the voicemail and then the operator hangs you up. You can register a voicemail in /etc/asterisk/voicemail.conf by writing the example below. Here you can learn more about voicemail.

[vm-test]

voicemail context is created

1111 => 123,gogh,gogh@some_domain.com

1111 mailbox is created with password 123 and assigned to user named gogh with email gogh@some_domain.com to notify the user when new message is received.

When you dial some extension like 0ZXXXXX (where ‘Z’ is number from 1-9 and ‘X’ is number from 0-9) you are send to a Macro which places a zero in front of the number and dials the new number. The reason to have additional zero in the beginning of the number is that all outgoing calls for my server must have a zero in front.

exten => s,2,Dial(Zap/2/0{$ARG})

this dials the number you want through Zap on channel 2. As you saw above in my case channel 2 is FXO channel with fxsks signalling and this channel is for outgoing calls.

I have also created a conference room. By dialling 9090 you can enter in it. Conference room can be defined in /etc/asterisk/meetme.conf. Here is a simple example:

[rooms]
conf => 9090[,pin][,adminpin]

This creates conference room with number 9090, without authorization when entering.

By dialling 1001 you call to the user we registered on asterisk PC.

Extensions 1111 and 2222 dial some mobile phones – in the first case through group 2 Dial(Zap/g2/…) and in the second through channel 2 Dial(Zap/2). In the example here channel 2 and group 2 are the same and they use the FXO channel, i.e. outgoing calls.

Extension 3333 dials channel one on Zap.

exten => 3333,1,Dial(Zap/1)

This dials channel 1 which is controlled by FXS. As we said in the beginning the local analogue line is connected to this place, so your local PSTN phone will be dialled.

4.TECHNICAL DATA*

 
Target Application:

– Small Office Home Office (SOHO) applications
– Gateway termination to analogue telephones
– Add inexpensive analogue phones to existing PBX
– Wireless point-to-point applications between Asterisk servers

Services and features:

– CallerID and Call Waiting CallerID
– ADSI phones
– PCI half-length slot
– RJ-11C connector

Environment conditions:

– Operation range: 0º to 50º C, 32º to 122º F
– Storage range: -20º to 65º C, 4º to 149º F
– Huminidity: 10-90% non-condensing

Standard Configuration

 

* –Official Information from Digium for Wildcard TDM400P Family

How To Configure Asterisk: A Typical Home Asterisk PBX Setup

How To Configure Asterisk: A Typical Home Asterisk PBX Setup

Now that Asterisk has gone mainstream, more and more Asterisk installations are happening in home environments.

Asterisk is perfect to power a residential phone system, as the cost of entry is now very obtainable, unlike in years past. In fact, you can even run Asterisk on a Linksys WRT54G, along with many many other Linux based embedded devices, allowing for even lower cost of entry and very low power consumption.

In this article, we are going to build a simple, but effective phone system composed of a Digium Analog Telephony Device and Voicemail. We are going to build upon the asterisk configuration from the first installment in this series.

Configuring Zaptel

Download and compile the latest version of Zaptel from the Digium FTP site.

voip:/usr/src# wget ftp://ftp.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
voip:/usr/src# ./configure && make install

We are using the TDM11B, which is 1 FXS and 1 FXO. This provides us with the ability to connect to a regular telephone line (PSTN) and provide dialtone to your existing house wiring.

The Zaptel configuration file is /etc/zaptel.conf.

The first two directives within zaptel.conf are loadzone and defaultzone. You will need to load the appropriate zone for the country you live in.

Available zones are:

* at
* au
* br
* cl
* es
* fi
* fr
* gr
* it
* jp
* mx
* nl
* no
* nz
* pl
* tw
* uk
* us
* us-old
* za

The last two directives in the zaptel file are:

fxoks=1
fxsks=4

These tell Asterisk to use the appropriate signaling for the two Zaptel telephony interface modules we have on the Digium Card.

Note: Digium has a very specific policy on where they plug in the modules for new hardware. Your channel numbers may be different, depending on where the modules are plugged in. You can determine the channel number and the type of signaling needed by examining the PCI card.

The channel numbers (1-4) start from on side of the card where the telephone cables connect. The green colored modules are Station or FXS interfaces, which need ‘fxoks’ signaling. The red colored modules are Line or FXO interfaces, which need fxsks signaling.

The entire zaptel.conf file:

loadzone=us
defaultzone=us
fxoks=1
fxsks=4

Zapata Configuration

The Zapata Channel driver configuration file is /etc/asterisk/zapata.conf

[channels]
context=users
signaling=fxo_ks
channel => 1
context=from-pstn
signaling=fxs_ks
channel => 4

Calls from Zaptel channel 1 go to the ‘users’ context and use ‘fxo_ks’ signaling. Calls from Zaptel channel 4 go to the ‘from-pstn’ context and use ‘fxs_ks’.

Notice that we set the context and signaling directives prior to setting the channel. This configuration method allows for very fine grain control over your phone system. Once a value is set, it stays set until you reset the configuration directive. While this fact is not apparent here, once you get into more advanced configurations it will become apparent and appreciated.
Voicemail Configuration

Asterisk’s Comedian Mail application tries to mimic Meridian mail, a popular voicemail platform created by Nortel. However, in my opinion Asterisk’s implementation is more flexible and powerful.

The Voicemail configuration file is /etc/asterisk/voicemail.conf.

[general]
format=wav
attach=yes
skipms=3000
maxsilence=6
silencethreshold=128
maxlogins=3
pbxskip=yes
serveremail=[valid from address required]
fromstring=Voicemail
emailsubject=New Voicemail message ${VM_MSGNUM}
emailbody=A ${VM_DUR} long message from ${VM_CALLERID}, on ${VM_DATE}
emaildateformat=%A, %d %B %Y at %H:%M:%S

Here we are informing Asterisk that we wish to record the files using the WAV formats. We are attaching the recording to the notification email. skipms is how many milliseconds we skip when a rewind or fast-forward is requested (by pressing * or # while a voicemail message is playing). maxsilence is how many seconds of silence we allow before hanging up the call. silencethreshold is the threshold value used to assist in detecting silence. 128 is a sane default value. If you are in a high background noise environment you may want to try 256 if you experience trouble with silence detection.

maxlogins allows you to control how many failed login attempts before hanging up. pbxsip=yes drops the [PBX] prefix on the notification email. A valid serveremail or from email address is required. fromstring is the name portion of the From email header.

emailsubject, emailbody and emaildateformat allow you to completely customize the exact content of the notification email. You can see the full details in voicemail.conf.sample, which is in the configs directory of the Asterisk source tree.

[default]
100 => 1234,Mark Spencer,valid@email.address.com

We define the default voicemail context. 100 is the mailbox number and 1234 is the password. Next, we define a name for this voicemail box and then a valid email address where the notification email is sent.
Extension Configuration

The Dialplan configuration file is /etc/asterisk/extensions.conf.

[macro-phone]
exten => s,1,Dial(${MACRO_EXTEN},25)
exten => s,n,Goto(${DIALSTATUS},1)

exten => ANSWER,1,Hangup
exten => CANCEL,1,Hangup
exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)

[from-pstn]
exten => s,1,Macro(phone,Zap/1)

[long-distance]
exten => NXXNXXXXXX,1,Dial,Zap/4/${EXTEN}
exten => 1NXXNXXXXXX,1,Dial,Zap/4/${EXTEN}

[local]
exten => NXXXXXX,1,Dial,Zap/4/${EXTEN}

[emergency]
exten => 911,1,Dial,Zap/4/${EXTEN}

[stations]
exten => 100,1,Macro(phone,Zap/1)

[users]
include => stations
include => long-distance
include => local
include => emergency

Here we define a powerful macro to seamlessly integrate voicemail into the system. As we defined in zapata.conf, calls from the PSTN line go into the from-pstn context, to which we pass onto Zap/1, here our actual telephone handset (or house wiring, if you are hardcore)

The ’s’ extension is the starting extension, since FXO (line) ports do not provide any sort of called number identification , so we simply use ’s’.

The remaining contexts layout a sane dial plan that allows for future expansion and access control.

For example – Lets say you added another FXS port to give your 15 year old daughter her own telephone line, you could add the following to extensions.conf:

[teenagers_room]
include => stations
include => local
include => emergency

Then ensure that the new FXS channel was sent to the ‘teenagers_room’ context (in zapata.conf). This is one effective method control your Daughter’s long distance bill. 🙂

Hopefully this shows you the power you can have at your home. No longer are telephone systems only for the office. With computer technology cost dropping and Asterisk reaching maturity you can, with just a little bit of effort deploy a very powerful phone system within your own home.

Tags: Asterisk, How To, VoIP

Asterisk on OpenWrt(Dial Plan)

Asterisk on OpenWrt

By Joe Barr on February 17, 2006 (8:00:00 AM)
Asterisk is free software that lets you create a fully functional, easily customizable, private branch exchange (PBX). Businesses like Asterisk because they can save money by using it, and because it is open source, they can add functionality to it easily and inexpensively. Asterisk is also becoming popular with home office users — so much so that it spawned a new project called Asterisk@Home, which released its 1.0 version last year. Now there’s even a version of Asterisk that runs on OpenWrt, a Linux distribution designed to run on your wireless router (see “OpenWrt nears prime time“). I found it to be worthwhile, but I wouldn’t depend on it for my home office.

Creating a dialplan is a little bit like programming. You may remember that in iax.conf and sip.conf, we made entries identifying the context of whatever device or channel was being defined. That entry tells Asterisk where to look in extensions.conf for guidance on the connection being requested.

Here is my simple extensions.conf.

;
[general]
;
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

[globals]
TRUNKMSD=1 ; MSD digits to strip (usually 1 or 0)
OUTBOUNDTRUNK=IAX2/warthawg@NuFone
NUFONENUMBER=8005551212 ; phony number

[internal]

include => inbound
include => outbound

exten => 101,1,Dial(SIP/bt101,15)
exten => _9NXXNXXXXXX,1,Goto(outbound|BYEXTENSION|1)

[inbound]

exten => 8005551212,1,Answer
exten => 8005551212,2,Background(enter-ext-of-person)

exten => 101,1,Dial(SIP/bt101,15)
exten => 101,102,Playback(ext-is-busy)
exten => 101,103,Hangup

exten => i,1,Playback(invalid)
exten => i,2,Goto(inbound,8004288951,2)

exten => t,1,Hangup


[outbound]

exten => _91NXXNXXXXXX,1,Dial(${OUTBOUNDTRUNK}/${EXTEN:1})
exten => _91NXXNXXXXXX,2,Congestion
exten => _91NXXNXXXXXX,102,Congestion

[default]

exten => s,1,Dial(SIP/bt101,15)

Let’s go over the [inbound] context shown above, which contains the rules for Asterisk to apply to incoming calls from my DID number from NuFone.

Asterisk-speak: A basic primer

Dialplan – the instructions that control the execution of your PBX: making connections for incoming, outgoing, and internal calls.

DID – Direct Inward Dialing. A method of overloading physical phone lines so that you can have a greater number of extensions than actual lines. In a small business, for example, there may only be four phone lines, but — thanks to the magic of DID — six or eight extensions can share them, each reachable by its own distinct phone number. The phone company passes the number dialed to the PBX, and the PBX patches the call to the correct extension. So even though you have only four lines, you can pretend to have twice that many. The only caveat is that you are always limited by the fact that you can’t have more concurrent calls than you have real lines. If you’ve ever tried to make a call from an extension in a business but have gotten a message saying all lines are busy, DID is the culprit.

IAX – Inter-Asterisk eXchange protocol, Asterisk’s protocol for data transport. These days, IAX actually refers to IAX2, the second generation of IAX. IAX can handle a number of different codecs and types of data, from voice to video.

Jitter – An abrupt stop/start/change in the rate of incoming traffic which causes the audio signal to break up and perhaps to garble words. Similar to pixelation on a video stream, except it’s in your ear.

PBX – Private Branch eXchange. The equipment that routes incoming and outgoing calls at a location to the phones on the desks at that location. Basically, a switchboard. Asterisk is an open source software PBX.

POTS – Plain Old Telephone Service. What you get from Ma Bell or one of her children or competitors.

PSTN – Public Switched Telephone Network.

RTP – Real-time Transport Protocol. An Internet protocol (per RFC 1889) for the transport of audio and video.

SIP – Session Initiation Protocol. SIP is an IETF standard for managing interactive sessions requiring multimedia, and is widely used for VOIP. SIP does not pass data; it only manages the sessions. RTP is used to pass the data after SIP sets up the session.

When a call is received on the inbound IAX connection defined in iax.conf, it is identified by the number the caller dialed when calling me. Any line that begins exten => applies only to the extension or group of extensions following the =>. I say extension or group of extensions because it can either be a discrete phone number, like 8005551212, or a pattern for an extension that may include a number of different extensions. The general format for the exten => directive is extension, priority, command. The priority determines the order of execution, not the order in which they appear in the file.

The first three lines of the [inbound] context are only executed when the extension is that of the DID number provided by NuFone. Regardless of the order those three lines appear in, they are executed by priority, with the lowest number being the highest priority.

Therefore, the Answer command is executed first, the Background second. The Background command plays a recording asking the caller to enter the extension he desires.

You could use Playback on this line instead of Background, but if you use Background, Asterisk will listen for the extension being entered while the message is being played. If you use Playback, Asterisk won’t start listening for the extension until the message has been played, which could be annoying for callers who already know what the message says.

Note that the extension changes in the third line. If and only if the caller enters extension 101 does Asterisk dial the BT101 extension. If the caller dials 101 and someone answers, the connection is complete and we are done.

If the extension dialed is busy, Asterisk bumps the priority by adding 101 to the priority that dialed the call, so that any following commands with a priority of less than 102 are not executed. In my dialplan, a busy extension plays a message saying I’m busy and asks the caller to call back later, then hangs up.

Asterisk provides two special codes for the extension for easy handling of both invalid and busy extensions. Notice the first two lines following the Hangup command. Both use the special i code, meaning an invalid — unhandled — extension was entered. Those two lines play a message to the caller, then route the call back to the Background command, asking the caller to enter the extension desired.

The last command in the [incoming] context uses the special t extension code, which catches calls where no extension is entered within 10 seconds. It simply hangs up the phone.

Starting Asterisk for the first time

To start Asterisk running on OpenWrt, enter asterisk -cvvv at the command line. This will open an Asterisk console for you, where you can monitor and control its operation.

While you are tweaking your configuration, it may be wise to enter the following two commands when you first start Asterisk.

set verbose 10
set debug 10

That will make Asterisk as verbose as it is possible for it to be, and when you’re shaking down your configuration, especially the dialplan, that’s a good thing. For other commands available at the Asterisk console, enter help.

When things don’t go as you think they should, turn to the book first, but remember that the version of Asterisk ported to OpenWrt is 1.07, and the current Asterisk version is 1.2.x, so the documentation may not match reality on OpenWrt. The #asterisk and #openwrt IRC channels on Freenode.net are also handy resources.

Having your own PBX is fun. Click Here for a sample of one my unavailable messages callers might be greeted with.

Conclusions about Asterisk on OpenWrt

I have experienced some jitter with Asterisk on OpenWrt, but most of the time the voice quality is fine. An active telephone call will have some impact on your Internet surfing and file downloading, but assuming you have broadband access, it won’t be significant, and vice versa.

I’ve since used bwm-ng — a bandwidth monitor — and measured Asterisk usage at 20KB a second each way during a SIP call. You probably will not notice it at all on your broadband connection, even though a big download or upload might take a little longer.

Memory and storage are the two big constraints on Asterisk on OpenWrt. A voice mail module is available, but with such scarce resources for storage, I opted not to use it. Running a second or third line would also be expensive in terms of memory, and might be more than OpenWrt could handle.

In my opinion, Asterisk on OpenWrt is a fun experiment, a good way to learn about telephony, and an easy way to learn Asterisk. But I wouldn’t want my small business, or even my home office, to depend on it for voice communications.

Asterisk on OpenWrt

Asterisk on OpenWrt

By Joe Barr on February 17, 2006 (8:00:00 AM)
Asterisk is free software that lets you create a fully functional, easily customizable, private branch exchange (PBX). Businesses like Asterisk because they can save money by using it, and because it is open source, they can add functionality to it easily and inexpensively. Asterisk is also becoming popular with home office users — so much so that it spawned a new project called Asterisk@Home, which released its 1.0 version last year. Now there’s even a version of Asterisk that runs on OpenWrt, a Linux distribution designed to run on your wireless router (see “OpenWrt nears prime time“). I found it to be worthwhile, but I wouldn’t depend on it for my home office.

I installed Asterisk on OpenWrt White Russian RC4 on a Linksys WRT54GS wireless router. It’s my first Asterisk installation. I admit that I scraped the knuckles on both hands getting Asterisk correctly configured, but now that I’ve done it, I would say it was worth all the frustrations it caused me. Not only do I now have a functional personal PBX, I’ve also learned a little about the black art of telephony along the way.

Installation was a snap. All I had to do was point my browser at the WRT54GS’s IP address, log in at the OpenWRT Admin Console, and then click the install button next to the Asterisk and Asterisk-sounds packages. The install was finished, but I still had a long way to go.

But first, a word or two about what I had already done prior to installing Asterisk. I first had to find a telephone I could use with Asterisk. I chose a Budge Tone Grandstream BT-101, based on its relatively low cost. You have to configure the phone’s user name, password, network parameters, and method of sending dual-tone multi-frequency (DTMF) to get it to work with your Asterisk installation.

Next, I had to find a suitable VoIP provider. I found 11 zillion Internet phone companies, but not all of them are Asterisk-friendly, nor do they all allow customers to BYOD (bring your own device). When I found one — NuFone — that did both, and seemed reasonably priced, I signed up for an account.

Configure this way

You must walk many paths, grasshopper, to Asterisk on OpenWRT configuration enlightenment. Sometimes those paths cross, double back, or wander deep into the land of Notworkski, but you must hack them until they work. I’ll provide key portions of my configuration files in this story, but while they may work for me and my particular hardware and provider environment, they may not work for you. Use them as a guide rather than simply copying them into your /etc/asterisk directory.

Resources
The best documentation I’ve come across on Asterisk is a book from O’Reilly called Asterisk: The Future of Telephony , by Jared Smith, Jim Van Meggelen, and Leif Madsen.

Because the book is published under the Creative Commons license, it is available from both regular retail channels and by free download on the Internet.

In addition, the Asterisk Documentation Project provides a lot of valuable documentation.

As you do the configuration, it may help to think of Asterisk as a PBX, the old-fashioned kind where an operator would physically connect an incoming call to the correct extension by plugging the correct patch-cord into the right socket. The Asterisk software does basically the same thing: it is all about patching local extensions to incoming or outgoing calls.

In my simple home office environment, my local extension — the SIP BT-101 Internet phone — needs to be able to talk to an Inter-Asterisk eXchange (IAX) network, NuFone. When we’re done, Asterisk will speak the IAX protocol to NuFone and SIP to the phone.

If you look in /etc/asterisk after the install you’ll see about 20 configuration files. Don’t despair; you probably need to worry about only three of them: iax.conf, sip.conf, and extensions.conf.

All Asterisk configuration files are plain text files. The ground rules for hacking them are simple. Each conf file — or at least each of the three covered in this article — is divided into sections. Section names, sometimes referred to as contexts, are given within brackets, like this: [section-name]. Anything on a line following a semicolon is a comment and is ignored by the software. Some configuration statements take the form item=whatever . Others look like item => something .

Let’s start with the iax.conf file. The IAX protocol thinks of its relationships as being between peers, users, or friends. The relationship between my Asterisk installation and Nufone is defined twice: one as peer, once as user. The settings in iax.conf allow Asterisk to register and handle outgoing calls from and incoming calls to the NuFone.

In the [general] section of iax.conf, I added the following line to register my account at NuFone:

register => username:password@nufone.net

In addition, I added two new sections to the file, both named NuFone. The first defines a peer relationship for outbound calls. The next defines a user relationship for inbound calls. My iax.conf looks like this:

[general]
bandwidth=high
allow=all
disallow=g723.1
jitterbuffer=no
forcejitterbuffer=no


register => user-name:password@providerIPaddress


tos=lowdelay
autokill=yes


[NuFone]
type=peer
user=username
host=providerIPaddress
secret=password
disallow=all
allow=ulaw
allow=gsm


[NuFone]
type=user
secret=password
context=inbound

Now let’s take a look at sip.conf. Remember, Asterisk is talking IAX to NuFone, and SIP to our phone, the BT-101, so sip.conf is where we tell Asterisk about the phone. My sip.conf looks like this, and should be a good starting point:

[general]
context=default ; Default context for incoming calls
bindport=5060 ; UDP Port to bind to (SIP standard port is 5060)
bindaddr=0.0.0.0 ; IP address to bind to (0.0.0.0 binds to all)
srvlookup=yes ; Enable DNS SRV lookups on outbound calls


[authenticate]
auth=username:password@192.168.1.1


[bt101]
type=friend
context=internal ; Where to start in the dialplan when this phone calls
callerid=name ; Full caller ID, to override the phones config
host=dynamic
user=username
secret=password
nat=no ; there is not NAT between phone and Asterisk
canreinvite=no ; allow RTP voice traffic to bypass Asterisk
dtmfmode=rfc2833 ; either RFC2833 or INFO for the BudgeTone
call-limit=1 ; permit only 1 outgoing call and 1 incoming call at a time

Asterisk looks to a configuration called a dialplan to see how you want a call to be handled. You define dialplans in extensions.conf, which tells Asterisk how to handle phone calls. Before you craft a dialplan in extensions.conf, I recommend you have a copy of the book Asterisk: The Future of Telephony available for guidance.

Next: The dialplan

Configuring Asterisk

Configuring Asterisk

Document Actions

Here we go through the basic configuration of Asterisk. We will set up analog telephones, SIP telephones, and IAX connections.

FXO and FXS Channels

The difference between an FXO channel and an FXS channel is simply which end of the connection provides the dial tone. An FXO port does not generate a dial tone; it accepts one. A common example is the dial tone provided by your phone company. An FXS port provides both the dial tone and ringing voltage to alert the station user of an inbound call. Both interfaces provide bidirectional communication (i.e.,communication that is transmitted and received in both directions simultaneously).

If your Asterisk server has a compatible FXO port,you can plug a telephone line from your telephone company (or “telco”) into this port. Asterisk can then use the telco line to place and receive telephone calls. By that same token,if your Asterisk server has a compatible FXS port,you may plug an analog telephone into your Asterisk server, so that Asterisk may call the phone and you may place calls.

Configuring an FXO Channel

We’ll start by configuring an FXO channel. The zaptel.conf file located in /etc/ is used to configure your hardware. The following minimal configuration defines an FXO port with FXS signaling:

fxsks=2

loadzone=us

defaultzone=us

After configuring zaptel.conf,you can load the drivers for the card. modprobe is used to load modules for use by the Linux kernel. For example,to load the wctdm driver, you would run:

# modprobe wctdm

You can verify that the hardware and ports were loaded and configured correctly with the use of the ztcfg program:

# /sbin/ztcfg –vv

Configuring an FXS Channel

We’ll now configuring an FXS channel. The zaptel.conf file located in /etc/ is used to configure your hardware. In the example below we are configuring channel 1 to use FXO signaling,with the kewlstart signaling protocol:

fxoks=1

fxsks=2

loadzone=us

defaultzone=us

After loading the drivers for your hardware,you can verify their state with the use of /sbin/ztcfg –vv:

Configuring SIP

The sip.conf file starts with a [general] section,which contains the channel settings and default options for all users and peers defined within sip.conf. You can override the default settings on a per-user/peer basis by configuring them within the user/peer definition.

Domain Name System Service records (DNS SRV records) are a way of setting up a logical,resolvable address where you can be reached. This allows calls to be forwarded to different locations without the need to change the logical address. By using SRV records,you gain many of the advantages of DNS,whereas disabling them breaks the SIP RFC and removes the ability to place SIP calls based on domain names. (Note that if multiple records are returned,Asterisk will use only the first.) DNS SRV record lookups are disabled by default in Asterisk,but it’s highly recommended that you turn them on. To enable them,set srvlookup=yes in the [general] section of sip.conf.

Each connection is defined as a user,peer,or friend. A user type is used to authenticate incoming calls,a peer type is used for outgoing calls,and a friend type is used for both. The extension name is defined within square brackets ([]). In this case,we have defined the extension john as a friend.

A secret is a password used for authentication. Our secret is defined as welcome. We can monitor the latency between our Asterisk server and the phone with qualify=yes, thereby determining whether the remote device is reachable. qualify=yes can be used to monitor any end device,including other Asterisk servers. By default,Asterisk will consider an extension reachable if the latency is less than 2,000 ms (2 seconds). You can configure the time Asterisk should use when determining whether or not a peer is reachable by replacing yes with the number of milliseconds.

If an extension is behind a device performing Network Address Translation (NAT), such as a router or firewall,configure nat=yes to force Asterisk to ignore the contact information for the extension and use the address from which the packets are being received. Setting host=dynamic will require the extension to register so that Asterisk knows how to reach the phone. To limit an endpoint to a single IP address or fully qualified domain name (FQDN),replace dynamic with the IP address or domain name. Note that this limits only where you place calls to,as the user is allowed to place calls from anywhere (assuming she has authenticated successfully). If you set host=static, the end device is not required to register.

Configuring IAX Connections

Inbound

In iax.conf,sections are defined with a name enclosed in square brackets ([]). Every iax.conf file needs at least one main section: [general]. Within the [general] section,you define the settings related to the use of the IAX protocol,such as default codecs and jitter buffering. You can override the default codecs you specify in the [general] section by specifying them within the user or peer definitions.

Within the [general] section,you’ll need to add a register statement. The purpose of the register statement is to tell the FWD IAX server where you are on the Internet (your IP address). When a call is placed to your FWD number,the FWD servers do a lookup in their database and forward the call to the IP address associated with the FWD number.samples).

In the [iaxfwd] section,define the user for incoming calls with type=user. Then define where the incoming call will be handled within the dialplan,with context=incoming. To specify that the authentication for the incoming call will be done with an RSA public/private key pair,use auth=rsa. The public key is defined with inkeys=freeworlddialup. The freeworlddialup public key comes standard with Asterisk.

Outbound

While an IAX user receives inbound calls; an IAX peer is used to place outbound calls. This section will set up iax.conf and extensions.conf so that you can place calls.

A peer is defined with type=peer. Use host to configure the server through which you will place calls (iax2.fwdnet.net). Your FWD account number and password will be used for authentication to the FWD network and are defined respectively with username and secret.

You can use the qualify=yes statement to occasionally check that the remote server is responding. The response time (latency) can be viewed from the Asterisk console with iax2 show peers. By default,a peer is considered unreachable after 2000 ms (2 seconds). You can customize the time period by replacing yes with the number of milliseconds.

The available codecs and the order of preference can be defined on a per-peer basis. disallow=all is used to reset any codec settings set previously. You can then allow the codecs you support and set their preference (from top to bottom),using the syntax allow=codec.

Use the iax2 show registry command from the Asterisk CLI to verify that you’ve registered successfully.

Excerpts in this section have been taken from O’Reilly’s Asterisk:The Future of Telephony.