People Communicate

Microsoft Unified Communications Blog

Microsoft Lync 2010, Asterisk and Skype installation and integration guide

Trixbox is a great distribution of Asterisk, however it does break certain Asterisk standards and you can’t beat a good command line – yes in Asterisk’s case the command line is easier than a web interface.

So why not plain old Asterisk? AsteriskNOW makes light work of the install and I’m by no means a Linux guru! You can still opt for the FreePBX front end – but we will choose to not go down this dark path – trust me on this!

So let’s talk objectives…

  1. Setup AsteriskNOW, configuring a SIP extension and corresponding dial-plan
  2. Install and configure Skype for Asterisk (SFA), ensuring the SIP extension above can route in/out
  3. Take the Lync 2010 Server install performed here and integrate it with AsteriskNOW
    • Make calls to and from the Asterisk SIP extension (Lync & SFA)
    • Make calls to and from the Lync client (SIP & SFA)

So here is an idea of how this will all piece together:

clip_image002

Sounds like a tall order right? Wrong. With AsteriskNOW and Lync Server 2010, it is reasonably straight forward and I will endeavor to document the end-to-end setup process.

Before I begin let me talk about SFA…

Skype as you may or may not be aware offers two SME level VoIP integrations:-

  1. Skype for SIP (now re-branded as Skype Connect) – essentially a way of integrating Skype’s cloud of PSTN in/out connectivity including the capability to call Skype users (22.5k online as I type) to an SIP enabled IP PBX – for supported vendors see here.
  2. Skype for Asterisk (SFA) – an add-on Asterisk channel driver which allows for Skype-to-Skype calls and access to Skype’s as cheap calling rates via your Asterisk end-point.

If you are already running an Asterisk based PBX you will probably want to know the difference. From a high level it comes down to the following:-

  1. Cost – Skype Connect is subscription-based, you pay $6.95 per channel plus calling costs – not cheap for those who want to use this for a lab sized implementation.
  2. Functionality – SFA is not channel-based, it is user-based, for a one off charge of $66 you get a single user license – sounds a bit more digestible, right? A single license would give you one channel. In this guide we will enable a single license be configured to route out from either SIP or Lync end points. From an inbound perspective you could create a Lync response group or Asterisk call group to broadcast inbound calls to multiple users.

One (or should i say three?) last caveat before we get on with the good stuff:-

  1. Lync is currently in release candidate, it is unlikely to change on a grand scale, but be aware it is not supported by Microsoft
  2. Lync (or OCS) + Asterisk integrations are not supported by Microsoft
  3. This is a “just for fun” guide or lab setup only

Okay, with that over with let’s look at requirements

  1. I’ll be using Windows Server 2008 R2 with Hyper-V to run Lync Server 2010 RC & AsteriskNOW
  2. I have assigned 2gb of memory to Lync Server 2010 RC and 512mb to AsteriskNOW (I know this seems minimal but it is enough for this small test setup)
  3. You’ll need to setup a Skype business account as SFA will not work with regular consumer accounts (you can route Skype-to-Skype calls between business and consumer accounts)
  4. Once you have setup a free Skype business account you’ll need credit as without credit it won’t route out to PSTN. I suggest you test the account by adding it to a Skype software client first (if you hit any roadblocks further down the line you’ll be pleased to have ruled this potential issue out)
  5. Buy an SFA single channel license which can be purchased directly from Digium, the makers of Asterisk, via their online store (currently at $66) – you’ll get a license key that we will activate later…

Let’s begin…

Download a copy of AsteriskNOW, I have opted for the 64-bit version here, whilst this is downloading (it is approximately 600mb), let’s setup our VM.

Create a name:

clip_image004

Set memory:

clip_image006

Don’t connect it to your virtual network, we’ll need to create a legacy network adaptor as we are using Linux

clip_image008

I’m going to accept the default options when configuring my virtual disk (this isn’t usually recommended for performance, but for AsteriskNOW it’ll be sufficient)

clip_image010

Once your bootable AsteriskNOW ISO is downloaded, select this as the operating system to boot from within Hyper-V Manager

clip_image012

Our summary, click Finish

clip_image014

Before we kick off the install, you’ll need to go to your settings and add one hardware component, the legacy network adaptor mentioned earlier – and make sure this is connected to your virtual network

clip_image016

Let’s start our VM! Fingers-crossed the AsteriskNOW ISO will boot and the install commences, select option 5 – Asterisk 1.6 only (we need Asterisk 1.6 for TCP support, a SIP trunk requirement for OCS and Lync)

clip_image018

Select yes, to accept the creation of partitions and wiping of data

clip_image020

The default partition scheme is fine, select next. Set your region, select next and create a root (or Administrator) password then click next.

clip_image022

The install will now commence, in my case I’m going to grab some breakfast…!

clip_image024

I’m back and the install is complete, eject your ISO via the Hyper-V toolbar, Select Media -> DVD Drive -> Eject. Then click reboot

clip_image026

During the boot sequence you’ll see a ton of text, which will all (hopefully) end with [   OK   ]. Upon completion you will see a Setup Agent, quit this and you will be presented with the screen below.

clip_image028

Login with your root account and start the network configuration utility, type system-config-network. You will then be presented with the screen below

clip_image030

Edit your network device “eth0 – Digital Equipment Corporation DECchip 21140 [FasterNet]“, remove the DHCP option and set a static address, in my case 192.168.10.30

clip_image032

Save and now edit your DNS configuration. In my case I have a local DNS server (192.168.10.253) but set this to suit your needs. I have also set my host name as ast.jacobs.local (jacobs.local is my local domain name) and set the search to my local domain. Then Save & Quit.

clip_image034

Once you are back to the command line type: shutdown –r now this will result in a reboot of the system. Once the system has completed a restart, login again as root. You should now be able to ping from this system to another address on your local network including the Internet (to check this, ping www.bing.com to ensure internet connectivity is working) – if you can’t then something has gone wrong! In some cases I have found that you need to head back into the network settings and re-input the DNS, this issue shouldn’t re-occur.

Now you are back to your Asterisk command line, type yum install register, you’ll be prompted to download the package, accept this by inputting Y and hitting enter. YUM is an abbreviated word for Yellow dog Updater Modified, it is a command line package management tool. The Register package is used to activate your SFA license.

clip_image036

Next we’ll update our version of AsteriskNOW, type yum update asterisk16, accept the upgraded packages (as detailed within our previous step)

clip_image038

Once completed, we’ll install SFA, type yum install asterisk16-skypeforasterisk, accept the package download. Once installed reboot, type shutdown –r now.

clip_image040

Once the reboot has completed login and we’ll register the SFA module (using the license key received from Digium). Login as root and type, register. Select option 1 (Digium Products), then option 7 Skype for Asterisk. Next you will be prompted to enter you SFA key, enter the key and register now. Click the space bar to run through the license agreement (does anyone read these?) and accept the agreementComplete your personal details and your license should be written to /var/lib/asterisk/licenses/ (you should back this up – I’ll explain this next). But one last reboot first, type shutdown –r now, our Asterisk install is now complete, next we’ll need to configure it!

clip_image042

To configure our Asterisk PBX we need to edit a number of text files, there are Linux-based editors, but in my experience they are not that user friendly and I like to perform this remotely using my friendly Windows PC, to do this you need an SSH client – I use WinSCP. Download a free copy via their website here. Once installed add a new site (see below)

clip_image044

Then change the default remote directory (as per the illustration below) and save the site.

clip_image046

Once saved click login. The first time you connect you will be prompted to save your Asterisk server key, click yes to add the host key to your cache. Finally enter your password, once connected an explorer type view of your Asterisk’s file system will be displayed – I have changed to a detailed view (choose view -> details)

clip_image048

Back-up your SFA license by copying the file from /var/lib/asterisk/licenses – there should only be one .lic file in there, just right click and copy to your desktop to save locally. Now head back to the folder /etc/asterisk – this is where our Asterisk config files are located.

We will be editing three files: (right click and “edit” within WinSCP)

  1. Sip.conf – for main Asterisk settings (trunks/extensions)
  2. Extensions.conf – for dial plans
  3. Chan_skype.conf – SFA settings

First sip.conf, replace the content of your file with the following settings (you should probably backup your original conf files before)

[general]

context=default ; Default context for incoming calls

allowoverlap=no ; Disable overlap dialing support. (Default is yes)

udpbindaddr=0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)

bindport=5060

bindaddr=0.0.0.0

tcpenable=yes ; Enable server for incoming TCP connections (default is no)

tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)

srvlookup=yes ; Enable DNS SRV lookups on outbound calls

notifyhold = yes ; Notify subscriptions on HOLD state (default: no)

[1001] ; A locally attached SIP extension

type=friend

callerid=1001

canreinvite=no

dtmfmode=rfc2833

mailbox=1001

disallow=all

allow=ulaw

transport=udp

secret=password

host=dynamic

context=default

[Lync_Trunk] ; Our Lync trunk

type=friend

port=5068 ; This is the default Lync Server TCP listening port

host=192.168.10.29 ; This should be the IP address of your Lync Server

dtmfmode=rfc2833

context=from-lync

qualify=yes

transport=tcp,udp

Next extensions.conf, replace the content of your file with the following settings

[general]

static=yes

writeprotect=no

[globals]

[default]

;dialling other extensions starting with 1 followed by three digits

exten=>_1XXX,1,Dial(SIP/${EXTEN},20)

exten=>_1XXX,n,hangup()

;send every digit after 9 to Skype for Asterisk

exten=>_9.,1,Dial(Skype/${EXTEN:1},20)

exten=>_9.,n,hangup()

;dialling other extensions starting with 2 followed by three digits

exten=>_2XXX,1,Dial(SIP/Lync_Trunk/${EXTEN},20)

exten=>_2XXX,n,hangup()

[from-lync]

;dialling other extensions starting with 1 followed by three digits

exten=>_1XXX,1,Dial(SIP/${EXTEN},20)

exten=>_1XXX,n,hangup()

;send other calls to Skype for Asterisk

exten=>_.,1,Dial(Skype/${EXTEN},20)

exten=>_.,n,hangup()

This dial plan will enable call routing between Lync , Asterisk & SFA. Finally configure your chan_skype.conf

You will need to change the default_user to represent your Skype ID, in my case:

;default_user=james_bond changed to (general section)

default_user=imapcblog

update the password

;secret=goldeneye changed to (user section)

secret=myskypepassword

change the default context to match your dial plan

;context=demo changed to (user section)

context=default

route the inbound calls to your Lync extension, in my case 2001

;exten=s changed to (user section)

exten=2001

Once you have configured all three config files reboot Asterisk, type shutdown –r now. Congratulation, your Asterisk configuration is complete! Next we need to configure Lync and pre-supposing you followed my previous Lync install guide here, you will need to head back into the Lync Topology Builder – we didn’t add a PSTN gateway previously. Download your Topology from the existing deployment and save the file locally, then add a PSTN gateway (see both steps below)

clip_image050

clip_image052

Once you have added the PSTN gateway you will have to re-publish the Topology, this will update the existing Topology with the new configuration settings, click finish

clip_image054

To permit call flow between both Lync and Asterisk worlds we need to define our Voice Routing within Lync Server 2010. Open the Lync Server Control Panel and access the Voice Routing options, we’ll need to configure our Dial Plan, Voice Policy, Route and PSTN Usage. I won’t walk you through this configuration (some is based upon location preferences, in my case UK), but I will show you the resulting configuration within the Lync Control Panel.

First the dial plan summary (pay close attention to my normalization rules) – this will route 1xxx to Asterisk, +44xxxxxxxxx to Asterisk and 2xxx internally (treated as local extension)

clip_image056

Next the Voice Policy, the default Global Policy should have the following PSTN usage records (these rules will handle our calls destined for Asterisk)

clip_image058

and the routes, as follows

clip_image060

Finally the PSTN usage, as follows

clip_image062

In my previous guide we created a test user, that user should now have his or her telephone details set, in our scenario tel:2001 (this is not best practice in a production deployment of Lync/OCS, but as a lab setup with a single PSTN number we should be given a free pass!) typically in production we would assign individual PSTN number and normalize to an internal DDI range i.e. +44208 555 2001 would normalize to 2001 when dialed.

clip_image064

With these settings committed successfully your setup should be complete, calls can now be made between both Asterisk and Lync, to setup a SIP based client I recommend X-Lite (for download and setup instruction follow my previous guide here)

Here we can see X-Lite to Lync

clip_image066

And the reverse Lync to X-Lite

clip_image068

Finally, let’s SkypeOut, first from Lync! (this illustration won’t mean a lot, but you will have to trust me – it works!)

image

That’s it, whilst I’m sure there are better ways of achieving PSTN breakout from OCS or Lync (with hardware/gateways), there is a certain amount of self-gratification from 100% software based VoIP.

I’m sure my configuration could have been applied in a number of different ways and you’ll probably notice that whilst X-Lite will permit Asterisk-to-Skype calls (dial 9 + Skype name), at this time Lync will not – only numbers can be passed (I’m happy to take suggestions on this). Otherwise let me know if you have spotted any errors or need guidance on issues (I’ll be moderating the comments below) and above all good luck and have some fun!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: