// archives

voip

This category contains 12 posts

Friendly SIP URIs in Asterisk

I have typed this info into several irc privmsgs in the last month, so I’ll write up how to setup ‘friendly’ sip uris with Asterisk.

Firstly let’s look at DNS. Say my email address is abc@example.com. The A record for example.com probably points to example.com’s webserver, so that people who skip the www can still see your website. Therefore, if you don’t run Asterisk on the web-server, how do you redirect packets to your voip server ?

The answer is the service (SRV) record. If example.com’s voip server was ‘voip-in.example.com’, your SRV record would look something like this :

_sip._udp IN SRV 1 0 5060 voip-in.example.com.

You then need to configure Asterisk to handle the sip packets properly. The default domain on this asterisk box is probably ‘voip-in.example.com’. Fortunately, multi-domain support is pretty easy, you just have multiple ‘domain’ lines, thus :

domain=example.com,visitors

…which would send requests for abc@example.com to the ‘abc’ extension in the [visitors] context in your dialplan.

The easy thing to do here is to just force requests to for the email-form sip uris to ‘goto’ the right section of the dialplan in your ‘normal’ phone dialplan, e.g.

[visitors]
exten => abc,1,Goto(default,1001,1)

This avoids lots of duplication. Ensure that your default/unauthenticated sip contexts do not allow access to your pstn gateway!

Alternative to ‘ringing’ tone in Asterisk

Haven’t posted a little tip to my blog for a little while, so here goes.

When people call me on my preferred number, I have it call my desk phone, the land-line via an ATA, my mobile via sip if I am at home, and should that not work, my mobile via GSM after five seconds of no answer in the home.  To stop people giving up listening to the ring-tone whilst the phone connects to my mobile I decided to replace the ring-tone with some music, using the built in music-on-hold feature in 1.4.
You can do all of this within the default sounds which come with Asterisk 1.4, including a snippet which says, “Please hold whilst I try to connect you to the person you are trying to reach.”

The magic to make it work is similar to :
exten => x,1,Answer()
exten => x,2,Playback(followme/pls-hold-while-try)
exten => x,3,Dial(SIP/spa&SIP/deskphone&SIP/mobile,55,m)
[drop your voicemail options after this]

The ‘pls-hold-while-try’ is a default sound which ships with 1.4.  The magic configuration which says to play music on hold instead of the ring is the ‘m’ option in the ‘Dial’ command.  You can turn a stereo mp3 into something which will play as music on hold with the ‘sox’ command (there is a Debian package of the same name).
sox -V musiconhold.mp3 -r 8000 -c 1 musiconhold.gsm resample -ql
Then just drop this gsm file into /var/lib/asterisk/moh/  (change /etc/asterisk/musiconhold.conf if this is no good).

SER 0.9.6 and MySQL 5.0

This describes a problem that I reported to the SER developers mailing list, and from the replies, I don’t think this will be fixed soon, hence this post for the search engines to find.

The SER plugin which supports MySQL does not build against current 5.0 versions, complaining ‘undefined symbol _pure_virtual’. Fixing that earns you a similar error, ‘undefined symbol: log’.

The fix is easy, you need to change the Makefile and add links to mygcc and maths libraries – change line 20 of the Makefile (current ver 1.26.2.1) from ‘-lmysqlclient -lz’ to ‘-lmysqlclient -lz -lm -lmygcc’

The Snom 360 and Asterisk

I replaced my — not very good — imported VOIP handset with a Snom 360. Conveniently, the Asterisk sip.conf has a loose default user for SNOM defined, but it’s not perfect, and certainly didn’t let me use the SNOM and voicemail properly.

Firstly, the DTMF mode must be rfc2833, and not inband as indicated. Inband meant that called parties (e.g. voicemail applications, IVRs) can’t “hear” the dtmf even though you can on the snom..

snom-360-mwi.jpgSecondly, the Message Waiting Indicator settings – to make them work you need both a ‘mailbox’ entry, and there must have been a voicemail left in the box to create it. If the box has never had a message before, you will see 404 messages bursting through your sip debug screens in Asterisk.

When you get it all working, it looks a bit like the image, including a voicemail count. The MWI actually flashes.

To make the VM retrieve button work, you need a vmexten=xx line in your sip.conf. The following config works with Asterisk 1.4 and the SNOM 360.

[andysnom]
type=friend
context=default
secret=heregoesthepassword
host=dynamic
dtmfmode=rfc2833
username=andysnom
mailbox=1001
vmexten=500
disallow=all
allow=ulaw
regexten=1001

Going to enjoy playing with the other features on this phone..