OpenSIPs
From ProjectDiaStar
Contents |
OpenSIPs Introduction
OpenSIPS (Open SIP Server) describes itself as a "mature Open Source implementation of a SIP server". While it contains many application-level functions, the basic installation instructions here set it up for use as a SIP registrar and outbound proxy. In these roles it can allow SIP phones and the DiaStar Server to register and direct calls from one to the other by simply dialing by extension rather than full SIP URL.
Installing OpenSIPs
These instructions assume that you are starting with a DiaStar system from an ISO installation. You may already have the packages listed.
The directory /etc/yumrepos.d must be restored before any yum updates or installations can be done. This directory is removed as part of the ISO installation.
Preliminary Packages
These packages, not included on the DiaStar ISO installation, are needed for OpenSIPs:
# yum install bison # yum install flex # yum install lynx
MySQL
The MySQL relational database is used by OpenSIPs for persistent storage of registration information. The following RPMs are needed:
# yum install mysql # yum install mysql-server # yum install mysql-devel
Once it is installed, start the MySQL server:
# service mysqld start
Set root password with:
# mysqladmin -u root password opendialogic
Automatic startup of the msyql daemon on reboot is done with:
# chkconfig --add mysqld # chkconfig mysqld on
OpenSIPs
The following instructions are the minimum needed to get a SIP registrar and outbound proxy working. Further instructions for installation can be found here:
The documentation set for OpenSIPs is here.
Get the latest stable version of OpenSIPs. As of 08-June-2010 this was 1.6.2:
# wget http://opensips.org/pub/opensips/1.6.2/src/opensips-1.6.2-notls_src.tar.gz
Compile/install OpenSIPs as follows:
# tar xvzf opensips-1.6.2-notls_src.tar.gz # cd opensips-1.6.2-notls # make all include_modules="db_mysql" # make install include_modules="db_mysql"
OpenSIPs, DiaStar and SIP Phone Configuration
Edit /usr/local/etc/opensips/opensipsctlrc and comment in the following line:
DBENGINE=MYSQL
Create the MySQL database used with OpenSIPs:
# opensipsdbctl create
Enter the root password for MySQL and answer "y" to all questions.
Edit /usr/local/etc/opensips/opensips.cfg and comment in the following lines to enable DB support:
loadmodule "db_mysql.so"
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
Running OpenSIPs on a DiaStar server will cause a conflict on the standard SIP port 5060. This is easily resolved by running DiaStar on a different port, e.g. 5062. In your DiaStar config file(ususally /etc/diastar/diastar.conf) set:
bindport = 5062
While editing the file, enable SIP registration and outbound proxy setting by uncommenting and adding the correct values to the following lines:
; proxyaddr is the IPv4 address of the proxy server. proxyaddr = 127.0.0.1 ; proxyport is the SIP port number on the proxy server [5060]. proxyport = 5060 ; registraraddr is the IPv4 address of the Registrar. registraraddr = 127.0.0.1 ; registrarport is the SIP port number on the Registrar [5060]. registrarport = 5060 ; registrarttl is registration time-to-live period in seconds. registrarttl = 1800 ; register is used to define an entity to be registered. ; It has four comma seperated values: name,identity,password,realm ; Multiple entities may be registered by using separate lines. register = 1000,sip:1000@example.com,secret,diastar
The proxyaddr and proxyport is for outbound proxy setup. Any outbound calls from DiaStar will be sent to this proxy, where they are expected to be forwarded. Outbound proxy may or may not be used.
registraraddr and registrarport should be set to the IP address and SIP port for the OpenSIPs installation.
When done, restart the DiaStar server:
# service diastar restart
SIP phones will always include similar settings for registration and an outbound proxy. These should be set to the IP address of the DiaStar/OpenSIPs system.
Finally, start the OpenSIPs server:
# opensipsctl start
At this point, it may be necessary to define the SIP domain name before adding SIP users. One way to do this is to set the environment variable SIP_DOMAIN in root's .bashrc:
export SIP_DOMAIN=projectdiastar.org
Registered SIP entities can now find one another by SIP user name/number. Additional SIP users that correspond to Asterisk dialplan extensions can be added to the OpenSIPs database as follows:
# opensipsctl ul add 300 sip:300@diastarserver.com:5062
When a registered SIP phone dials 300, the call will be redirected by OpenSIPs to the DiaStar server, SIP username/Asterisk extension 300. Note that DiaStar is running on port 5062.
A list of registered users is easily obtained with the command:
# opensipsctl ul show
Note that automatically registered and manually added users will be persistent across OpenSIPs startups and shutdowns, as they are stored in the MySQL database.
