How to install OpenSIPS on Raspberry Pi?
6 min readHow to install OpenSIPS on Raspberry Pi?
- Raspberry Pi 5 vs. Mini PC with Intel N100 Processor
- Huawei NearLink Surpasses Bluetooth and WiFi on All Fronts
- Huawei: First Wi-Fi 7 Router BE3 Pro with 2.5G Port at US$68
- What are the differences between WiFi6 WiFi6e and WiFi7?
- PBX On Raspberry Pi
- FreePBX vs. FusionFBX
How to install OpenSIPS on Raspberry Pi?
OpenSIPS is an open-source SIP server that runs on Linux-based operating systems, and it can be installed on the Raspberry Pi using the Raspbian or Ubuntu operating systems.
To install OpenSIPS on a Raspberry Pi, you will need to follow these general steps:
-
Install the operating system on your Raspberry Pi. Raspbian or Ubuntu are both good choices.
-
Install the necessary dependencies for OpenSIPS, such as the C compiler, libraries, and development tools.
-
Download the OpenSIPS source code and compile it on your Raspberry Pi using the appropriate configuration options.
-
Install and configure any additional modules or plugins that you need for your specific use case.
-
Configure your OpenSIPS server using the appropriate configuration files, such as sip.conf and opensips.cfg.
-
Start the OpenSIPS service and test your configuration using a SIP client.
Keep in mind that installing and configuring OpenSIPS on a Raspberry Pi may require some technical knowledge and expertise, and you should carefully follow the instructions and best practices provided by the OpenSIPS documentation and community.
Step by stemp Installing Procedcure:
Here are the steps to install OpenSIPS on a Raspberry Pi running Raspbian or Ubuntu:
-
Update the package lists:
sudo apt-get update
-
Install the dependencies:
sudo apt-get install git build-essential flex bison libssl-dev libxml2-dev libncurses5-dev libsqlite3-dev libpq-dev libmysqlclient-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libtool-bin libmariadbclient-dev
-
Clone the OpenSIPS source code from GitHub:
git clone https://github.com/OpenSIPS/opensips.git
-
Change to the OpenSIPS directory:
cd opensips
-
Configure and compile OpenSIPS:
make menuconfig
make all
make install
Note: During the
make menuconfig
step, you can configure various options and modules for your specific use case. You can use the arrow keys to navigate, spacebar to select options, and Enter to confirm. -
Create a new OpenSIPS configuration file:
sudo nano /usr/local/etc/opensips/opensips.cfg
-
Add the following basic configuration to the file:
# Basic configuration
log_stderror
debug_mode = 1
children = 1
# Listen on all interfaces
listen = udp:0.0.0.0:5060
# Routing rules
route {
# Echo back any requests
if (is_method("INVITE")) {
sl_send_reply("100", "Trying");
if (!t_relay()) {
sl_reply_error();
}
}
# Handle all other requests
else {
sl_send_reply("200", "OK");
}
}
-
Save and exit the file.
-
Start the OpenSIPS service:
sudo service opensips start
Note: You can also stop or restart the service using
sudo service opensips stop
orsudo service opensips restart
. -
Test your configuration using a SIP client, such as Linphone or Zoiper. Set the SIP server address to your Raspberry Pi’s IP address and port 5060. You should be able to make and receive calls to the Echo back routing rule defined in step 7.
That’s it! You should now have a basic OpenSIPS server running on your Raspberry Pi.
You can further customize and configure OpenSIPS by editing the configuration file and installing additional modules or plugins.
How to add an extension in OpenSIPs?
-
Create a new SIP account for the extension in your OpenSIPS database or user location module. This will typically involve adding a new record to your MySQL, PostgreSQL, or other database, or creating a new user in your user location module.
-
Define the routing rules for the extension in your OpenSIPS configuration file. This will typically involve adding a new route block that matches the extension number or SIP URI and specifies the actions to take when a call is received for that extension.
For example, the following configuration block defines a route for extension 1000 that forwards incoming calls to the SIP address “sip:1000@example.com”:
route {
if (uri == "sip:1000@example.com") {
# Forward the call to extension 1000
forward("sip:1000@192.168.1.100");
exit;
}
} -
Reload your OpenSIPS configuration file to apply the changes:
opensipsctl reload
-
Configure your SIP client or PBX to register the new extension with OpenSIPS. This will typically involve entering the SIP address or extension number, username, password, and server address in your client or PBX configuration settings.
-
Test the extension by making a call to its SIP address or number. If everything is configured correctly, the call should be forwarded to the extension and you should hear ringing or an answer from the extension.
Keep in mind that adding an extension to OpenSIPS may involve additional configuration steps depending on your specific use case and network topology.
You should carefully follow the instructions and best practices provided by the OpenSIPS documentation and community to ensure a secure and reliable installation.
How to install the UI on OpenSIPs?
However, there are several open-source UIs available that you can use to monitor and manage your OpenSIPS deployment.
One popular option is the OpenSIPS Control Panel (OCP), which is a web-based UI that provides a graphical interface for configuring and monitoring your OpenSIPS instance.
Here are the general steps to install the OpenSIPS Control Panel (OCP) on your OpenSIPS server:
-
Install a web server (e.g., Apache, Nginx) on your OpenSIPS server, if not already installed. You can install Apache by running the following command:
sudo apt-get update
sudo apt-get install apache2
-
Install PHP and the required PHP modules on your OpenSIPS server. You can install PHP and the required modules by running the following command:
sudo apt-get install php php-cli php-mysql php-gd php-xml php-curl php-mbstring
-
Download the latest version of OCP from the official website:
wget https://github.com/OpenSIPS/opensips-cp/archive/8.0.tar.gz
-
Extract the downloaded archive and move the OCP files to your web server’s document root directory:
tar -xzf 8.0.tar.gz
sudo mv opensips-cp-8.0 /var/www/html/opensips-cp
-
Create a new MySQL database and user for OCP. You can use the following commands to create a new MySQL database and user:
sudo mysql -u root -p
create database opensipscp;
create user opensipscpuser@localhost identified by 'password';
grant all on opensipscp.* to opensipscpuser@localhost;
exit;
-
Import the OCP database schema into the new database:
sudo mysql -u root -p opensipscp < /var/www/html/opensips-cp/config/tools/opensips-cp-8.0/mysql/schema.sql
-
Configure OCP by copying the sample configuration file and modifying it with your database and OpenSIPS server settings:
cd /var/www/html/opensips-cp/config
sudo cp opensips-cp.cfg.sample opensips-cp.cfg
sudo nano opensips-cp.cfg
In the configuration file, set the values for
DB_HOST
,DB_USER
, andDB_PASS
to match your MySQL database settings, and set the value forOPENSIPS_HOST
to match the IP address or hostname of your OpenSIPS server. -
Start your web server and navigate to the OCP URL in your web browser:
http://<your-server-ip>/opensips-cp/
You should see the OCP login page. Use the default username
admin
and passwordopensips
to log in.
Once you have successfully installed OCP, you can use it to monitor your OpenSIPS deployment, view call statistics, configure routing rules, and manage users and extensions.
SD card for Raspberry Pi
Raspberry Pi 3/4 is powerful enough for small office.
As SD card has limited times for writing/Reading, we recommend to cost a little more to buy Endurance Cards of Samsung or Sandisk for formal uses (office).
Other VoIP Solution:
PBX on Raspberry Pi
How to install Kamaillio on Raspberry Pi 3 or 4?
How to install SIPfoundry on Raspberry Pi?
How to install OpenSIPS on Raspberry Pi?