Configuring Polycom 321 IP Phones With a Plantronics CS510 Wireless Headset

98% of my work is software engineering and web development but sometimes I get pulled into troubleshooting random internal IT issues.

One of these was building a small business phone system. Recently it was setting up a wireless headset for the Polycom 321 IP phones.

Sounds easy, right? Nope. VOIP systems are not well documented and seem to suffering the same fate as router hardware. All the innovation in the VOIP is in the cloud, on the hardware side there is a lot of progress to be made.

So, for all those who just need to get their wireless headset to work:

Hardware CS510 – The wireless headset EHS APP-51 – The adaptor Plantronics adaptor for the Polycom phone. Yes, that’s right, the expensive wireless headset doesn’t come with a adaptor needed to make the headset work. RJ22 to Male 2.5mm – This connects the APP-51 adaptor to the IP 321 2.5mm headphone jack. This is only needed for some lower-end Polycom IP phone models. Some of the more advanced Polycom models, like the SoundPoint IP 650 don’t need this adaptor. Setup

Plantronic Headset

For Plantronics headsets, change the coarse receive level to 3 and the transmit level to B on the headset base unit. Refer to the Universal EHS Adapter Getting Started guide packed in the headset box for more details.

Polycom Phone

I swapped a couple emails with Plantronics support before I found this piece of information:

Phone must be running SIP application 3.1 or higher and BootROM 4.1.0 or later.

Specify whether or not the electronic hookswitch is enabled and what type of headset (attribute up.analogHeadsetOption set to 2) is attached by changing the phone1.cfg in the boot server. If this is not setup the call will hang up in 30 seconds

References Polycom IP 321 EHS Plantronics CS520 User Guide Plantronics EHS Guide Plantronics Polycom Compatibility Guide

Continue Reading

Cloud Based DID With a POTS Based Asterisk System

A while back I wrote about my experience setting up a business phone system with Asterisk, Polycom, and POTS. This system has been working fine over the last year, I’ve only had to dive in once or twice to fix a couple issues (which I’ll detail in a future post).

However, recently someone using the phone system needed a Direct Inward Dial (DID) to their phone. I couldn’t find any concise walkthrough about how to set this up, so I’ve written down my processing in figuring this out.

I knew Asterisk supported DID, and I found a guide that walked you through setting one up.

If you using POTS for your calls and not a SIP trunk, DID gets tricky really fast. Some information mentioned voltage, analog signaling, and other tricks; having to work with your telephone provider; and PRI, number pulsing, and reversing polarity on analog lines. Both solutions seemed very messy and time consuming to me (working with my telephone company – Verizon – has only been painful). My hunch was that the lines coming into our building weren’t clean and we would have issues with the connections (the contractor who set up the lines mentioned something about the lines being dirty and not being able to fix them). I’m not a VOIP professional – nor do I want to be – line voltage and electrical signaling is the last thing I want to deal with.

Another possibility would of been to dedicate a physical line to the specific phone off the PBX and take that number off the hunt group. I could create an inbound route in Asterisk linking the dedicated line to the extension off the PBX. If I used this method, I would of had to take the line off the hunt group because depending on the number of people calling in the line might be picked up and then anyone using the DID will get a busy signal.

However, this would require buying more hardware and ordering another POTS line, something I didn’t want to do (mainly because of the time involved).

At this point I started to regret going with POTS over SIP trunks for our phone provider. However, POTS offered significant savings for us. Our lines through Verizon are relatively cheap (somewhere around ~$25/line) and came with unlimited minutes. When I looked at cloud phone providers they were charging $0.02 – 0.03 a minute. With our call volume this would of ended up costing us a good chunk more per month. Taking a look at cloud phone providers now it looks like the landscape has changed and cloud and land line providers seem to be much closer to price parity.

I figured it must be possible to forward a call over the PSTN to a SIP. Twilio definitely doesn’t allow connection to SIP endpoints right now (although, they have a service in beta). With Tropo it seemed like it was possible, but I couldn’t test an outbound phone connection without going through a verification process. Additionally, outbound calls ran $0.03/minute which seemed high.

After some googling I found DID Logic which on their front page mentioned call forwarding to a SIP URI – great. The company seems a bit  shady (“bought a theme + plugged in some standard marketing copy” sort of site), but since I could test things out for a couple bucks I went ahead and tried it out – it works great.

I grabbed a number off of DID Logic for ~$1/month + $0.007/minute and forwarded it to my PBX.

However, the Asterisk box was not setup to pick up anonymous SIP calls and my SonicWall firewall was not setup to expose SIP ports to the PBX.

Setting up Asterisk to Support SIP Call Forwarding From DID Logic

Make sure “Allow Anonymous InBound SIP Calls?” is enabled in the General Settings on your FreePBX admin (a SIP call from DID Logic will be anonymous).

Then add an InBound DID number in the extension’s control panel. With this DID assigned you can now call your phone using the SIP URI “”. Most likely your PBX is behind a firewall, you’ll have to configure your firewall + NAT settings to forward SIP traffic to the PBX.

Sonic Wall SIP Traffic Forwarding Setup

You need to have both a firewall rule and a NAT routing policy for SIP traffic to work on a Sonic Wall device. Check out this comment for information about UDP timeout settings and some other general information about SonicWall Config.

Your Firewall rule should look something like:

WAN –> LAN Source: Any Destination: Any Service: VOIP Allow

Your Firewall rule should nothandle the routing to a specific IP address even though there is an option for it. The routing is handled via your NAT rule (General > Nat Policies) and should look like:

Original Source: Any Translated Source: Original Original Destination: Any Translated Destination: PBX Original Service: VOIP Translated Service: Original

The PBX destination won’t exist by default. To create that destination, go to Firewall > Address Objects and add one referencing your PBX on your LAN.

Also, ensure that “Enable consistent NAT” is enabled under VOIP > Settings. Do not enable any of the transform options.

Continue Reading

Introduction to VOIP Telephony: Setting up a Business Phone System with Asterisk and Polycom

I was recently charged with picking out a new telephone system for a new office the company I work for was moving into. We were previously using a 3Com NBX 100. Inbound and outbound call volume for this company is relatively low. The needs of the company included:

Easy + extensible conference calls (update: we’ve recently transitioned to using UberConference for all conference calls) Ability to use softphones (software based SIP phones) Voicemail system that: Would email you when there was a new voicemail with a audio attachment Ability to view voicemails on a web page Traditional keypad based voicemail navigation Reliability

The company was not looking for a unified messaging system, video conferencing, color LCD phones with automatic VPN connections, etc. A basic PBX to support the phone needs of a small company was all that was needed.

Proposals from a couple providers yielded total costs of a 10 hard phone + 10 soft phone system to be around $8,000 – $12,000 with an ongoing contract. This seemed a bit high considering the simplicity of the needs of the company. After some research and a lot of trial and error I was able to get the entire phone system deployed for less than $2,100 ($350 POE switch, 10 phones * $85, ~$900 analog card, used an old Windows box lying around). It took me about a week of full-time work to figure out how all the peices fit together and deploy the system. Although VOIP may seem a bit intimidating with all the lingo and plethora of options, it isn’t as hard or mysterious as it may seem at first.

Hopefully this compilation of notes will help someone in a similar situation develop and deploy a VOIP Asterisk based solution. Enjoy.

Vocabulary POTS = Plain Old Telephone Service = Analog Lines = Copper Lines SIP = Session Initiation Protocol. This is the traffic that will travel over your LAN and communicate with your office phones (in my case, Polycom 321s and SIP Trunk = A digital alternative to POTS. I did not utilize a SIP Trunk in my setup, but from what I understand you basically grab a special card that then connects through your WAN to a remote SIP Trunk provider. Essentially your phone lines are routed through your internet (similar to Skype). PBX = Private Branch Exchange. This is box that sits between your telephone endpoints (SIP trunk or POTS) and your phones connected to your lan POE = Power Over Ethernet. Many modern phones can be powered through the ethernet cable that they use to communicate with the LAN, this eliminates the need for power adaptors for each individual phone. Some ‘pre-built’ / commercial PBXs have POE built in. In my setup I purchased a NetGear FS728TP-100NAS TFTP = Trivial File Transfer Protocol. The Polycoms (and many other phones) use TFTP to pull their application binary, configuration settings, and other information. ARP = Address Resolution Protocol. I don’t really understand this piece too much, but FreePBX / Elastix = GUI for the Asterisk configuration files DAHDI = software that integrates with Digium (and other) analog and digital PCI hardware devices. This used to be called Zaptel. This software runs on the driver level of operating system (it isn’t a service like Asterisk). Essentially is bridges asterisk with POTS or SIP trunks. Basic System Overview Separate cat6 voice + data lines to each work station Data lines connected to gigabit switch Voice lines connected to the POE 10/100 switch POE switch tied to the gigabit switch via 2 gigabit ethernet ports Asterisk running on couple-year-old Dell dual-core 2.8ghz, 3GB of ram, gigabit ethernet Asterisk box (PBX) connected to gigabit switch 6 POTS lines through Verizon 10 Polycom SoundPoint 321 10+ Softphones Remote users accessing PBX via VPN ack instead of grep on the command line Asterisk, FreePBX, DAHDI, CentOS 2.6.18-274.17.1.el5 (`uname -r`) Setting Up an Asterisk-Based VOIP System with Polycom Phones Basic AsteriskNOW Installation Procedure There a couple ways to handle Asterisk installation, and a couple GUIs to choose from. I settled on AsteriskNOW + FreePBX GUI. After downloading the image, burning it to disk, and booting from the disk on your asterisk box you still need to update to the latest versions of the software by running `yum update`. After running `yum update` you’ll have to update the FreePBX software. You can sort of do this through the FreePBX module interface, but there was an extra step involved that I couldn’t find my notes on. Duplicate IP Message on Polycom 321 Phones

This message was caused because of an old Microsoft 2003 Business server that was still connected to the network. DHCP used to be handled by the server, but we switched DHCP to the SonicWall. Although DHCP was disabled on the MS server, it seemed to be sending out some sort of broadcast that caused the phones (and only the phones!) to report a duplicate IP. Eliminating the MS server was the only solution that worked (all services relating to DHCP had been turned off on the server.

Updating Polycom 321 Firmware via TFTP

The Polycom devices support both FTP + TFTP configuration + boot loading. However, I was trying to simply the setup as much as possible and trivial FTP sounded a bit more simple. However, a TFTP server is not configured by default on an AsteriskNOW installation. To enable TFTP, first run `nano /etc/xinetd.d/tftp` from the command line and then change `disable = yes` to `disable = no`; save the file. Finally, run `service xinetd restart` from the command line. The TFTP server should be up and running.

The TFTP server does not have `ls` and other FTP-like commands. The easiest way to test if it is working is to grab a file from it from another machine: [codee] $ tftp pbx.localhost tftp> get LoudRing.wav Received 128810 bytes in 0.1 seconds tftp> [/codee]

Sending Phone Boot Server via DHCP

Apparently there are many parameters you can send to clients via DHCP. DHCP was running on a SonicWall 210 in this specific configuration. I had a bit of trouble getting this working, but the following settings worked on the SonicWall for me:

option 66: tftp://pbx.localhost option 160: tftp://pbx.localhost option 150: tftp://pbx.localhost Note that the “tftp://” is important. In this specific instance I had a local DNS server running on a Mac Mini Server (Lion) that all clients were configured to hit before hitting the external DNS. Upgrading the Polycom BootRom & Sip.ld (Application)

This was a bit tricky, and I did not document exactly how I got to it work, but here are some pointers. You’ll need to download “UC_Software_3_3_3_release_sig_split” the not the latest “” from Polycom support. Looking at the end point manager’s package.json it seems as though the latest supported version is 3.3.3. I tried downloading the split version but it didn’t seem to work as well for me. You’ll also need to download the latest BootRom “”. After downloading these pieces you’ll have to send them to your /tftpboot folder (I used `scp sip.ld root@pbx.local:/tftpboot` to move the files over). After putting the pieces in place, `ls -l /tftpboot` should look something like this: [code] -rw-rw-rw- 1 asterisk asterisk 2437 Feb 20 14:30 000000000000.cfg -rw-rw-rw- 1 asterisk asterisk 2079 Feb 18 15:39 0004f2a8077e.cfg -rw-rw-rw- 1 asterisk asterisk 7470 Feb 18 12:53 0004f2a8077e_reg.cfg # … (more configuration) -rwxr-xr-x 1 asterisk asterisk 639624 Jan 27 14:27 2345-12360-001.bootrom.ld -rwxr-xr-x 1 asterisk asterisk 3322061 Jan 27 14:41 2345-12360-001.sip.ld -rwxr-xr-x 1 asterisk asterisk 7591196 Jan 27 13:45 bootrom.ld drwxr-xr-x 2 asterisk asterisk 4096 Feb 18 14:34 contacts drwxr-xr-x 2 asterisk asterisk 4096 Jan 26 14:59 licenses drwxr-xr-x 2 asterisk asterisk 4096 Feb 18 12:53 logs -rw-rw-rw- 1 asterisk asterisk 127966 Feb 20 14:30 LoudRing.wav drwxr-xr-x 2 asterisk asterisk 4096 Feb 13 16:12 overrides -rw-rw-rw- 1 asterisk asterisk 8537 Feb 20 14:30 sip.cfg -rwxr-xr-x 1 asterisk asterisk 14 Jan 27 14:41 sip.ver drwxr-xr-x 2 asterisk asterisk 4096 Jan 26 14:59 SoundPointIPLocalization -rw-rw-rw- 1 asterisk asterisk 95926 Feb 20 14:30 SoundPointIPWelcome.wav [/code]

I’m not sure if you needed an updated bootrom.ld and the specific 2345-12360-001.bootrom.ld; but it worked.

Using End Point Manager to Generate Configuration XML for Polycom

In order to install End Point Manager I had to upload the module via the FreePBX Module Admin. For my installation (details given above) I used version (list of .tar.gz versions can be found here, GitHub repo here. After installing, go to advanced options and set “Time Server” to “” and nmap to “/usr/bin/nmap” (you may have to install nmap via yum, I can’t remember if it was installed by default or not). If you are using TFTP, make sure that configuration option is set as well. I could not get the automatic phone vendor packages to work. I had to download the “provisioner_net.tgz” and manually upload the package via the “Manual Endpoint Modules Upload/Export” under “End Point Advanced Settings.”

At this point, with the DHCP options correctly set, for new phones you should be able to plug them into the network, run a scan using nmap, and add the phones via the end point manager GUI. Unplug & replug the Polycom phone in and it should pull the configuration from the TFTP server (the PBX box) set in the DHCP options and startup just fine.

Default “Phone Book” / Directory on Polycom

Although the phones claim to support loading the `000000000000-directory.xml` file into all phones; I could not get this to work even after factory resetting the phones. I grabbed the XML for the polycom directory by using this modified version of the printextensions module, copying the XML into the `000000000000-directory.xml` file, and then running this BASH script to copy the default to each of the phones custom directory.xml files. Do not use this with a production system as it will overwrite any users customizations.

Installing Git on CentOS (Default AsteriskNOW OS)

Yum is the default package manager on CentOS, but the default repos don’t contain git. I wanted to pull in my dotfiles to the Asterisk box as well as manage the custom print extensions repo that I was working on. Here are the two BASH lines you need: [code] rpm -Uvh yum install –enablerepo=webtatic git-all [/code]

Software vs Hardware High Performance Echo Cancellation (HPEC)

This is specific to Digium based cards. I didn’t know this until after purchasing the TDM800 with hardware echo cancellation, but after talking with an Digium customer support representative I learned that the algorithm used for echo cancelation is the same for the software based and hardware based echo cancellation. The CPU load on my installation hovers around 1%, I’m guessing for a < 20 person office environment the software based echo cancelation would of worked just fine (although I don’t have experiential evidence to support this).

Call Logging

Initially call logging did not work in my installation. You can check if call logging is configured correctly by running `asterisk -r` and then running `cdr show status` from the Asterisk prompt. You should see something like: [code] Call Detail Record (CDR) settings ———————————- Logging: Enabled Mode: Simple Log unanswered calls: No

* Registered Backends ——————- mysql cdr-custom [/code] If your installation is working correctly. Mine wasn’t, working off this guide, the following BASH commands worked for me: [code] # check if the mysql addons are installed yum list installed|ack mysql

# if they aren’t, install the mysql addons yum install asterisk18-addons-mysql [/code]

Digium Has Incredible Customer Support

I was throughly impressed by the quality of Digium’s customer support. They answered non-hardware related questions, ssh’d into my machine to debug some issues, and there was a less than one minute wait time.

Outbound Call Configuration

This was something that ended up being a bit more tricky that I thought. I ended up configuring the dial patterns to force long distance formatting (01+xxx+xxx+xxxx) on all numbers. I wanted to ability for people to dial with and without the 1, this seems to be working fine so far:

POTS Call Tuning

Different POTS lines have different levels and other ‘analog stuff’. To clear out noise and optimize your configuration you need to run the following script (retrieved from a Digium rep): [codee] service asterisk stop # tunes impendence on the analog lines fxotune -x -i

# restart dahdi and start asterisk service dahdi stop && service dahdi start service asterisk start [/codee]

Setting up IVR Auto Answer

Configure your IVR, then go to Setup –> Inbound Routes. Choose “any DID / any CID”. At the bottom of the page switch “Destination” to IVR + desired auto attendant.

Configuring Backups

I usually login to the Asterisk box as root. I configured the backups with my root SSH key, but the Asterisk backup process runs on the Asterisk user. Make sure that the SSH keys you hand off to FreePBX are readable by the asterisk process.

Inbound + Outbound Call Volume Tuning

Word of warning: I haven’t actually done this yet. These are the notes I’ve compiled, but I wasn’t able to get all this information together before the phone system was deployed.

Most of the guides I was able to find were a bit out of date. When reading through those resources recall that Dahdi is the new Zaptel. There are two gain adjustments: inbound (rxgain) and outbound (txgain). In order to test the levels run the following command: dahdi_monitor 1 -vv. These levels can be calibrated against a 102 milliwat test number, I found one here: 670-234-0102.

For the TDM800, here are the instructions from Digium on how to edit the two gain levels:

The gains are typically edited in /etc/modprobe.d/dahdi.conf. The parameters are set like:

options wctdm24xxp fxotxgain=<value>db fxorxgain=<value>db fxstxgain=<value>db fxsrxgain=<value>db

The default value is -4.5db (decibels)

They can also be edited in /etc/asterisk/chan_dahdi.conf

rxgain=<value> txgain=<value>

In this case the ‘db’ is assumed by asterisk. In chan_dahdi.conf the default value is 0.0.

We encourage you to make small changes to any of these values as it can dramatically effect your audio.

Misc Tips If calls are dropping after a couple seconds, check your external IP in Tools –> Asterisk IAX Settings Uninstalling Asterisk modules: [code]/var/lib/asterisk/bin/module_admin uninstall endpointman[/code] The Music on Hold directory is [code] /var/lib/asterisk/moh/[/code] Grabbing the DAHDI version from the command line: [code]dmesg|ack dah[/code] To add a invalid extension or timeout fallback to your IVR / autoattendant add two options in the IVR GUI: i & t (you specify i or t instead of a number) and then specify a action just like you would a normal IVR option. Restart DAHDI & Asterisk in one line:[codee]service asterisk stop && service asterisk start && service dahdi stop && service dahdi start [/codee] Copy default directory.xml to specific directory.xml’s for all Polycom devices linked to the EndPoint Manager Location of HPEC license(s): [code] /var/lib/asterisk/licenses [/code] Convert standard wav files into Asterisk / POTS compatible wav: [code]sox autoattendant.wav  -r 8000 -c 1 -s -w auto-new.wav resample -ql[/code] Caller ID is not consistent across carriers. Some carriers can disregard caller ID information altogether. I had trouble with the built-in Polycom phone restart script contained in the endpoint manager. I wrote a quick script to work with someone’s Polycom restart script as a workaround. I originally tested the system on an XP100 clone card, and I’m pretty sure that was the source of this issue, but this information was helpful in temporarily resolving that issue before I purchased the TDM800. FXO hardware’s context must be set to “from-pstn” for the IVR to be routed correctly If all your inbound calls are coming in as “Unknown” you might want to check with your service provider. According to my Verizon account rep, inbound calls can sometimes come in as Unknown on new lines if your account is configured incorrectly Dashes and parentheses outbound numbers inputted into softphones seems to cause issues with dialplans You can export Asterisk compatible .wav files directly from Audacity without using any command line tools to post-process the audio. To reset a Polycom 321 phone, reboot the phone and hold 1 + 3 + 5 + 7. The default admin password on these devices is 456. In order to enable the “Line 2” button on the polycom phones you’ll need to edit the master configuration file and change the “reg.1.lineKeys” preference to “2” References

Here is a list of links I found helpful while researching this stuff.

Polycom Phones 10/2011 – Provisioning Polycom SoundPoint IP 321 Phones – Elastix / Trixbox 09/2010 – Auto Re-Provisioning Polycom Phones 06/2008 – Upgrading Firmware on Polycom Phones (old) How to Update Polycom IP Phone Firmware via FTP 01/2009 – DHCP Option 66 & Asterisk 08/08 – TFTP Server Issues Example /tftpboot Directory 09/09 – Using PolyCom Phones with Asterisk Asterisk 09/2011 Fighting echo on POTS Asterisk Guru (great guide on misc Asterisk setup) Music on Hold Setup Slides Asterisk Blog (some tips & tricks) DAHDI Manual Asterisk Setup Guide (great resource) and Asterisk Notes General Asterisk Blog (some interesting tips & tricks) Documentation for TDM800 and Digium Knowledge Base Reza Samimi’s Blog (incredible resource, probably the most helpful thing I was able to find) Team Forrest Blog Online Asterisk Book Creating an IVR (auto-attendant) How To Configure Asterisk General Information on Asterisk Backups Software Print Well Formatted Extension + Feature Code Lists Polycom directory.xml Script Blink – Mac VOIP client. Paid. X-Lite –  Mac + PC VOIP client. Free with ads or Paid. – Mac VOIP client. Really simple, integrates with address book + growl. However, it seemed to ‘drop’ its connection to the Asterisk server (people would call the extension and it would respond as busy despite the fact that the was on) List of phones that are supported by Endpoint Manager

Continue Reading