PBX: Debian, Asterisk, DAHDI, and OpenVox A400E11

Rather than a tutorial, this article is a field manual (it provides relevant instructions, but leaves out the rationale behind them) that describes a very basic but working installation of an Asterisk PBX running on Debian 9.5 (codename "stretch") that uses an OpenVox A400E11 analogue card for connecting to a PSTN from internal VoIP stations using the SIP .

Card Installation

OpenVox' analogue cards are sensitive to ESD, use an anti-static wrist strap while you install the card. Between the card and the telephone line, install an inline surge protector (such as the Tripp Lite DTEL2). Double-check that the surge protector's grounding cable is attached to the ground. If a proper external connection to the ground is not available, employ bonding: attach the ground cable of the protector it to an unpainted metal part of the case of the PC. Ensure that electricity does not leak from the PC's PSU to the case of the PC.

An OpenVox A400E11 PCIe card with two FXS and two FXO modules.

In the standard reference orientation of a PCI add-on card (as presented above: the mounting bracket is on the left, the PCI bus connector is at the bottom, components are facing the observer), analogue add-on FXO (red daughter PCB) and FXS (green daughter PCB) modules are connected in the left-to-right order to RJ11 female slots of the card in the top-to-bottom order (i.e. the leftmost analogue module is connected to the topmost RJ11 slot). When the card is powered, every analogue module that is properly initialised is signalled with a lit green LED above the respective RJ11 slot.

Physical Location of the System

Assuming that the PBX is intended for headless operation, the order of software installation is as follows:

  1. Connect the PC to a KVM switch and to the Internet.
  2. Install Debian.
  3. Configure Debian.
  4. Install DAHDI
  5. Install Asterisk.
  6. Power down the PC and move it to its intended physical location.
  7. Remotely configure DAHDI
  8. Remotely configure Asterisk.

Debian Installation

In the tasksel dialogue of the installer, select standard system utilities and the SSH server; deselect everything else.

Debian Configuration

Install sudo(1) and make yourself a member of the group sudo. Logout and login. Invoke

sudo apt-get update      
sudo apt-get dist-upgrade
Reboot into the up-to-date kernel. If the PC has a single NIC that is shared by VoIP and remote management, disable ‘predictable NIC names’ by passing net.ifnames=0 on the kernel command line (edit /etc/default/grub and invoke update-grub(8)) to have the NIC to be always named eth0. Configure the NIC that you plan to use for VoIP to join the same VLAN as your SIP clients. Assuming that the name of the VoIP NIC is eth0, that it should have the static class C IPv4 address of, and that the VLAN ID is 17, have the following in interfaces(5):
auto eth0.17
iface eth0.17 inet static
    vlan-raw-device eth0

DAHDI Installation

sudo apt-get install dahdi-source dahdi
sudo m-a a-i dahdi

List supported tone zones. Choose a zone from this list, you will need this value to for configuring DAHDI later:

wget -qO - http://http.debian.net/debian/pool/main/d/dahdi-tools/dahdi-tools_2.11.1.orig.tar.gz \
    | tar -Oxzf - dahdi-tools-2.11.1/zonedata.c \
    | grep '\.country[[:space:]]*=' \
    | sed 's/^[^"]*"\([^"]*\)".*$/\1/' \
    | sort -u

Asterisk Installation

sudo apt-get install asterisk-dahdi

DAHDI Configuration

List supported operating modes of the wctdm driver:

tar -Oxjf /usr/src/dahdi.tar.bz2 modules/dahdi/drivers/dahdi/fxo_modes.h \
    | grep '\.name[[:space:]]*=' \
    | sed 's/^[^"]*"\([^"]*\)".*$/\1/' \
    | sort -u

Configure the desired operating mode of the wctdm driver (replace MODE below):

cat <<EOF | sudo tee /etc/modprobe.d/wctdm.conf > /dev/null
options opermode=MODE
sudo update-initramfs -u -k all

Generate DAHDI hardware configuration files:

sudo dahdi_genconf chan_dahdi dahdi modules

Set tone zones loadzone and defaultzone in /etc/dahdi/system.conf (note: replace ZONE below):

TEMP_SYSTEM_CONF="$(mktemp)" \
    && grep -vE '^(loadzone|defaultzone)' /etc/system.conf > "${TEMP_SYSTEM_CONF}" \
    && sudo mv "${TEMP_SYSTEM_CONF}" /etc/system.conf
cat <<EOF | sudo tee -a /etc/system.conf > /dev/null
loadzone = ZONE
defaultzone = ZONE

Asterisk Configuration

Create the minimal /etc/asterisk/chan_dahdi.conf (note saving the sample for future reference):

sudo cp /etc/asterisk/chan_dahdi.conf /etc/asterisk/chan_dahdi.conf.orig
cat <<EOF | sudo tee -a /etc/asterisk/chan_dahdi.conf > /dev/null
#include dahdi-channels.conf

List supported tone indications:

grep -E '^\[[a-z]{2}\]' /etc/asterisk/indications.conf \
    | tr -d '[]' \
    | sort -u

Set tone indication (note: replace COUNTRY below):

sudo sed -i /etc/asterisk/indications.conf \

Define at least one SIP peer in /etc/asterisk/sip.conf and create a dialplan in /etc/asterisk/extensions.conf. Note that numbers of DAHDI channels that you use in the dialplan must match definitions found in /etc/asterisk/dahdi-channels.conf—be careful when re-using existing dialplans because numbers of DAHDI channels depend on physical location of analogue modules on the card. Your previous dialplan may fail if you use it with a card having a different layout of analogue modules.

The minimal /etc/asterisk/sip.conf that enables Asterisk to listen for SIP connections on the IPv4 address of and defines one peer named one looks as follows (replace SECRET below with the value of the secret that is known to the peer one):



The minimal dialplan, /etc/asterisk/extensions.conf that enables the SIP peer one defined above to call PSTN and receive calls from it looks as follows (assuming that the number of the DAHDI channel that corresponds to the FXO which is connected to PSTN is 1, and that PSTN numbers must begin with * or a digit):



exten => s,1,Answer()
exten => s,n,Dial(SIP/one)
exten => s,n,Hangup

exten => _[*0-9]./one,1,Set(TIMEOUT(response)=3)
exten => _[*0-9]./one,2,Dial(dahdi/1/${EXTEN})
exten => _[*0-9]./one,3,Hangup

Ensure that file mode and ownership of those files that you modified are correct:

(cd /etc/asterisk \
    && sudo chown asterisk:asterisk dahdi-channels.conf \
        chan_dahdi.conf \
        indications.conf \
        sip.conf \
        extensions.conf \
    && sudo chmod 640 dahdi-channels.conf \
        chan_dahdi.conf \
        indications.conf \
        sip.conf \

Now reboot and test the system. The rest of the setup depends on your requirements.

The Essential Asterisk Cheat Sheet

Execute an Asterisk commandsudo asterisk -rx command
Start the Asterisk shellsudo asterisk -r
List DAHDI channelsCLI> dahdi show channels
List registered SIP peersCLI> sip show peers
List calls in progressCLI> core show channels
Reload the dialplanCLI> dialplan reload
Dial an extensionCLI> dial extension
Terminate a call in progressCLI> channel request hangup channel
Leave the Asterisk shellCLI> exit

Useful Links

Vadim Penzin, September 4th, 2018

I hereby place this article into the public domain.
You are welcome to contact me by writing to howto at this domain.
I publish this information in the hope that it will be useful, but without ANY WARRANTY.
You are responsible for any and all consequences that may arise as the result of using this information.