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

RTPProxy
apt install build-essential
apt install libucl-dev
cd /usr/src
git clone -b master https://github.com/sippy/rtpproxy.git
git -C rtpproxy submodule update --init --recursive
cd rtpproxy
./configure
make clean all
make install


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, PRESENCE
/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
chmod 0644 /etc/opensips/opensips.cfg

# Restart OpenSIPS
systemctl restart opensips

opensips.cfg for server behind the firewall

/* 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

opensips.cfg for RTPProxy

### RTPProxy module ###
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.cfg for dispatcher

### Dispatcher modules ###
loadmodule "dispatcher.so"
modparam("dispatcher", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
modparam("dispatcher", "dst_avp", "$avp(271)")
modparam("dispatcher", "attrs_avp", "$avp(272)")
modparam("dispatcher", "grp_avp", "$avp(273)")
modparam("dispatcher", "cnt_avp", "$avp(274)")
modparam("dispatcher", "hash_pvar", "$avp(273)")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_from", "sip:sipcheck@outbound_IP:5060")
modparam("dispatcher", "ds_ping_interval", 10)
modparam("dispatcher", "ds_probing_threshhold", 3)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "options_reply_codes", "501,403,404,400,200")


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"
Log file

Edit: /etc/rsyslog.d/opensips.conf

local0.*                        -/var/log/opensips.log

Restart rsyslog

touch /var/log/opensips.log
systemctl restart rsyslog

OpenSIPS CLI

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

FAQ

OCP 的 dispatcher 頁面出現空白

Solution: 檢查 dispatcher 與 mi_http 模組是否載入成功。驗證方式可以用 OCP 的 MI Commands 執行 ds_list,如果有內容輸出表示模組載入成功。

Dispatcher

CGRateS