OpenSIPS
Installation on Debian 10
- OpenSIPS v3 with GUI on Debian v10 MariaDB Apache install guide
- Quick Start to OpenSIPS Training 3.2
OpenSIPS 3.3
apt install gnupg2
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
# For Debian 10
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
# For Ubuntu 20
echo "deb https://apt.opensips.org focal 3.3-releases" >/etc/apt/sources.list.d/opensips.list
echo "deb https://apt.opensips.org focal 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
Configure the systemd
Edit: /etc/systemd/system/rtpproxy.service
[Unit]
Description=RTPProxy media server
After=network.target
Requires=network.target
[Service]
Type=simple
PIDFile=/var/run/rtpproxy/rtpproxy.pid
Environment='OPTIONS= -l 172.16.0.67 -A 154.19.187.227 -m 10000 -M 20000 -d INFO:LOG_LOCAL5'
Restart=always
RestartSec=5
ExecStartPre=-/bin/mkdir /var/run/rtpproxy
ExecStartPre=-/bin/chown opensips:opensips /var/run/rtpproxy
ExecStart=/usr/local/bin/rtpproxy -p /var/run/rtpproxy/rtpproxy.pid -s unix:/var/run/rtpproxy/rtpproxy.sock \
-u opensips:opensips $OPTIONS
ExecStop=/usr/bin/pkill -F /var/run/rtpproxy/rtpproxy.pid
ExecStopPost=-/bin/rm -R /var/run/rtpproxy
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rtpproxy
SyslogFacility=local5
TimeoutStartSec=10
TimeoutStopSec=10
[Install]
WantedBy=multi-user.target
Start the service
systemctl daemon-reload
systemctl start rtpproxy
systemctl enable rtpproxy
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/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
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
,如果有內容輸出表示模組載入成功。
Links
- https://opensips.org/
- https://www.rtpproxy.org/
- Quick Start to OpenSIPS Training 3.2
- opensips 簡介 1/2
Dispatcher
CGRateS
- Installation
- CGRateS Usage
- https://fossies.org/linux/opensips/modules/cgrates/README
- https://nickvsnetworking.com/category/voip/cgrates/
No Comments