Saturday, September 28, 2013

Custom Caller ID Names with Google Voice, OBi202, OpenCNAM and YATE (part 1 of 3)

In this series: Part 1 | Part 2 | Part 3

If you are not already aware, Google will be making changes in May, 2014 that will break compatibility with Obi devices and Google Voice. Some or all of this document may not be applicable after that time. (http://blog.obihai.com/2013/10/important-message-about-google-voice.html)

Update 9/11/2014 - Obi + Google Voice now supported again!

Introduction

When using Google Voice as your primary phone with the OBi202, incoming caller ID consists only of a number, but not a name. In a previous post I described one way around this, which was to subscribe to another VOIP service that offers CNAM and then forward your Google Voice there. This method is reasonably easy to configure, but I wanted more.

Inspired by the idea in this forum post I set out to install my own SIP server and write my own caller ID name lookup module. The idea behind this is that the incoming Google Voice call will be initially handled by the OBi202 (via Google Chat which is turned on), forwarded by the OBi202 to a VOIP server that I run for caller ID CNAM data to be added, and then forwarded back to the OBi202 to ring the attached phone(s).

I'll fast forward to the end result, which is seen here, when I call my "home phone" from my cell phone:


No, this is not spoofing caller ID or doing anything uncouth to any public phone line. This caller ID name was generated on my internal network -- my server simply ignored the name that is publicly associated with my phone number and displayed what I wanted on the handset, just like any internal PBX system does. No hacking, cracking, spoofing, or other questionable activity required. (If you want to change the name displayed to others when you call them, contact your telephone provider.)

Prerequisites

In order to do this:
  1. You need the OBi202 configured and working with your Google Voice account.
  2. You need to know how to configure your OBi202 using the manual "expert" mode.
  3. You need one unused "service provider" slot and one unused "voice services" slot on your OBi202.
  4. You need a Linux server that's going to be running 24x7 -- either physical or virtual would be fine, and the telephony software can coexist with other software (e.g. mail server, DNS server, or whatever you happen to be running). This server needs a static IP address, and I'd strongly suggest it be connected to a UPS.
  5. You need some basic Linux sysadmin skills to be able to move around the shell and accomplish the instructions in this tutorial.
You do NOT need Anveo (as described in my previous post) or any other non-Google Voice VOIP provider. Note that I am keeping Anveo to provide 911 service, but I've dropped the "incoming call" plan described in that post.

Overview

Here's what you are going to accomplish:
  1. Install and configure YATE
  2. Configure your OBi202 to forward calls to YATE
  3. Create and configure a custom Caller ID lookup module for YATE

Install YATE

YATE stands for Yet Another Telephony Engine. It's an open source project found here: http://yate.null.ro/pmwiki/

YATE is a replacement for Asterisk, FreePBX, and similar systems. I was starting fresh without any experience with telephony systems. I chose YATE because it is light weight and also because I found someone who had documented part of the setup I was trying to accomplish.

I use Ubuntu and used the wildfire PPA mentioned on YATE's download page. On Ubuntu the install went like this:

$ sudo add-apt-repository ppa:wildfire/yate
$ sudo apt-get update
$ sudo apt-get install yate yate-core

The version I got at the time of this writing was 4.3.0-1~dfsg-1wf3.

There are downloads available for RHEL/CentOS also, and source code to compile it yourself on any Linux. Be aware that your directory paths may vary.

Configure YATE

This thread on the YATE forums had information about the configuration that was needed to make this work. Follow the instructions there to modify these two configuration files:

/etc/yate/regexroute.conf

[general]
prerouteall=yes

[contexts]
.*=;rtp_forward=yes

[default]
; Route sip call back to the source
${module}^sip$=sip/sip:${caller}@${ip_host}:${ip_port}

/etc/yate/ysipchan.conf:

[general]
forward_sdp=yes

To connect the OBi202 to YATE you'll need a username and a password, which you will create at this time. The username goes in the brackets and the password goes on the next line. You'll need this username and password when you configure your OBi202 device later. Note that your password is stored here in plain text, so you need to choose something that you don't use elsewhere (e.g. your banking, e-mail, etc.). Don't just copy this - make up your own username and password!

/etc/yate/regfile.conf

[obi202user]
password=obi202password

Configure YATE Startup

The init scripts make some assumptions about where the PID file and log file should be written, and those assumptions don't work when the process is running as a user other than root. I prefer to run the daemon as a non-privileged user. To do this I created a directory for YATE to stash its log and PID file:

$ sudo mkdir /var/yate
$ sudo chown yate:yate /var/yate

I can now configure the startup configuration script, which is /etc/default/yate on Ubuntu:

# Defaults for yate initscript
# sourced by /etc/init.d/yate

# make this read NO_START=0 when you're done setting up your config.
NO_START=0

# Additional options that are passed to the Daemon.
PIDFILE="/var/yate/yate.pid"
DAEMON_OPTS="-d -rs -l /var/yate/yate.log -Dfu -v"
YATE_USER="yate"
YATE_GROUP="yate"

With that file in place, I am able to start and stop YATE using its init script. It's worth testing this at this point to make sure it works.

$ ps -ef | grep yate | grep -v grep
$ sudo service yate start
$ ps -ef | grep yate | grep -v grep
yate     20523     1  0 23:49 ?        00:00:00 /usr/bin/yate -p /var/yate/yate.pid -d -rs -l /var/yate/yate.log -Dfu -v
yate     20524 20523  7 23:49 ?        00:00:16 /usr/bin/yate -p /var/yate/yate.pid -d -rs -l /var/yate/yate.log -Dfu -v
$ sudo service yate stop
$ ps -ef | grep yate | grep -v grep
$ sudo service yate start

Configure Linux


iptables firewall

Since I run iptables on all my Linux systems, I had to configure things to allow traffic to port 5060/udp from my OBi202. (I strongly suggest you run iptables to limit network access to your system, especially if you're putting it on the internet. You don't need this YATE server accepting SIP connections from the internet if you're only seeking to accomplish the setup I'm documenting here.)

Automatic start

The Ubuntu packages included the initialization scripts for YATE so that it starts on boot. If you used a different installer or a different flavor of Linux, you'll want to double-check that the YATE processes start on boot. (If your server isn't being used, you could reboot it just to double check that YATE starts automatically. However a reboot is not required now, or any time later, to activate YATE.)

Conclusion

Congratulations - you now have a YATE server up and running. Continue to Part 2 of this series to configure your OBi202 to route Google Voice calls to your YATE server.

No comments:

Post a Comment