Showing posts with label Asterisk. Show all posts
Showing posts with label Asterisk. Show all posts

Friday, August 26, 2011

Asterisk disk full

Just after my last class today I though I'd copy the asterisk box from the presenter machine to my backup drive. I was shocked to see a 44GB file! Obviously there was some logging problem bloating the hard disk, but it was not asterisk's log files under var/asterisk but instead core files found in tmp.
These core files are effectively memory dump files created by CentOS when Asterisk mibehaves and crashes. I had 43 GB worth of dump files already. The problem is, that simple errors in your sip.conf can cause Asterisk to crash and restart and subsequently crash, going on until your HDD is full of dump files.
I found a easy post on how to control the core dumps here:
http://aplawrence.com/Linux/limit_core_files.html

But that only combats half the problem. The main part was why was asterisk is crashing so often. the answer lied in my case in the qualify=yes entries in my sip.config. If the Lync Mediation server does not expect to respond to the gateway (topology not published yet, Mediation Service not restarted) or is not online at all then the qualify will fail. Worse even, it will crash my Asterisk 1.6 box causing those dumps to quickly fill up the HDD (50MB per dump). So setting qualify=no has helped me keep my asterisk box more stable between my demonstrations.

Thursday, June 23, 2011

Using 2talk SIP Provider with Lync

yesterday I posted about using Asterisk with Lync. Today I will share my configuration files for getting 2Talk up and running with the latest version of Asterisk 1.6:
Effectively there are two configuration files you need to worry about. The sip and the extensions files.
The sip.conf file specifies the different sip trunks and authentication mechanisms. The extensions.conf is your dialplan, which can be the trickiest to get working. Below are my versions (passwords removed)

sip.conf:

[general]
registerattempts=0
registertimeout=20
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

;register 2Talk number to receive incoming calls (replace placeholders with values, remove brackets)
register => :@2talk.co.nz/

[1001] ; A locally attached SIP extension (in my case an X-Lite client)
type=friend
callerid=1001
canreinvite=no
dtmfmode=rfc2833
mailbox=1001
disallow=all
allow=ulaw
transport=udp
secret=password
host=dynamic
context=default



[2talk]
type=friend
username=
fromuser=
secret=
host=2talk.co.nz
context=from-2talk ; going to use this in extensions.conf
dtmfmode=rfc2833
disallow=all
allow=ilbc
allow=gsm
allow=alaw
allow=ulaw
;allow=g729 ; only if you have licenses to use it
nat=yes
canreinvite=no
insecure=invite,port ; use insecure=very in earlier versions of Asterisk such as v1.2


[Lync_Trunk] ; Our Lync trunk
type=friend
port=5068 ; This is the default Lync Server TCP listening port
host= ; This should be the IP address of your Lync Mediation Server
dtmfmode=rfc2833
context=from-lync
qualify=yes
transport=tcp,udp

extensions.conf

[general]

static=yes
writeprotect=no

[globals]

[default]
;calls to a 4 digit extension starting with one are routed directly via SIP to local phones
exten => _1XXX,1,Dial(SIP/${EXTEN},20)
exten => _1XXX,2,hangup()

; outbound calls (outside of your own PBX) (only used for internal phones, not calls originating from Lync)
exten => _0.,1,Dial(SIP/${EXTEN:1}@2talk)
exten => _0.,2,hangup()

;calls coming in locally going to a 4 digit number starting with 2 are redirected over the Lync trunk
exten => _2XXX,1,Dial(SIP/Lync_Trunk/${EXTEN},20)
exten => _2XXX,2,hangup()

[from-lync]
;dialling other extensions starting with 1 followed by three digits are sent locally
exten=>_1XXX,1,Dial(SIP/${EXTEN},20)
exten=>_1XXX,n,hangup()

;send other calls to 2talk for Asterisk (no prefix here as Lync will probably have its own dialplan)
exten => _.,1,Dial(SIP/${EXTEN}@2talk)
exten => _.,2,hangup()


[from-2talk]
;send incoming calls on your 2talk number to a Lync Extension
exten => _X.,1,Dial(SIP/Lync_Trunk/2001)


That's it folks! Try using the two configurations with your 2talk SIP provider, add your own number, secret and Lync IP address and start making and receiving calls over Lync.

Tuesday, June 21, 2011

Using Asteriks with Lync 2010

Next week I am teaching how to install and configure Lync using the material provided in the course10533 from Microsoft. Although the course has some great stuff, it misses out on the really juicy bits. Setting up a PSTN connection for example.
I simply could not resist setting it up for myself. After some digging I found this GREAT! Post by Adam:
http://imaucblog.com/archive/2010/10/09/step-by-step-microsoft-lync-2010-asterisk-and-skype-installationintegration-guide/

But then I need to get my Virtual machines connected to the internet! Now ICS has proven to be rather icky. And Bridging really mucks things up. So in the end only a good ol Routing Service would do the trick.
John Paul has a nice article on how to configure Hyper-V to route traffic to your wireless adapter:
http://sqlblog.com/blogs/john_paul_cook/archive/2008/03/23/using-wireless-with-hyper-v.aspx

WARNING! Skip the first quarter of the screenshots where he shows bridging. don't wanna do that. jump down to where he starts talking about RRAS

Once I had routing set up and could connect to the net using the private ip-ranges I wanted, I was ready to install Asterisk using Adam's instructions.

Some tips for getting it all running:
No need to buy Skype Plugin if you wanna use sip. I used 2talk and am happy with the results. For the detailled config for 2talk try this page:
http://blog.2talk.co.nz/asterisk.html

IK found a mix between the settings from Adam and the ones from 2talk worked best.

WARNING! A typo or bad rule can send your Asterisk server into an endless crash loop. To fix that, copy the 2talk configurations back into the files and start over again.

Some helping commands I used along the way on the Linux box:
ifconfig (set a new IP address)
route (add a default route to connect to Gateway)
ping (test ip connectivity)
nslookup (test dns server connectivity)
ifconfig and route take effect immediately on the linux box. The changes made via the network setup program only come to life on the next reboot (which took about 5-10 minutes each time)
 
asterisk -r (connect to asterisk console)
  reload (reload all configs)
  diaplan reload (reload only the dialplan)
  sip show peers (see what routes are setup and working)

And as I hate using the command line editor, downlad a browser/editor for Windows ASAP, such as WinSCP: http://winscp.net/eng/download.php
You will need that editor to edit the /etc/asterisk/sip.conf and /etc/asterisk/extensions.conf files

Whenever you make a change to sip.conf or extensions.conf make sure to run the reload command in asterisk again.
Also, staying logged in to Asterisk will show what is going on and is useful when debugging conversation attempts.
Finally, try getting it working step by step.
1) connect X-Lite to SIP provider via Asterisk
2) connect X-Lite to Lync
3) connect Lync to X-Lite
4) connect Lync to SIP provider
Step 1 should be your priority. Once that works the rest falls into place.


Happy configuring. Having it all working is an exhilerating feeling. you'll know what I mean once you have made your first Lync phone call to a real land line.