Skip to main content

OpenSIPS

Installation on Debian 10

OpenSIPS 3.3
apt install gnupg2
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
echo "deb https://apt.opensips.org buster 3.3-releases" >/etc/apt/sources.list.d/opensips.list
echo "deb https://apt.opensips.org buster cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list
apt update
apt install opensips
apt install opensips-cli

# Install all other modules
apt install opensips-*

# Start opensips and check the status
systemctl start opensips
systemctl status opensips
OpenSIPS Database Support (MySQL)
# Install MySQL Server (MariaDB on Debian 10)
apt install mariadb-server

# Create the database opensips using the OpenSIPS command line interface
opensips-cli -x database create opensips

# Verify if the tables were created
mysql opensips -e "show tables"

# Set the root's password for MariaDB and complete a few secure steps.
MariaDB> alter user 'root'@'localhost' identified by 'newpassword';
MariaDB> flush privileges;
MariaDB> exit
OpenSIPS Control Panel 9.3.3
# Install Apache, PHP and other dependencies
apt-get install apache2 libapache2-mod-php php-curl php php-mysql php-gd php-pear php-cli php-apcu git

# Download the OCP 9.3.3
git clone -b 9.3.3 https://github.com/OpenSIPS/opensips-cp.git /var/www/opensips-cp

Configure Apache

# Remove the default configuration
rm /etc/apache2/sites-enabled/000-default.conf

Edit: /etc/apache2/sites-enabled/opensips.conf

<VirtualHost *:80>
        <Directory /var/www/opensips-cp/web>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all granted
        </Directory>

        <Directory /var/www/opensips-cp>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all denied
        </Directory>

        Alias /cp /var/www/opensips-cp/web

        <DirectoryMatch "/var/www/opensips-cp/web/tools/.*/.*/(template|custom_actions|lib)/">
                Require all denied
        </DirectoryMatch>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Set the permissions of directories

chown -R www-data:www-data /var/www/opensips-cp/

Creating the OCP tables

# This will create the OCP specific tables into the opensips database and add a first access user, 
# the admin user with the opensips password.
mysql -uroot -p opensips < /var/www/opensips-cp/config/db_schema.mysql

set Cron jobs

cp /var/www/opensips-cp/config/tools/system/smonitor/opensips_stats_cron /etc/cron.d
sed -i 's/\/var\/www\/html\/opensips-cp/\/var\/www\/opensips-cp/g' /etc/cron.d/opensips_stats_cron

Restart Apache

systemctl restart apache2

Visit the OCP Web site: http://server-ip-address/cp , admin / opensips

Configuration

OpenSIPS

Generate config file

# Install the package required
apt install m4

# -> Residential Script
# --> Configure Residential Script
# ---> Select all options except for TLS, VM_DIVERSION
/usr/sbin/osipsconfig

mv /etc/opensips/opensips.cfg /etc/opensips/opensips.cfg.orig
mv /etc/opensips/opensips_residential_2023-3-19_6:6:6.cfg /etc/opensips/opensips.cfg

/etc/opensips/opensips.cfg for NAT environment

/* For AWS and OpenStack Environment */
/* WAN IP: 123.123.123.123 */
/* LAN IP: 172.16.0.67
advertised_address="123.123.123.123"
alias="123.123.123.123"

socket=udp:172.16.0.67:5060
socket=tcp:172.16.0.67:5060

...
...

loadmodule "rtpproxy.so"
## Fixed for ERROR:rtpproxy:send_rtpp_command: proxy <udp:localhost:7890> does not respond, disable it
#modparam("rtpproxy", "rtpproxy_sock", "udp:localhost:7890")
modparam("rtpproxy", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
OpenSIPS Control Panel (OCP)

OCP 管理模組開啟與關閉

編輯: config/modules.inc.php

資料庫連線資訊

編輯: config/db.inc.php

RTPProxy

/etc/default/rtpproxy

## Replace with your network interface IP address
## If you have WAN IP & LAN IP as follows, here is LAN IP.
## WAN IP: 123.123.123.123
## LAN IP: 172.16.0.67
LISTEN_ADDR=172.16.0.67

# The control socket.
CONTROL_SOCK="unix:/var/run/rtpproxy.sock"
# To listen on an UDP socket, uncomment this line:
# CONTROL_SOCK=udp:127.0.0.1:7890

## If the rtpproxy is behind a NAT firewall. The WAN IP is configured by the -A option.
## NOTE: The option "-A" is supported on RTPProxy newer version only.
#EXTRA_OPTS="-l $LISTEN_ADDR -m 10000 -M 20000"
EXTRA_OPTS="-l $LISTEN_ADDR -m 10000 -M 20000 -A 123.123.123.123"

OpenSIPS CLI

# opensips-cli -x mi version
{
    "Server": "OpenSIPS (3.1.14 (x86_64/linux))"
}

Dispatcher

CGRateS