Monday, June 23, 2008

Wanderer's Love

It has been long while that my heart beats not
It has been so long that my love wanders
I've been searching for you everywhere
Till I find myself staring at you

I never noticed you before
But every now and then
In everyday I see you face to face
You seems to get prettier each day

Let me tell you how beautiful you are
Let me express how truly I love you
I love to see every details that you do
The way you talk, the way you smile
It's making me crazy as I get near you

Couldn't explain how I feel when I see you
How I wish you could be the right one
That my heart has been praying for
But I am too reluctant to tell you
How much I always dream of you

Friday, June 6, 2008

Route Calls from Openser to Asterisk

Last time we talked about on how to install and set up the OpenSER and to make it work. Now we're going to discuss on how are we going to integrate OpenSER with the Powerful Asterisk PBX. By the way, why do we need to integrate it anyway? OpenSER is just use as a SIP Proxy, SIP Server and can only communicate using SIP protocol and has no way to access such as PSTN lines. Another thing to mention is that it doesn't have that rich features just like what a PBX could offer. This is the point where Asterisk comes into the scene.

Now let's prepare things first for the Asterisk.

1. Create the SIP trunk where the OpenSER will connect to the Asterisk Server. We can do this in 2 ways.
Either we register the Asterisk server as a SIP UA to OpenSER or we will statically declare a SIP trunk to the Asterisk Server. So we will choose the latter.

Edit sip.conf using your favorite text editor (for me it's vi)

# vi /etc/asterisk/sip.conf

[openser]
type=friend
context=incoming
host=192.168.2.235 ; replace this with the IP address of your SIP server (OpenSER)
fromdomain=192.168.2.235 ; same thing here
insecure=port,invite

# vi /etc/asterisk/extensions.conf

[incoming]

exten => 205,1,Dial(SIP/205,60) ; note that the UA 205 is registered on the Asterisk server not on the OpenSER
exten => 205,n,Hangup

Offcourse you have to reload asterisk so the changes would take effect then

2. Alright now it's time to tweak our OpenSER.

# vi /usr/local/etc/openser/openser.cfg

;note that we're using the default configuration of openser ( we'll discuss on our future tutorial on how to make use of the sipwise wizard )

;look for this line

if (is_method("INVITE")) {
setflag(1); # do accouting

}

;make it like this one

if (is_method("INVITE")) {
setflag(1); # do accouting

if (uri=~"sip:205@192.168.2.235")
{
route(2);
}

}


Hey what does this stuff mean??

Let me explain everytime a SIP UA initiate a call it sends an INVITE message sending also the uri being requested in our case it is "sip:205@192.168.2.235". Again change the IP here with the IP of your SIP server. Here I've used static value '205' but you can actually make use of pattern matching here say for instance all numbers beginning with 1 followed by 1 or 2 we can represent this by "sip:1[1-2]@192.168.235"

What's the next stuff?

route(2) ====> this one refer to a routing block which contains lines of rules

so we have to add at the end of the file the following to define our route(2). Here's how?

route[2] {

rewritehostport("192.168.2.2:5060"); # change the IP here with the IP of your Asterisk Server
t_relay();
exit;
}

3. Offcourse you have to reload or restart OpenSER

4. Now you're done and let us test the things that we have done.

register a SIP UA to Asterisk Server with username 205
register a SIP UA to OpenSER with username of what you like (Please refer to my previous tutorial on how to add new UA subscriber)

Using your phone registered to OpenSER dial 205.....

It should now ring the local extension registered on your Asterisk Server. :-)

5. Same principle I guess to use if you want to route your PSTN calls from OpenSER to your Asterisk PBX which is capable to access PSTN network.

Okey that's all for this tutorial. I just hope that you find it useful.

CHeers!!!!!! Take Care and God Bless!!!!

Tuesday, June 3, 2008

Getting Started with OpenSER: INSTALLATION OF OpenSER on Linux ( CentOS )

INSTALLATION OF OpenSER on Linux ( CentOS )

1. First install the following dependencies that will be needed to compile OpenSER sources:

- bison
- flex
- mysql
- mysql-devel
- subversion (if you intend to use subversion to get its sources

*you can install the said sources via tarballs or rpms or via yum which I did :-)

2. Now get the source OpenSER package ( I get the latest one which is 1.3.x)

svn co http://openser.svn.sourceforge.net/svnroot/openser/branches/1.3 sip-server

or via

wget http://www.openser.org/pub/openser/latest/src/openser-1.3.2-tls_src.tar.gz

3. Unzip and extract the files

tar xvzf openser-1.3.2-tls_src.tar.gz

4. cd to the source directory

cd openser-1.3.2-tls

5. Do following for compilation and installation

make clean
make all include_modules="mysql"
make prefix=/usr/local install include_modules="mysql"

6. Now edit first openserctlrc

vi /usr/local/etc/openser/openserctlrc

uncomment the line that says

DBENGINE=MYSQL

7. Now we can create the database for the OpenSER

/usr/local/sbin/openserdbctl create

*Note that upon execution of this command it will create 2 users for OpenSER

8. Now we wil edit first the openser.cfg to enable MySQL support.

vi /usr/local/etc/opernser.cfg

You will have to uncomment the following lines:

- loadmodule "/usr/lib/openser/modules/mysql.so"

- loadmodule "/usr/lib/openser/modules/auth.so"

- loadmodule "/usr/lib/openser/modules/auth_db.so"

- modparam("usrloc", "db_mode", 2)

- modparam("auth", "calculate_ha1", yes)

- modparam("auth_db", "password_column", "password")

- if (!www_authorize("sip.org", "subscriber")) {
- www_challenge("sip.org", "0");
- break;
- };


Make sure you change the two sip.org instances in the above config, to your
domain, or realm. In my case, I changed this to 192.168.2.235 which was the
IP address of this box.

Also, be sure to comment out the following line:

modparam("usrloc", "db_mode", 0)


9. Now let us copy the init script so as to start OpenSER as service ( such as starting it at boot). Copy the openser.init which can be found on the base directory of the OpenSER source. In my case I installed the source on root directory

cp /root/openser-1.3.2-tls/packaging/rpm/openser.init /etc/init.d/openser
chmod 755 /etc/init.d/openser
/sbin/chkconfig --add openser

also before you start the openser correct the path of its service execution

vi /etc/init.d/openser

change the following line

oser=/usr/sbin/openser

with this one since we installed the binaries on path /usr/local

oser=/usr/local/sbin/openser


10. Now you can start the openser service

/sbin/service openser start

11. To test we will create user / SIP account to test our set up. We can do this by using the openserctl tool

openserctl add test testpasswd test@192.168.2.235

*Note you might encounter problem once you issued the command above and complaining for the SIP_DOMAiN. To fix that,
issue the command as follows:

export SIP_DOMAIN=192.168.2.235

Now re issue the command for adding new user / SIP account

12. Test it by registering a softphone and filling up the phone's registration info's. You should be able to register already.


"Now you have a working SIP Server". Actually I am still exploring it too..... I'll give you some more additional infos whatever turns out during my studied on this software. I am more familiar with tweaking Asterisk not this one. But I heard that using Asterisk/OpenSER tandem is great for offering VOIP services.

Okey that' all for this tutorial hope this help for those who are just about to start with SER/OpenSER. Cheers to all!!!! And God Bless!!!!! :-)

Here are some more helpful links:

http://www.openser.org/dokuwiki/doku.php/install:openser-from-svn
http://www.openser.org/mos/view/-OpenSER-Installation-Notes/
http://www.oldskoolphreak.com/tfiles/voip/beginners_openser.txt