Skype for Asterisk howto

Here’s how you can make and receive Skype calls from Asterisk without purchasing Skype for Asterisk from Digium. We’ll use stsProxy and SipToSis. The main benefits of this method is that you can access Skype as a normal user, you don’t have to create a business user for the SIP interface needed by Asterisk, and you can have as many Skype “channels”, as you want, for free.

In this example we will use 2 Skype users with 2 channels for each user. The whole system will look like this:


You’ll need at least one sound card in your computer running Skype instances. No analog inputs/outputs are needed, it’s just used by Skype. You could also try ALSA module snd-dummy, but users reported problems with it. You’ll need Sun’s Java JRE (aptitude install sun-java6-jre). OpenJDK is not suitable. Install Xvfb and x11vnc too (this means NO X desktop is needed for this solution).

First, we have to create the Skype users in Asterisk, add to sip.conf:

[foo]
type=friend
secret=foo
host=dynamic
canreinvite=no
context=foo

[bar]
type=friend
secret=bar
host=dynamic
canreinvite=no
context=bar

To handle incoming calls from Skype, add to the extensions.conf:

[foo]
exten => foo,1,Dial(…)

[bar]
exten => bar,1,Dial(…)

For calling numbers with Skype clients, add these lines:

exten => _7.,1,Dial(SIP/foo/${EXTEN:1})
exten => _8.,1,Dial(SIP/bar/${EXTEN:1})

This way if you first press number 7 on your phone, then the phone number, the number will be dialed using Skype client “foo”. If you first press number 8 on your phone, “bar” will be used for the call.

For calling a Skype username with foo, add this:

exten => 1234,1,Dial(SIP/foo/username)

Next step: create a home directory for each Skype channel with adduser. You don’t have to give a password for these accounts since we won’t log in to them. So create four users: foo, foo2, bar, bar2 with home directories /home/foo, /home/foo2, /home/bar, /home/bar2.

Setting up stsProxy: download and extract stsProxy to /home/foo/stsproxy and /home/bar/stsproxy (we need only one instance of stsProxy per Skype user, so you have to extract stsProxy to 2 separate dirs).

Run “chmod +x stsProxy_linux” to make stsProxy’s startup script executable, and edit stsProxy.cfg. Set publicIP to your machine’s public IP (for ex. 192.168.1.1, if you are running stsProxy and Asterisk on the same localnet, also you can disable STUN, stunTestInterval=0), set via_addr to you Asterisk server’s IP.

For user “foo”, set host_port=5065, from_url=”Foo” <sip:foo@ASTERISKSERVERIP:5060>, username=foo, passwd=foo, for user “bar”, set host_port=5066, from_url=”Bar” <sip:bar@ASTERISKSERVERIP:5060>, username=bar, passwd=bar. Replace ASTERISKSERVERIP with your Asteisk server’s IP address.

Setting up SipToSis: download and extract SipToSis to each home folder (/home/foo/siptosis, /home/foo2/siptosis, /home/bar/siptosis, /home/bar2/siptosis).

Run “chmod +x SipToSis_linux” in each folder to make SipToSis’s startup script executable. Edit SkypeToSipAuth.props, comment out the last line “*,play:clips/invalidDest.wav”.

For both foo and foo2, add the new line:
*,sip:foo@STSPROXYFOOSERVERIP:5065

For bar and bar2, add the line:
*,sip:bar@STSPROXYBARSERVERIP:5066.

These settings will route the calls coming from the associated Skype client to the channel’s stsProxy.

Next, edit each user’s siptosis.cfg. Modifications needed for each user are:

foo:
skype_audioportbase=64460
via_addr=ASTERISKSERVERIP
stunServer=
stunTestInterval=0
host_port=5061
contact_url=sip:foo@SIPTOSISFOO1SERVERIP:5061
from_url=”Skype Foo” <sip:foo@STSPROXYFOOSERVERIP:5065>
username=foo
passwd=foo
audio_port=63210

foo2:
skype_audioportbase=64464
via_addr=ASTERISKSERVERIP
stunServer=
stunTestInterval=0
host_port=5062
contact_url=sip:foo2@SIPTOSISFOO2SERVERIP:5062
from_url=”Skype Foo” <sip:foo2@STSPROXYFOOSERVERIP:5065>
username=foo
passwd=foo
audio_port=63214

bar:
skype_audioportbase=64468
via_addr=ASTERISKSERVERIP
stunServer=
stunTestInterval=0
host_port=5063
contact_url=sip:bar@SIPTOSISBAR2SERVERIP:5063
from_url=”Skype Bar” <sip:bar@STSPROXYBARSERVERIP:5066>
username=bar
passwd=bar
audio_port=63218

bar2:
skype_audioportbase=64472
via_addr=ASTERISKSERVERIP
stunServer=
stunTestInterval=0
host_port=5064
contact_url=sip:bar2@SIPTOSISBAR2SERVERIP:5064
from_url=”Skype Bar” <sip:bar2@STSPROXYBARSERVERIP:5066>
username=bar
passwd=bar
audio_port=63222

Don’t forget to uncomment sample auto config with no registration!

I also edited SkypeOutDialingRules.props and set these rules for (local) Hungarian numbers:

^([0-9]{6})$:+3634$1
^06([0-9]{6,})$:+36$1
^0036([0-9]+)$:+36$1

That’s all for siptosis for now. Let’s see Skype. You’ll need the static version of Skype. Download an extract it to /usr/local/skype.

This file contains the start/stop scripts for the individual users, extract them to your home dir. There’s also a script file called looper, which you have to place in /usr/local/bin. This script makes sure Skype is restarted when it unexpectedly exists.

The start script will start an Xvfb virtual X server and a Skype instance for each user, and 2 stsProxies (one for “foo” and one for “bar”). To be able to access the Skypes, configure inetd to start x11vnc, insert these lines at the end of /etc/inetd.conf:

5901 stream tcp nowait root /usr/sbin/tcpd /usr/bin/x11vnc -inetd -q -display :1 -nopw
5902 stream tcp nowait root /usr/sbin/tcpd /usr/bin/x11vnc -inetd -q -display :2 -nopw
5903 stream tcp nowait root /usr/sbin/tcpd /usr/bin/x11vnc -inetd -q -display :3 -nopw
5904 stream tcp nowait root /usr/sbin/tcpd /usr/bin/x11vnc -inetd -q -display :4 -nopw

This file contains the init.d (Debian) scripts needed to start the whole system, extract them to /etc/init.d. After executing /etc/init.d/skypetrunk start, you’ll be able to VNC to the server on ports 5901, 5902, 5903 and 5904:



If you want to start skypetrunk on system boot, execute (on Debian, this will place symlinks in /etc/rc.x dirs to /etc/init.d/skypetrunk):
update-rc.d skypetrunk start 90 2 3 4 5 . stop 15 0 1 6 .

Click on yes for Skype API requests. You have to log in with each Skype client (same logins for foo, same logins for bar clients, one Skype client means one channel). I’m using these sound settings (my sound card is a PCI SB Live Value):



ALSA interface for speakers and ringing are both set to hw:0,0 (mic is hw:0,1).

Update: I enabled the integrated soundcard on the motherboard, now my sound settings look like this:

You may want to add the log files to logrotate. Place and edit this file in /etc/logrotate.d/.

You can find more info about SipToSis and stsProxy here.

I had a strange problem with stsProxy, it always registered in Asterisk with my WAN IP address, even though it runs on the same server as Asterisk (IP: 192.168.1.1) and I couldn’t make Skype calls. Solution: set via_addr to 127.0.0.1 or the host name of the server.

Name (required)
E-mail (required - never shown publicly)
Webpage URL
Comment:
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.

Trackback responses to this post

About me

Nonoo
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with. ... »

Twitter

Listening now

My favorite artists