Using Asterisk to pass and receive SIP calls from Microsoft OCS to a SIP Trunk in UDP
Enabling Any SIP Phone & Any SIP Trunking Service Provider with OCS 2007 R2 !
Goals of the demo :
Use asterisk like a UPD/TCP translator between OCS and a SIP trunking services in UDP mode.
- make calls from Microsoft Office Communicator to the sip trunk
- dial froma external mobile or a PSTN phonetrough the sip trunk and answer the call on eithera hard or soft phone or Office Communicator.
- control forwarding and simultaneous ringing options from the Communicator
I use Asterisk 1.6 which support TCP and UDP installed on CentOS 5 – Kernel 2.6.18
Installation steps :
-
Add a mediation server to the OCS infrastructure
-
Add an asterisk server
-
Configure Mediation server to use the asterisk box
-
Resolve NAT problem (if needed)
-
Create two SIP trunks :
- Asterisk to OCS
- Asterisk to SIP Trunk service
-
Define the context used by this trunks
-
Configure follow me
-
Test the infrastructure
Basic schema :
OCS R2 —- Mediation —- Asterisk —— Firewall — SIPTrunk
MTLS —- TCP —- UDP —- NAT —– UDP
I use Hyper-V for the two OCS servers and VMware for the Asterisk server.
Step-by-steps
Step 1 : Add a mediation server to your infrastructure
-
Install a mediation server
-
Configure certificate
-
Add the OCS reskit tools (useful for troubleshooting)
-
Create a dial plan
-
Create a location profile with two normalization rules.
The first will be use for internal numbering and the second is a generic rule that redirect all call that do not correspond to a valid extension number in OCS to the default gateway.
-
Internal : OCS user have an three digit extension beginning by 2
Phone pattern : ^2(\d{2})$
Translation pattern : +2$1
-
Generic rule : All number are concerned (be careful to put this rule in second position in your location profile)
Phone pattern : ^(.*)$
Translation pattern : $1
Assign the location profile to the front-end server (properties of the pool / properties of front-end / Voice Tab)
NB : Test your dial plan using the Enterprise Voice route helper
Step 2 : Add an asterisk server
-
Download trixbox 2.2 Virtual Appliance from VMware website http://www.vmware.com/appliances/directory/939
-
Configure basic settings (Ip address, ..)
-
Add this line in the begining of sip.conf
tcpenable = yes
bindport = 5060
-
Access the web Trixbox interface (use Mozilla) In system menu / Network / Configure IP, Subnet, DNS and a valid hostname on internet : Ex : sip.mydomain.com
Step 3 : Configure Mediation server to use the asterisk box
- Open the properties of your mediation server verify that :
- in General tab : the gateway listening port is 5060
- In next hop connections tab : put the IP address of your asterisk server in PSTN gateway next hop with 5060 for the port number
Step 4 : Resolve NAT problems (if needed)
- In Asterisk, Go to PBX / Config File Editor / and edit SIP_NAT.conf
nat=yes
externip=Valid_FQDN
localnet=Your_Localnet/Your_Subnet
- Open in your firewall port
- 5060 in UDP and TCP for SIP
- RTP: 10000 to 20000 UDP
- Verify that you can see you valid public IP in the Trixbox system status
Step 5 : Create two SIP trunk in Trixbox : asterisk to OCS and Asterisk to SIP Trunk service
- Asterisk to OCS
Trunk Name : ocs
PEER Details :
host=ip-mediation-server
type=peer
qualify=yes
transport=tcp
insecure=very
port=5060
canreinvite=yes
fromdomain=yourdomain
context=from-ocs
Incoming Settings :
User context : (I put a OCS username here)
User details :
host=ip-mediation-server
type=peer
transport=tcp
insecure=very
port=5060
context=from-ocs
register string :
(leave blank)
-
Asterisk to SIP Trunk service
Trunk Name : siptrunk
PEER Details :
type=friend
disallow=all
allow=ilbc&speex&gsm&alaw&ulaw
username=username
secret=password
host=yoursipregistrar
canreinvite=no
context=from-siptrunk
Incoming Settings :
Clear all
register string :
username:password@yoursipregistrar (/yournumber if needded)
Step 6 : configure context
Edit Extension_Custom.conf and add a the end of the file :
[from-ocs]
exten => _X.,1,Answer
exten => _X.,2,Dial(SIP/${EXTEN}@siptrunk,,tr)
#include extensions-away-status.conf
[from-siptrunk]
exten => _X.,1,Set(numDialled=+${EXTEN:Number_of_X_to_ignore})
exten => _X.,2,Set(__FROM_DID=${EXTEN})
exten => _X.,3,Answer
exten => _X.,4,Dial(SIP/${numDialled}@ocs,,tr)
exten => _X.,4,Dial(SIP/${numDialled}@ocs)
Step 7 : Configure follow-me in Asterisk
Assign line number from your sip trunk to Asterisk extension and redirect to phone extension in OCS by using a # after the number.
DID number from your SIP trunk provider —> Extension in Asterisk —> Follow-me to OCS extention (use # after the number to precise that it’s external to asterisk)
Step 8 : Test the infrastructure
- Troubleshooting tools that you can use in Asterisk :
- Log as root with a terminal tools (putty) / Type asterisk –r / Type sip set debug on
- Assign a line prefix to test the trunk from a softphone directly connected to Asterisk
Ex : Create a outbound route with “9|.” to test the trunk by dialing 9 before the number
- Troubleshooting tools that you can use in OCS :
- Eventviewer
- Use the Debug tools (right click your mediation server)
- MS Netmon
- OCS Route helper to validate your dial plan.
Have fun with that and leave me a message if encounter some problems!
It’s probably possible to do the same withother IP/PBX like : Freeswitch, OpenSer, SipxECS, …
Date : 04/08:2009 – Author : Yann Espanet – mail : yann@unifiedcommunications.eu
Thanks Yann. I would love to see a demonstration. We are certified Microsoft voice partner located in souther California and we would love to be able to offer this to our clients.
1Hello,
I can’t dial from OCS to Asterisk, but i can dial from asterisk to ocs
2