OpenSIPS v2 with GUI on Debian v8 MariaDB Apache install guide
OpenSIPS is a multi-functional, multi-purpose SIP server used by carriers, telecoms or ITSPs for solutions like Class4/5 Platforms, Trunking / Wholesale, Enterprise / Virtual PBX Solutions, Session Border Controllers, Application Servers, Front-End Load Balancers, IMS Platforms, Call Centers, and many other things.
Tested on:
Debian v8 (Jessie) x64 minimal install
OpenSips v2.4
OpenSips GUI v8.2.4
Apache v2.4
PHP v5.6
MariaDB v10
Prerequisites
apt update && apt upgrade -y
apt -y install m4 git nano sudo curl dbus monit apache2 lsb-release
PHP
Install PHP v5
apt -y install php5 php5-gd php5-mysql php5-xmlrpc php-pear php5-cli php-apc php5-curl libapache2-mod-php5
pear install MDB2#mysql
sed -i "s#short_open_tag = Off#short_open_tag = On#g" /etc/php5/apache2/php.ini
MariaDB
# Set root password when asked. Otherwise it will keep nagging. apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash apt -y install mariadb-server
Add the following line under [mysqld]
to disable strict mode.
nano /etc/mysql/my.cnf
sql_mode=''
systemctl restart mariadb
Disable Firewall
It is sometimes helpful to disable the firewall during installation.
systemctl disable firewalld systemctl disable iptables systemctl stop firewalld systemctl stop iptables
Timezone
## FIND YOUR TIMEZONE tzselect ## SET TIMEZONE EXAMPLE timedatectl set-timezone America/Vancouver ## CHECK TIMEZONE timedatectl status
systemctl restart rsyslog
Install
OpenSips
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B echo "deb http://apt.opensips.org $(lsb_release -sc) 2.4-releases" >/etc/apt/sources.list.d/opensips.list
apt update && apt -y install opensips opensips-mysql-module opensips-postgres-module opensips-unixodbc-module opensips-jabber-module opensips-cpl-module opensips-radius-modules opensips-presence-modules opensips-xmlrpc-module opensips-perl-modules opensips-snmpstats-module opensips-xmpp-module opensips-carrierroute-module opensips-berkeley-module opensips-ldap-modules opensips-geoip-module opensips-regex-module opensips-identity-module opensips-b2bua-module opensips-dbhttp-module opensips-console opensips-dialplan-module opensips-http-modules opensips-tls-module opensips-cgrates-module
DB install
nano /etc/opensips/opensipsctlrc
Remove #
from the following line
DBENGINE=MYSQL
/usr/sbin/opensipsdbctl create
Answer y
to everything
Config generator
/usr/sbin/osipsconfig
Navigate to Generate OpenSIPS Script > Residential Script > Configure Residential Script
> Select everything except TLS with spacebar. Hit q key to go back to previous menu. Select Generate Residential Script
. The tool will show the location and name of the generated script.
mv /etc/opensips/opensips.cfg /etc/opensips/opensips.cfg.orig cp /etc/opensips/generated_script_name.cfg /etc/opensips/opensips.cfg chmod 644 /etc/opensips/opensips.cfg
edit lines marked by # CUSTOMIZE ME
comment if not using the default DB credentials.
Addtional configs.
nano /etc/opensips/opensips.cfg
## Replace the listen=xxp:127.0.0.1:5060
lines substituting in the IP of the server
listen=udp:x.x.x.x:5060
listen=tcp:x.x.x.x:5060
## Add or update HTTPD module section. These two modules are required for OpenSIPS control panel.
## The httpd.so module must be loaded first.
## Verify the modules are not loaded more than once in the file otherwise OpenSIPS will not start.
## If you generated the script with all options selected it will add httpd.so on port 8888.
## Change that port to 8080 and add loadmodule "mi_json.so".
#### HTTPD module
loadmodule "httpd.so"
modparam("httpd", "port", 8080)
loadmodule "mi_json.so"
Check config file validity and show any errors
opensips -C /etc/opensips
If no errors, load config file
systemctl restart opensips
Show console commandsopensipsctl
View internal statusopensipsctl moni
Control Panel
git clone -b 8.2.4 https://github.com/OpenSIPS/opensips-cp.git /var/www/opensips
Create OCP table
Before logging in as admin
, you must first create the relevant table in the database and add admin
user.
cd /var/www/opensips/config mysql -p opensips < db_schema.mysql
Statistics monitor
cat >> /etc/cron.d/opensips_stats_cron << EOF # run the statistics sampling once every minute * * * * * root (cd /var/www/opensips/; /usr/bin/php cron_job/get_opensips_stats.php) # run the statistics cleanup once every hour, at x:10 10 * * * * root (cd /var/www/opensips/; /usr/bin/php cron_job/clean_statistics.php) EOF
Monit config
echo -e "set httpd port 2812 and\nallow localhost" >> /etc/monit/monitrc systemctl restart monit
In the following file, if not using ssl change to ['has_ssl']=0
.
Change json:127.0.0.1:8888
to json:127.0.0.1:8080
nano /var/www/opensips/config/boxes.global.inc.php
Apache config
cat >> /etc/apache2/sites-available/opensips.conf << EOF <VirtualHost *:80> DocumentRoot /var/www/opensips <Directory /var/www/opensips/web> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> <Directory /var/www/opensips> Options Indexes FollowSymLinks MultiViews AllowOverride None Order deny,allow deny from all </Directory> Alias /cp /var/www/opensips/web </VirtualHost> EOF
a2dissite 000-default a2ensite opensips
chown -R www-data. /var/www/opensips
systemctl restart apache2
browse to http://x.x.x.x/cp
username: admin
password: opensips
Misc
Firewall
apt -y install firewalld systemctl enable firewalld systemctl start firewalld firewall-cmd --permanent --zone=public --add-service={http,https} firewall-cmd --permanent --zone=public --add-port={5060,5061}/tcp firewall-cmd --permanent --zone=public --add-port={5060,5061}/udp firewall-cmd --reload firewall-cmd --list-all
Log file
To write OpenSips logs to a separate log file in addition to /var/log/syslog.
## Add the following line to /etc/rsyslog.conf local0.* -/var/log/opensips.log
touch /var/log/opensips.log systemctl restart rsyslog
Basic configuration
This shows a basic configuration consisting of local users and a SIP trunk provider.
Create a local user
From OpenSIPS control panel:
System > Domains > Add Domain > x.x.x.x
where x.x.x.x
is the IP of the server.
Users > User Management > Add New User
Create an extension number username (such as "1000"), and assign the above domain and a password. You can also create a named username (such as "joe") and assign alias username (such as "1000") as extension number for dialing.
Point a SIP device at the server IP and add the user credentials above. The SIP device should indicate it is registered. Add a second device and you should be able to make extension to extension calls between them.
Verify registration info by clicking on "Contacts" icon in User Management . On OpenSIPS cli use opensipsctl ul show
.
Set up a SIP trunk
For inbound calling simply point the DID number to the IP of the OpenSIPS server and set the SIP Trunk to IP authentication on the SIP provider end.
Add gateway source IP for inbound (DID) at Dynamic Routing > Gateways
GWID = SomeSipProvider Type = 1 (Proxy) Address = x.x.x.x # Where x.x.x.x is the IP address of calls coming from your Sip Provider.
Click on "Apply Changes to Server" in upper right of screen.
You can add IP authentication on the OpenSips end by using is_from_gw("1")
or loading Permissions Module, adding the IP to Permissions in the Menu, and using check_source_address("1")
. How that is implemented is beyond the scope of this document.
Inbound Calling
For dialing directly from the PSTN to a configured user via the configured SIP trunk. This may vary depending on what DID format the SIP trunk provider sends.
Users > Alias Management
Username = someusername # This user name must exist in Users > User Management Alias Username = 1NXXNXXXXXX # This is your DID phone number
You should now be able to make phone calls from the PSTN to your user by dialing the DID phone number.
Outbound Calling
For dialing directly to the PSTN from any configured user. This may vary depending on what format the SIP trunk provider expects.
Around line 360 in opensips.cfg, replace
if ($rU=~"^\+[1-9][0-9]+$") {
with
if (dp_translate("10","$rU/$rU") ) {
restart to load the change
systemctl restart opensips
From the GUI control panel System > Dialplan > Add New Rule
for +E.164 dialing if this is what the SIP provider expects.
Dialplan ID = 10 Rule Priority = 1 Matching Regular Expression = ^\+[1-9][0-9]+$
Add new rule for E.164 North American dialing (1NXXNXXXXXX) if this is what the SIP trunk provider expects.
Dialplan ID = 10 Rule Priority = 2 Matching Regular Expression = ^1[1-9][0-9]{9}+$
Click on "Apply Changes to Server" in upper right of screen.
System > Dynamic Routing > Rules > Add New
Group ID = 0 #Click the "Add" button below it to populate the "0" Prefix = 1 #Dialed numbers that begin with 1 Gateways List = YourGatewayName #Click the "Add" button to populate Gateway List with your Gateway
Click on "Apply Changes to Server" in upper right of screen.
You should now be able to dial from any local user to the PSTN dialing 11 digit North American numbers which start with 1.